refactor tests for contents
This commit is contained in:
parent
187de54962
commit
e560c71ee5
@ -5,7 +5,10 @@ Feature: Editing a content type
|
|||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given I have the site: "test site" set up
|
Given I have the site: "test site" set up
|
||||||
And I have a custom project model
|
And I have a custom model named "Projects" with
|
||||||
|
| label | kind | required |
|
||||||
|
| Name | string | true |
|
||||||
|
| Description | text | false |
|
||||||
And I have a designer and an author
|
And I have a designer and an author
|
||||||
|
|
||||||
Scenario: As an unauthenticated user
|
Scenario: As an unauthenticated user
|
||||||
|
@ -5,7 +5,10 @@ Feature: Pages
|
|||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given I have the site: "test site" set up
|
Given I have the site: "test site" set up
|
||||||
And I have a custom project model
|
And I have a custom model named "Projects" with
|
||||||
|
| label | kind | required |
|
||||||
|
| Name | string | true |
|
||||||
|
| Description | text | false |
|
||||||
And I have a designer and an author
|
And I have a designer and an author
|
||||||
And a page named "hello-world" with the template:
|
And a page named "hello-world" with the template:
|
||||||
"""
|
"""
|
||||||
|
@ -5,9 +5,18 @@ Feature: Manage Contents
|
|||||||
|
|
||||||
Background:
|
Background:
|
||||||
Given I have the site: "test site" set up
|
Given I have the site: "test site" set up
|
||||||
And I have a custom project model
|
And I have a custom model named "Projects" with
|
||||||
|
| label | kind | required |
|
||||||
|
| Name | string | true |
|
||||||
|
| Description | text | false |
|
||||||
|
| Category | category | false |
|
||||||
|
And I have "Design, Development" as "Category" values of the "Projects" model
|
||||||
And I am an authenticated user
|
And I am an authenticated user
|
||||||
And I have a project entry with "My sexy project" as name and "Lorem ipsum" as description
|
And I have entries for "Projects" with
|
||||||
|
| name | description | category |
|
||||||
|
| My sexy project | Lorem ipsum | Development |
|
||||||
|
| Foo project | Lorem ipsum... | Design |
|
||||||
|
| Bar project | Lorem ipsum... | Design |
|
||||||
|
|
||||||
Scenario:
|
Scenario:
|
||||||
When I go to the "Projects" model list page
|
When I go to the "Projects" model list page
|
||||||
@ -51,4 +60,11 @@ Scenario: Destroy an entry
|
|||||||
Then I should see "Content was successfully deleted."
|
Then I should see "Content was successfully deleted."
|
||||||
And I should not see "My sexy project"
|
And I should not see "My sexy project"
|
||||||
|
|
||||||
Scenario: Group entries by category
|
Scenario: Group entries by category
|
||||||
|
When I go to the "Projects" model list page
|
||||||
|
Then I should not see "Development"
|
||||||
|
And I should not see "Design"
|
||||||
|
When I change the presentation of the "Projects" model by grouping items by "Category"
|
||||||
|
And I go to the "Projects" model list page
|
||||||
|
Then I should see "Development"
|
||||||
|
And I should see "Design"
|
@ -1,12 +1,39 @@
|
|||||||
Given /^I have a custom project model/ do
|
Given %r{^I have a custom model named "([^"]*)" with$} do |name, fields|
|
||||||
site = Site.first
|
site = Site.first
|
||||||
@content_type = Factory.build(:content_type, :site => site, :name => 'Projects')
|
content_type = Factory.build(:content_type, :site => site, :name => name)
|
||||||
@content_type.content_custom_fields.build :label => 'Name', :kind => 'string', :required => true
|
fields.hashes.each do |field|
|
||||||
@content_type.content_custom_fields.build :label => 'Description', :kind => 'text'
|
f = content_type.content_custom_fields.build field
|
||||||
@content_type.save.should be_true
|
end
|
||||||
|
content_type.valid?
|
||||||
|
content_type.save.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
Given /^I have a project entry with "(.*)" as name and "(.*)" as description/ do |name, description|
|
Given %r{^I have "([^"]*)" as "([^"]*)" values of the "([^"]*)" model$} do |values, field, name|
|
||||||
@content = @content_type.contents.build :name => name, :description => description
|
content_type = ContentType.where(:name => name).first
|
||||||
@content.save.should be_true
|
field = content_type.content_custom_fields.detect { |f| f.label == field }
|
||||||
|
field.should_not be_nil
|
||||||
|
|
||||||
|
if field.kind == 'category'
|
||||||
|
values.split(',').collect(&:strip).each do |name|
|
||||||
|
field.category_items.build :name => name
|
||||||
|
end
|
||||||
|
content_type.save.should be_true
|
||||||
|
else
|
||||||
|
raise "#{field.kind} field is not supported"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Given %r{^I have entries for "([^"]*)" with$} do |name, entries|
|
||||||
|
content_type = ContentType.where(:name => name).first
|
||||||
|
entries.hashes.each do |entry|
|
||||||
|
content_type.contents.create(entry)
|
||||||
|
end
|
||||||
|
content_type.save.should be_true
|
||||||
|
end
|
||||||
|
|
||||||
|
When %r{^I change the presentation of the "([^"]*)" model by grouping items by "([^"]*)"$} do |name, field|
|
||||||
|
content_type = ContentType.where(:name => name).first
|
||||||
|
field = content_type.content_custom_fields.detect { |f| f.label == field }
|
||||||
|
content_type.group_by_field_name = field._name
|
||||||
|
content_type.save.should be_true
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user