From c7ea5ab532492fdc36ca96712cabebc12bf6b1b8 Mon Sep 17 00:00:00 2001 From: did Date: Wed, 29 Jun 2011 14:00:26 +0200 Subject: [PATCH] add more features for the model section --- app/views/admin/contents/_list.html.haml | 2 +- config/cucumber.yml | 2 +- config/locales/admin_ui.en.yml | 1 + config/locales/admin_ui.fr.yml | 1 + doc/TODO | 12 +++++- features/admin/contents.feature | 38 ++++++++++++++++++- .../step_definitions/content_types_steps.rb | 7 +++- features/step_definitions/more_web_steps.rb | 3 ++ features/support/paths.rb | 3 ++ 9 files changed, 63 insertions(+), 6 deletions(-) create mode 100644 features/step_definitions/more_web_steps.rb diff --git a/app/views/admin/contents/_list.html.haml b/app/views/admin/contents/_list.html.haml index 497ede88..40ba8e29 100644 --- a/app/views/admin/contents/_list.html.haml +++ b/app/views/admin/contents/_list.html.haml @@ -12,4 +12,4 @@ != t('admin.contents.index.updated_at') = l content.updated_at, :format => :short rescue 'n/a' - = link_to image_tag('admin/list/icons/trash.png'), admin_content_path(@content_type.slug, content), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete \ No newline at end of file + = link_to image_tag('admin/list/icons/trash.png', :alt => t('admin.buttons.delete')), admin_content_path(@content_type.slug, content), :class => 'remove', :confirm => t('admin.messages.confirm'), :method => :delete \ No newline at end of file diff --git a/config/cucumber.yml b/config/cucumber.yml index 19b288df..621a14ce 100644 --- a/config/cucumber.yml +++ b/config/cucumber.yml @@ -1,7 +1,7 @@ <% rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" -std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip" %> default: <%= std_opts %> features wip: --tags @wip:3 --wip features diff --git a/config/locales/admin_ui.en.yml b/config/locales/admin_ui.en.yml index e767dbca..5caa9719 100644 --- a/config/locales/admin_ui.en.yml +++ b/config/locales/admin_ui.en.yml @@ -6,6 +6,7 @@ en: change_password: Update new_item: "+ add" switch_to_site: Go + delete: "Delete" messages: confirm: Are you sure ? diff --git a/config/locales/admin_ui.fr.yml b/config/locales/admin_ui.fr.yml index 83052244..d81db98c 100644 --- a/config/locales/admin_ui.fr.yml +++ b/config/locales/admin_ui.fr.yml @@ -16,6 +16,7 @@ fr: change_password: Mettre à jour new_item: "+ ajouter" switch_to_site: Aller + delete: "Supprimer" messages: confirm: "Êtes-vous sûr(e) ?" diff --git a/doc/TODO b/doc/TODO index f5183530..e57c4976 100644 --- a/doc/TODO +++ b/doc/TODO @@ -45,7 +45,16 @@ x cancan: (authors / designers / admin) x theme asset x features / specs x enable rack-cache only for a specific url +- check hosting: + x heroku + - bushi.do + - deploy => okay + - unable to reach the console + - unable to set a new subdomain - convert existing templates (the 2 of the themes section) +- liquid tag: Date.today (now), add a test to compare 2 dates +- tinyMCE => fullscreen +- icon for redirection page in the pages section (back-office) => MERGE @@ -53,7 +62,6 @@ x enable rack-cache only for a specific url - heroku: unable to upload a new file => okay - import => okay - delete an item => okay -- liquid tag: Date.today (now), add a test to compare 2 dates - better ui: increase text field length + refactor error message BACKLOG: @@ -68,7 +76,7 @@ BACKLOG: - global regions: keyword in editable element (http://www.mongodb.org/display/DOCS/Updating) - cucumber features for admin pages (in progress) (- duostack/doutcloud version) -- icon for redirection page in the pages section (back-office) + - write my first tutorial about locomotive - upgrade warning if new version of locomotive (maybe based on the commit id) - deploying workflow: diff --git a/features/admin/contents.feature b/features/admin/contents.feature index 36654a08..a9d0e172 100644 --- a/features/admin/contents.feature +++ b/features/admin/contents.feature @@ -7,10 +7,46 @@ Background: Given I have the site: "test site" set up And I have a custom project model And I am an authenticated user + And I have a project entry with "My sexy project" as name and "Lorem ipsum" as description -Scenario: Adding a new entry +Scenario: + When I go to the "Projects" model list page + Then I should see "My sexy project" + +Scenario: Add a new entry When I go to the "Projects" model edition page And I follow "new item" Then I should see "Projects — new item" + When I fill in "Name" with "My other sexy project" + And I fill in "Description" with "Lorem ipsum...." + And I press "Create" + Then I should see "Content was successfully created." +Scenario: Add an invalid entry + When I go to the "Projects" model edition page + And I follow "new item" + And I fill in "Description" with "Lorem ipsum...." + And I press "Create" + Then I should not see "Content was successfully created." +Scenario: Update an existing entry + When I go to the "Projects" model list page + And I follow "My sexy project" + When I fill in "Name" with "My other sexy project (UPDATED)" + And I press "Update" + Then I should see "Content was successfully updated." + When I go to the "Projects" model list page + Then I should see "My other sexy project (UPDATED)" + +Scenario: Update an invalid entry + When I go to the "Projects" model list page + And I follow "My sexy project" + When I fill in "Name" with "" + And I press "Update" + Then I should not see "Content was successfully updated." + +Scenario: Destroy an entry + When I go to the "Projects" model list page + And I follow image link "Delete" + Then I should see "Content was successfully deleted." + And I should not see "My sexy project" \ No newline at end of file diff --git a/features/step_definitions/content_types_steps.rb b/features/step_definitions/content_types_steps.rb index 86a57b07..a97f8332 100644 --- a/features/step_definitions/content_types_steps.rb +++ b/features/step_definitions/content_types_steps.rb @@ -1,7 +1,12 @@ Given /^I have a custom project model/ do site = Site.first @content_type = Factory.build(:content_type, :site => site, :name => 'Projects') - @content_type.content_custom_fields.build :label => 'Name', :kind => 'string' + @content_type.content_custom_fields.build :label => 'Name', :kind => 'string', :required => true @content_type.content_custom_fields.build :label => 'Description', :kind => 'text' @content_type.save.should be_true +end + +Given /^I have a project entry with "(.*)" as name and "(.*)" as description/ do |name, description| + @content = @content_type.contents.build :name => name, :description => description + @content.save.should be_true end \ No newline at end of file diff --git a/features/step_definitions/more_web_steps.rb b/features/step_definitions/more_web_steps.rb new file mode 100644 index 00000000..e4530498 --- /dev/null +++ b/features/step_definitions/more_web_steps.rb @@ -0,0 +1,3 @@ +When /^I follow image link "([^"]*)"$/ do |img_alt| + find(:xpath, "//img[@alt = '#{img_alt}']/parent::a").click() +end \ No newline at end of file diff --git a/features/support/paths.rb b/features/support/paths.rb index 289b385c..53e2000c 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -27,6 +27,9 @@ module NavigationHelpers edit_admin_current_site_path when /import page/ new_admin_import_path + when /the "(.*)" model list page/ + content_type = Site.first.content_types.where(:name => $1).first + admin_contents_path(content_type.slug) when /the "(.*)" model edition page/ content_type = Site.first.content_types.where(:name => $1).first edit_admin_content_type_path(content_type)