diff --git a/db/seeds.rb b/db/seeds.rb index 9f074e1ee..00c8ef10a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,13 +4,13 @@ if %w[development test dev local].include?(Rails.env) pwd = "cmsadmin" else - pwd = (0..8).inject(""){|s,i| s << (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a).rand} + pwd = (0..8).inject("") { |s, i| s << (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a).rand } end User.current = create_user(:cmsadmin, :login => "cmsadmin", :first_name => "CMS", :last_name => "Administrator", :email => "cmsadmin@example.com", :password => pwd, :password_confirmation => pwd) -create_permission(:administrate, :name => "administrate", :full_name => "Administer CMS" , :description => "Allows users to administer the CMS, including adding users and groups.") -create_permission(:edit_content, :name => "edit_content", :full_name => "Edit Content" , :description => "Allows users to Add, Edit and Delete both Pages and Blocks. Can Save (but not Publish) and Assign them as well.") -create_permission(:publish_content, :name => "publish_content", :full_name => "Publish Content" , :description => "Allows users to Save and Publish, Hide and Archive both Pages and Blocks.") +create_permission(:administrate, :name => "administrate", :full_name => "Administer CMS", :description => "Allows users to administer the CMS, including adding users and groups.") +create_permission(:edit_content, :name => "edit_content", :full_name => "Edit Content", :description => "Allows users to Add, Edit and Delete both Pages and Blocks. Can Save (but not Publish) and Assign them as well.") +create_permission(:publish_content, :name => "publish_content", :full_name => "Publish Content", :description => "Allows users to Save and Publish, Hide and Archive both Pages and Blocks.") create_group_type(:guest_group_type, :name => "Guest", :guest => true) create_group_type(:registered_public_user, :name => "Registered Public User") @@ -26,13 +26,13 @@ groups(:content_admin).permissions< "Default", :domain => "example.com") create_section(:root, :name => "My Site", :path => "/", :root => true) create_section(:system, :name => "system", :parent => sections(:root), :path => "/system", :hidden => true) - -Group.all.each{|g| g.sections = Section.all } + +Group.all.each { |g| g.sections = Section.all } create_page(:home, :name => "Home", :path => "/", :section => sections(:root), :template_file_name => "default.html.erb", :cacheable => true) create_page(:not_found, :name => "Page Not Found", :path => "/system/not_found", :section => sections(:system), :template_file_name => "default.html.erb", :publish_on_save => true, :hidden => true, :cacheable => true) @@ -50,9 +50,10 @@ create_html_block(:server_error, :name => "Server Error", :content => "

The server encountered an unexpected condition that prevented it from fulfilling the request.

", :publish_on_save => true) pages(:server_error).create_connector(html_blocks(:server_error), "main") pages(:server_error).publish! -pages(:home).publish! - -puts "*************************************************" -puts "* YOUR CMS username/password is: cmsadmin/#{pwd}" -puts "*************************************************" - +pages(:home).publish! + +unless Cms::DataLoader.silent_mode + puts "*************************************************" + puts "* YOUR CMS username/password is: cmsadmin/#{pwd}" + puts "*************************************************" +end diff --git a/features/content_pages.feature b/features/content_pages.feature deleted file mode 100644 index ee0ac618b..000000000 --- a/features/content_pages.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Content Pages - In order to see a website - As an guest - I want a CMS that services content pages - -Background: Blank CMS Install - Given there is a homepage - -Scenario: Homepage - Given I am on the homepage - Then I should see a page titled "THIS TEST IS PASSING WHEN IT SHOULDN'T" - -Scenario: Homepage exists - Given I am on the homepage - Then the homepage should exist \ No newline at end of file diff --git a/features/install_content.feature b/features/install_content.feature new file mode 100644 index 000000000..5a70a49fe --- /dev/null +++ b/features/install_content.feature @@ -0,0 +1,14 @@ +Feature: Install blank site + In order to have a reasonable starting point + a web developer + wants a a blank site to be created with seed content. + + Scenario: A homepage exists + Given I am on the homepage + Then I should see a page titled "Home" + + Scenario: An error page exists + Given I am at /system/server_error + Then I should see a page titled "Server Error" + + diff --git a/features/step_definitions/content_pages_steps.rb b/features/step_definitions/content_pages_steps.rb index ccb470b1b..0d2a20d67 100644 --- a/features/step_definitions/content_pages_steps.rb +++ b/features/step_definitions/content_pages_steps.rb @@ -1,7 +1,7 @@ # ex: Then I should see a page titled "Home" Then /^I should see a page titled "([^"]*)"$/ do |page_title| - page.has_css?("title", :text=>page_title) - page.has_content?(page_title) + page.should have_css("title", :text=>page_title) + page.should have_content(page_title) end Given /^I am logged in as a Content Editor$/ do @@ -30,14 +30,13 @@ end Given /^there is a homepage$/ do - page = Page.with_path("/").first - if page - @homepage = page - else - @homepage = Factory(:page, :path=>"/", :name=>"Home Page") - end + @homepage = Page.with_path("/").first end Then /^I should see Welcome, cmsadmin$/ do page.has_content? 'Welcome, cmsadmin' +end + +Given /^I am at (.+)/ do |path| + visit path end \ No newline at end of file diff --git a/features/step_definitions/install_content_steps.rb b/features/step_definitions/install_content_steps.rb new file mode 100644 index 000000000..eb36253b8 --- /dev/null +++ b/features/step_definitions/install_content_steps.rb @@ -0,0 +1 @@ +# Steps go here. \ No newline at end of file diff --git a/features/support/paths.rb b/features/support/paths.rb index 06b3efb0b..5db3c9b21 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -11,6 +11,7 @@ def path_to(page_name) when /the home\s?page/ '/' + # Add more mappings here. # Here is an example that pulls values out of the Regexp: # diff --git a/features/support/test_setup.rb b/features/support/test_setup.rb new file mode 100644 index 000000000..8c6e15520 --- /dev/null +++ b/features/support/test_setup.rb @@ -0,0 +1,11 @@ +require 'cms/data_loader' + +AfterConfiguration do + DatabaseCleaner.clean + Cms::DataLoader.silent_mode = true + require File.join(File.dirname(__FILE__), '../../db/seeds.rb') +end + + +require 'factory_girl' +require File.join(File.dirname(__FILE__), '../../test/factories.rb') diff --git a/lib/cms/data_loader.rb b/lib/cms/data_loader.rb index 2fc49a850..924a10f63 100644 --- a/lib/cms/data_loader.rb +++ b/lib/cms/data_loader.rb @@ -1,5 +1,8 @@ module Cms module DataLoader + + mattr_accessor :silent_mode + def method_missing(method_name, *args) if md = method_name.to_s.match(/^create_(.+)$/) begin @@ -17,7 +20,7 @@ def method_missing(method_name, *args) end end def create(model_name, record_name, data={}) - puts "-- create_#{model_name}(:#{record_name})" + puts "-- create_#{model_name}(:#{record_name})" unless Cms::DataLoader.silent_mode @data ||= {} @data[model_name.pluralize.to_sym] ||= {} model = model_name.classify.constantize.new(data) diff --git a/test/factories.rb b/test/factories.rb index 7441d1106..c5c886cde 100644 --- a/test/factories.rb +++ b/test/factories.rb @@ -102,12 +102,22 @@ m.sequence(:name) {|n| "TestPermission#{n}" } end +def create_or_find_root_section + root = Section.root.first + unless root + root = Section.create!(:name=>"Root", :root=>true, :path=>"/") + end + root +end + Factory.define :section do |m| m.name "Test" m.path "/" - m.parent { Section.root.first } + m.parent { create_or_find_root_section } end + + Factory.define :site do |m| m.sequence(:name) {|n| "Test #{n}"} m.domain {|a| "#{a.name.gsub(/\s/,"_").downcase}.com" } diff --git a/todo_list.txt b/todo_list.txt index 9cc8a93c5..70a2f43be 100644 --- a/todo_list.txt +++ b/todo_list.txt @@ -3,7 +3,12 @@ Status BrowserCMS 3.3.0 is complete. -Gems to Publish (once its live) +Cucumber Recommendations +* Avoid using selectors unless it really matters. +* Express intent in scenarios +* Can group multiple steps into a single step + + Gems to Publish (once its live) ============ bcms_fckeditor - 1.1.0 is pushed to github. Gem needs to be pushed as well. Need to test file upload (browser.xml) from within the browser bcms_news - 1.2 pushed to github. Gem not released yet. (Has bugs)