diff --git a/app/views/contexts/create.js.erb b/app/views/contexts/create.js.erb index fead9ed7..fbca6db4 100644 --- a/app/views/contexts/create.js.erb +++ b/app/views/contexts/create.js.erb @@ -9,7 +9,11 @@ <% end -%> function hide_empty_message() { - $('contexts-empty-nd').hide(); +<% if @context.hidden? -%> + $('div#hidden-contexts-empty-nd').hide(); +<% else -%> + $('div#active-contexts-empty-nd').hide(); +<% end -%> } function add_context(state) { diff --git a/features/context_list.feature b/features/context_list.feature index 4190053c..e2afe018 100644 --- a/features/context_list.feature +++ b/features/context_list.feature @@ -62,7 +62,7 @@ Feature: Manage the list of contexts Then I should see that a context named "@ipad" is not present And I should see that the context container for hidden contexts is not present - @javascript + @javascript Scenario: Delete context from context page right after an edit Given I have a context called "@computer" When I go to the contexts page @@ -83,7 +83,7 @@ Feature: Manage the list of contexts And the badge should show 1 @javascript - Scenario Outline: Add a new context with state + Scenario Outline: Showing a new context with state Given I have the following contexts | context | hide | | @ipad | true | @@ -97,6 +97,18 @@ Feature: Manage the list of contexts | active | @phone | | hidden | @hidden | + @javascript + Scenario: Showing a new context with state + When I go to the contexts page + Then I should see empty message for active contexts + And I should see empty message for hidden contexts + When I add a new active context "@active" + Then I should see the context "@active" under "active" + And I should not see empty message for active contexts + When I add a new hidden context "@hidden" + Then I should see the context "@hidden" under "hidden" + And I should not see empty message for hidden contexts + @javascript Scenario: I can drag and drop to order the contexts Given I have the following contexts diff --git a/features/step_definitions/context_list_steps.rb b/features/step_definitions/context_list_steps.rb index e4d63653..399f937c 100644 --- a/features/step_definitions/context_list_steps.rb +++ b/features/step_definitions/context_list_steps.rb @@ -90,3 +90,12 @@ end Then /^the context list badge for ([^"]*) contexts should show (\d+)$/ do |state_name, count| find("span##{state_name}-contexts-count").text.should == count end + +Then /^I should (see|not see) empty message for (active|hidden) contexts$/ do |visible, state| + box = (state=='active') ? "div#active-contexts-empty-nd" : "div#hidden-contexts-empty-nd" + + elem = page.find(box) + elem.should_not be_nil + + elem.send(visible=="see" ? "should" : "should_not", be_visible) +end \ No newline at end of file