diff --git a/features/admin/content_types/has_many.feature b/features/admin/content_types/has_many.feature new file mode 100644 index 00000000..f402373d --- /dev/null +++ b/features/admin/content_types/has_many.feature @@ -0,0 +1,51 @@ +Feature: Create and manage has many relationships + In order to work with two associated models together + As an administrator + I want to set up and manage a has many relationship + +Background: + Given I have the site: "test site" set up + And I have a custom model named "Projects" with + | label | kind | required | target | + | Name | string | true | | + | Description | text | false | | + And I have a custom model named "Clients" with + | label | kind | required | target | + | Name | string | true | | + | Description | string | false | | + | Projects | has_many | false | Projects | + And I have entries for "Clients" with + | name | description | + | Alpha, Inc | Description for Alpha, Inc | + | Beta, Inc | Description for Beta, Inc | + | Gamma, Inc | Description for Gamma, Inc | + And I have entries for "Projects" with + | name | description | + | Fun project | Description for the fun one | + | Boring project | Description for the boring one | + + And I am an authenticated user + +@javascript +Scenario: I view a client without any projects + When I go to the "Clients" model list page + And I follow "Alpha, Inc" + And I wait until ".has-many-selector" is visible + Then I should see "Empty" within the list of items + +@javascript +Scenario: I add a project to a client + When I go to the "Clients" model list page + And I follow "Beta, Inc" + And I wait until ".has-many-selector ul li.template" is visible + Then "Fun project" should be an option for "label" + And I press "+ add" + When I press "Save" + And I wait until ".has-many-selector ul li.template" is visible + Then I should see "Fun project" within the list of added items + And I should not see "Empty" within the list of items + When I go to the "Clients" model list page + And I follow "Beta, Inc" + And I wait until ".has-many-selector ul li.template" is visible + Then I should see "Fun project" within the list of added items + And I should not see "Empty" within the list of items diff --git a/features/support/selectors.rb b/features/support/selectors.rb index d1ae28c5..b57c196c 100644 --- a/features/support/selectors.rb +++ b/features/support/selectors.rb @@ -13,7 +13,13 @@ module HtmlSelectorsHelpers when "the main form" "form.formtastic" - + + when "the list of added items" + ".has-many-selector li.item.added" + + when "the list of items" + ".has-many-selector" + # Add more mappings here. # Here is an example that pulls values out of the Regexp: #