fix #1396 and add a test for it

This commit is contained in:
Reinier Balt 2013-02-18 17:14:37 +01:00
parent 28bfbe6f1d
commit fe31eb75a5
3 changed files with 28 additions and 3 deletions

View file

@ -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) {

View file

@ -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

View file

@ -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