diff --git a/app/views/contexts/_context_listing.rhtml b/app/views/contexts/_context_listing.rhtml index 3be6d091..ce616d16 100644 --- a/app/views/contexts/_context_listing.rhtml +++ b/app/views/contexts/_context_listing.rhtml @@ -26,7 +26,8 @@ :with => "'_source_view=#{@source_view}'", :before => "$('#{dom_id(context)}').block({message:null});", :complete => "$('#{dom_id(context)}').unblock();", - :confirm => "Are you sure that you want to delete the context '#{context.name}'?" + :confirm => "Are you sure that you want to delete the context '#{context.name}'?", + :html => { :id => dom_id(context, 'delete') } ) %> <%= link_to_remote( image_tag( "blank.png", :title => "Edit context", :class=>"edit_item"), @@ -34,7 +35,8 @@ :method => 'get', :with => "'_source_view=#{@source_view}'", :before => "$('#{dom_id(context)}').block({message:null});", - :complete => "$('#{dom_id(context)}').unblock();" + :complete => "$('#{dom_id(context)}').unblock();", + :html => { :id => dom_id(context, 'edit') } ) %> diff --git a/features/contexts_manage.feature b/features/contexts_manage.feature index 00ce49fa..9f819215 100644 --- a/features/contexts_manage.feature +++ b/features/contexts_manage.feature @@ -19,3 +19,32 @@ Feature: Manage contexts When I go to the contexts page Then he should see that a context named "Errands" is not present And he should see that a context named "OutAndAbout" is present + + @selenium + Scenario: Delete context from context page + Given I have a context called "@computer" + When I go to the contexts page + Then the badge should show 1 + When I delete the context "@computer" + Then he should see that a context named "@computer" is not present + And the badge should show 0 + + @selenium + Scenario: Delete context from context page right after an edit + Given I have a context called "@computer" + When I go to the contexts page + And I edit the context to rename it to "@laptop" + When I delete the context "@laptop" + Then he should see that a context named "@laptop" is not present + And the badge should show 0 + + @selenium + Scenario: Edit context from context twice + Given I have a context called "@computer" + When I go to the contexts page + And I edit the context to rename it to "@laptop" + And I edit the context to rename it to "@ipad" + Then he should see that a context named "@computer" is not present + And he should see that a context named "@laptop" is not present + And he should see that a context named "@ipad" is present + And the badge should show 1 diff --git a/features/step_definitions/context_steps.rb b/features/step_definitions/context_steps.rb index e8a49491..58813a63 100644 --- a/features/step_definitions/context_steps.rb +++ b/features/step_definitions/context_steps.rb @@ -1,5 +1,5 @@ Given /^I have a context called "([^\"]*)"$/ do |context_name| - @current_user.contexts.create!(:name => context_name) + @context = @current_user.contexts.create!(:name => context_name) end When /^I visits the context page for "([^\"]*)"$/ do |context_name| @@ -24,4 +24,24 @@ end Then /^he should see that a context named "([^\"]*)" is not present$/ do |context_name| Then "I should not see \"#{context_name}\"" -end \ No newline at end of file +end + +Given /^I have a context "([^\"]*)" with (.*) actions$/ do |context_name, number_of_actions| + context = @current_user.contexts.create!(:name => context_name) + 1.upto number_of_actions.to_i do |i| + @current_user.todos.create!(:context_id => context.id, :description => "todo #{i}") + end +end + +When /^I delete the context "([^\"]*)"$/ do |context_name| + context = @current_user.contexts.find_by_name(context_name) + context.should_not be_nil + click_link "delete_context_#{context.id}" + selenium.get_confirmation.should == "Are you sure that you want to delete the context '#{context_name}'?" +end + +When /^I edit the context to rename it to "([^\"]*)"$/ do |new_name| + click_link "edit_context_#{@context.id}" + fill_in "context_name", :with => new_name + click_button "submit_context_#{@context.id}" +end diff --git a/test/selenium/context_listing/delete.rsel b/test/selenium/context_listing/delete.rsel deleted file mode 100644 index e16221fe..00000000 --- a/test/selenium/context_listing/delete.rsel +++ /dev/null @@ -1,6 +0,0 @@ -setup :fixtures => :all -login :as => 'admin' -open "/contexts" -click "css=#context_3 .buttons img.delete_item" -assert_confirmation "Are you sure that you want to delete the context 'email'?" -wait_for_element_not_present "context_3" \ No newline at end of file