locomotivecms 3.0.0.rc3 → 3.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/README.md +1 -1
- data/app/assets/stylesheets/locomotive/unauthorized/_public.scss +7 -4
- data/app/controllers/locomotive/errors_controller.rb +4 -0
- data/app/helpers/locomotive/errors_helper.rb +2 -4
- data/app/models/locomotive/concerns/content_entry/csv.rb +4 -0
- data/app/models/locomotive/concerns/content_entry/slug.rb +0 -2
- data/app/models/locomotive/concerns/content_type/sync.rb +2 -2
- data/app/models/locomotive/concerns/page/templatized.rb +1 -1
- data/app/models/locomotive/concerns/site/access_points.rb +3 -3
- data/app/models/locomotive/theme_asset.rb +0 -1
- data/app/views/locomotive/developers_documentation/_wagon.html.slim +2 -2
- data/app/views/locomotive/devise_mailer/reset_password_instructions.html.slim +1 -0
- data/app/views/locomotive/errors/no_site.json +1 -0
- data/app/views/locomotive/shared/_sidebar.html.slim +1 -1
- data/app/views/locomotive/shared/_sidebar_without_site.html.slim +1 -1
- data/app/views/locomotive/shared/header/_account_menu.html.slim +2 -2
- data/config/locales/en.yml +1 -1
- data/config/routes.rb +4 -2
- data/lib/generators/locomotive/install/install_generator.rb +9 -9
- data/lib/generators/locomotive/install/templates/carrierwave.rb +23 -12
- data/lib/generators/locomotive/install/templates/carrierwave_aws.rb +36 -0
- data/lib/generators/locomotive/install/templates/mongoid.yml +97 -35
- data/lib/locomotive/dependencies.rb +1 -1
- data/lib/locomotive/middlewares/site.rb +10 -4
- data/lib/locomotive/mongoid/patches.rb +1 -1
- data/lib/locomotive/steam_adaptor.rb +6 -4
- data/lib/locomotive/version.rb +1 -1
- data/spec/dummy/config/application.rb +0 -3
- data/spec/dummy/config/initializers/devise.rb +128 -58
- data/spec/dummy/config/mongoid.yml +95 -78
- data/spec/models/locomotive/content_entry_spec.rb +6 -6
- data/spec/requests/locomotive/steam/cache_spec.rb +1 -1
- data/spec/requests/site_spec.rb +25 -0
- data/spec/support/mongoid.rb +2 -0
- metadata +16 -189
- data/features/api/accounts.feature +0 -43
- data/features/api/authentication.feature +0 -41
- data/features/api/authorization/accounts.feature +0 -165
- data/features/api/authorization/content_assets.feature +0 -147
- data/features/api/authorization/content_entries.feature +0 -202
- data/features/api/authorization/content_types.feature +0 -237
- data/features/api/authorization/current_site.feature +0 -30
- data/features/api/authorization/memberships.feature +0 -225
- data/features/api/authorization/pages.feature +0 -189
- data/features/api/authorization/sites.feature +0 -212
- data/features/api/authorization/snippets.feature +0 -179
- data/features/api/authorization/theme_assets.feature +0 -185
- data/features/api/authorization/translations.feature +0 -253
- data/features/api/content_entries.feature +0 -184
- data/features/api/content_types.feature +0 -156
- data/features/api/editable_elements.feature +0 -190
- data/features/api/entries_custom_fields.feature +0 -150
- data/features/api/memberships.feature +0 -26
- data/features/api/pages.feature +0 -72
- data/features/backoffice/authorization/account_settings.feature +0 -28
- data/features/backoffice/authorization/content_type.feature +0 -35
- data/features/backoffice/authorization/current_site.feature +0 -53
- data/features/backoffice/authorization/inline_front_end_editing.feature +0 -46
- data/features/backoffice/authorization/pages.feature +0 -95
- data/features/backoffice/authorization/theme_assets.feature +0 -50
- data/features/backoffice/content_types/edit.feature +0 -20
- data/features/backoffice/content_types/email.feature +0 -26
- data/features/backoffice/content_types/has_many.feature +0 -80
- data/features/backoffice/content_types/integer.feature +0 -26
- data/features/backoffice/content_types/localized.feature +0 -63
- data/features/backoffice/content_types/many_to_many.feature +0 -70
- data/features/backoffice/content_types/tags.feature +0 -22
- data/features/backoffice/content_types/uniqueness.feature +0 -29
- data/features/backoffice/contents.feature +0 -93
- data/features/backoffice/editable_elements.feature +0 -22
- data/features/backoffice/installation.feature +0 -33
- data/features/backoffice/login.feature +0 -33
- data/features/backoffice/mounting.feature +0 -13
- data/features/backoffice/my_account.feature +0 -22
- data/features/backoffice/pages.feature +0 -73
- data/features/backoffice/regressions.feature +0 -19
- data/features/backoffice/site.feature +0 -71
- data/features/backoffice/snippets.feature +0 -39
- data/features/backoffice/theme_assets.feature +0 -72
- data/features/backoffice/translations.feature +0 -50
- data/features/public/basic.feature +0 -30
- data/features/public/contact_form.feature +0 -98
- data/features/public/content_entries.feature +0 -69
- data/features/public/editable_elements.feature +0 -138
- data/features/public/has_many.feature +0 -8
- data/features/public/inheritance.feature +0 -157
- data/features/public/inline_front_end_editing.feature +0 -26
- data/features/public/many_to_many.feature +0 -64
- data/features/public/new_contact_form.feature +0 -95
- data/features/public/pages.feature +0 -116
- data/features/public/pagination.feature +0 -8
- data/features/public/robots.feature +0 -22
- data/features/public/session.feature +0 -40
- data/features/public/sitemap.feature +0 -74
- data/features/public/snippets.feature +0 -21
- data/features/public/tablerow.feature +0 -42
- data/features/public/tags.feature +0 -45
- data/features/step_definitions/api_steps.rb +0 -179
- data/features/step_definitions/backoffice/mounting_steps.rb +0 -22
- data/features/step_definitions/backoffice_steps.rb +0 -47
- data/features/step_definitions/content_assets_steps.rb +0 -12
- data/features/step_definitions/content_types_steps.rb +0 -135
- data/features/step_definitions/current_site_steps.rb +0 -43
- data/features/step_definitions/editable_elements_steps.rb +0 -24
- data/features/step_definitions/membership_steps.rb +0 -19
- data/features/step_definitions/more_web_steps.rb +0 -131
- data/features/step_definitions/page_steps.rb +0 -133
- data/features/step_definitions/pagination_steps.rb +0 -35
- data/features/step_definitions/pickle_steps.rb +0 -100
- data/features/step_definitions/relationships_steps.rb +0 -110
- data/features/step_definitions/site_steps.rb +0 -111
- data/features/step_definitions/snippet_steps.rb +0 -37
- data/features/step_definitions/theme_asset_steps.rb +0 -64
- data/features/step_definitions/translation_steps.rb +0 -7
- data/features/step_definitions/web_steps.rb +0 -225
- data/features/step_definitions/within_steps.rb +0 -14
- data/features/support/cleaner.rb +0 -4
- data/features/support/env.rb +0 -82
- data/features/support/factory_girl.rb +0 -2
- data/features/support/http.rb +0 -22
- data/features/support/locales.rb +0 -5
- data/features/support/paths.rb +0 -62
- data/features/support/pickle.rb +0 -24
- data/features/support/selectors.rb +0 -57
@@ -1,47 +0,0 @@
|
|
1
|
-
### Authentication
|
2
|
-
|
3
|
-
Given /^I am not authenticated$/ do
|
4
|
-
visit('/locomotive/sign_out')
|
5
|
-
end
|
6
|
-
|
7
|
-
Given /^I am an authenticated "([^"]*)"$/ do |role|
|
8
|
-
@member = Locomotive::Site.first.memberships.where(:role => role.downcase).first || FactoryGirl.create(role.downcase.to_sym, :site => Locomotive::Site.first)
|
9
|
-
|
10
|
-
step %{I go to login}
|
11
|
-
step %{I fill in "Email" with "#{@member.account.email}"}
|
12
|
-
step %{I fill in "Password" with "easyone"}
|
13
|
-
step %{I press "Log in"}
|
14
|
-
end
|
15
|
-
|
16
|
-
Given /^I am an authenticated user$/ do
|
17
|
-
step %{I am an authenticated "admin"}
|
18
|
-
end
|
19
|
-
|
20
|
-
Then /^I should see the access denied message$/ do
|
21
|
-
page.body.include?("You are not authorized to access this page").should be_true
|
22
|
-
end
|
23
|
-
|
24
|
-
Then /^I am redirected to "([^\"]*)"$/ do |url|
|
25
|
-
assert [301, 302].include?(@integration_session.status), "Expected status to be 301 or 302, got #{@integration_session.status}"
|
26
|
-
location = @integration_session.headers["Location"]
|
27
|
-
assert_equal url, location
|
28
|
-
visit location
|
29
|
-
end
|
30
|
-
|
31
|
-
### Cross-domain authentication
|
32
|
-
|
33
|
-
When /^I forget to press the button on the cross-domain notice page$/ do
|
34
|
-
@admin.updated_at = 2.minutes.ago
|
35
|
-
Mongoid::Persistence::Update.new(@admin).send(:update)
|
36
|
-
end
|
37
|
-
|
38
|
-
### Common
|
39
|
-
|
40
|
-
When(/^I change the number of items to display per page to (\d+)$/) do |per_page|
|
41
|
-
Locomotive.config.ui[:per_page] = per_page
|
42
|
-
end
|
43
|
-
|
44
|
-
Then /^I debug$/ do
|
45
|
-
debugger
|
46
|
-
0
|
47
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
|
2
|
-
Given /^I have the following content assets:$/ do |table|
|
3
|
-
site = Locomotive::Site.first
|
4
|
-
table.hashes.each do |asset_hash|
|
5
|
-
asset_hash['site'] = site
|
6
|
-
asset_hash['source'] = FixturedAsset.open(asset_hash['file'])
|
7
|
-
asset_hash.delete('file')
|
8
|
-
|
9
|
-
asset = FactoryGirl.build(:asset, asset_hash)
|
10
|
-
asset.save.should be_true
|
11
|
-
end
|
12
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
def build_content_type(name)
|
2
|
-
site = Locomotive::Site.first
|
3
|
-
FactoryGirl.build(:content_type, site: site, name: name, order_by: '_position')
|
4
|
-
end
|
5
|
-
|
6
|
-
def set_custom_fields_from_table(content_type, fields)
|
7
|
-
fields.hashes.each do |field|
|
8
|
-
# found a belongs_to association
|
9
|
-
if field['type'] == 'belongs_to'
|
10
|
-
target_name = field.delete('target')
|
11
|
-
target_model = @site.content_types.where(name: target_name).first
|
12
|
-
|
13
|
-
field['class_name'] = target_model.entries_class_name
|
14
|
-
end
|
15
|
-
|
16
|
-
content_type.entries_custom_fields.build field
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
Given %r{^I have a custom model named "([^"]*)" with id "([^"]*)" and$} do |name, id, fields|
|
21
|
-
content_type = build_content_type(name)
|
22
|
-
content_type.id = BSON::ObjectId(id)
|
23
|
-
set_custom_fields_from_table(content_type, fields)
|
24
|
-
content_type.valid?
|
25
|
-
content_type.save.should be_true
|
26
|
-
end
|
27
|
-
|
28
|
-
Given(/^the "(.*?)" model was created by another thread$/) do |name|
|
29
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
30
|
-
Locomotive.send(:remove_const, :"ContentEntry#{content_type._id}")
|
31
|
-
"Locomotive::ContentEntry#{content_type._id}".constantize
|
32
|
-
end
|
33
|
-
|
34
|
-
Given %r{^I have a custom model named "([^"]*)" with$} do |name, fields|
|
35
|
-
content_type = build_content_type(name)
|
36
|
-
set_custom_fields_from_table(content_type, fields)
|
37
|
-
content_type.valid?
|
38
|
-
content_type.save.should be_true
|
39
|
-
end
|
40
|
-
|
41
|
-
Given %r{^I have "([^"]*)" as "([^"]*)" values of the "([^"]*)" model$} do |values, field, name|
|
42
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
43
|
-
field = content_type.entries_custom_fields.detect { |f| f.label == field }
|
44
|
-
field.should_not be_nil
|
45
|
-
|
46
|
-
if field.type == 'select'
|
47
|
-
values.split(',').collect(&:strip).each do |name|
|
48
|
-
field.select_options.build name: name
|
49
|
-
end
|
50
|
-
content_type.save.should be_true
|
51
|
-
else
|
52
|
-
raise "#{field.type} field is not supported"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Given %r{^I have entries for "([^"]*)" with$} do |name, entries|
|
57
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
58
|
-
entries.hashes.each do |attributes|
|
59
|
-
entry_id = attributes.delete('id')
|
60
|
-
entry = content_type.entries.build(attributes)
|
61
|
-
entry.id = entry_id if entry_id
|
62
|
-
entry.save!
|
63
|
-
end
|
64
|
-
content_type.save.should be_true
|
65
|
-
end
|
66
|
-
|
67
|
-
When(/^the custom model named "(.*?)" is ordered by "(.*?)"$/) do |name, order_by|
|
68
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
69
|
-
content_type.update_attribute :order_by, order_by
|
70
|
-
end
|
71
|
-
|
72
|
-
#the "client" "Alpha, Inc" has "Fun project" as one of its "projects"
|
73
|
-
Given(/^the "(.*?)" "(.*?)" has "(.*?)" as one of its "(.*?)"$/) do |source, source_label, target_label, target|
|
74
|
-
source_model = Locomotive::ContentType.where(name: source.classify.pluralize).first
|
75
|
-
source_entry = source_model.entries.where(source_model.label_field_name => source_label).first
|
76
|
-
target_model = Locomotive::ContentType.where(name: target.classify.pluralize).first
|
77
|
-
target_entry = target_model.entries.where(target_model.label_field_name => target_label).first
|
78
|
-
|
79
|
-
source_entry.send("#{target}").send("<<", target_entry)
|
80
|
-
end
|
81
|
-
|
82
|
-
When(/^I choose "(.*?)" in the list$/) do |name|
|
83
|
-
within('#content') do
|
84
|
-
click_link(name)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
When(/^I delete the first content entry$/) do
|
89
|
-
within('#content ul.list li:first') do
|
90
|
-
click_link 'Delete'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
Given %r{^I (enable|disable) the public submission of the "([^"]*)" model$} do |action, name|
|
95
|
-
enabled = action == 'enable'
|
96
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
97
|
-
content_type.public_submission_enabled = enabled
|
98
|
-
content_type.public_submission_accounts = enabled ? [Locomotive::Account.first._id] : []
|
99
|
-
content_type.save.should be_true
|
100
|
-
end
|
101
|
-
|
102
|
-
When %r{^I change the presentation of the "([^"]*)" model by grouping items by "([^"]*)"$} do |name, field|
|
103
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
104
|
-
field = content_type.entries_custom_fields.detect { |f| f.label == field }
|
105
|
-
content_type.group_by_field_id = field._id
|
106
|
-
content_type.save.should be_true
|
107
|
-
end
|
108
|
-
|
109
|
-
Then %r{^I should not see (\d+) times the "([^"]*)" field$} do |n, field|
|
110
|
-
page.all(:css, "#content_#{field.underscore.downcase}_input").size.should_not == n.to_i
|
111
|
-
end
|
112
|
-
|
113
|
-
When %r{^I unselect the notified accounts$} do
|
114
|
-
page.evaluate_script "window.application_view.view.model.set({ 'public_submission_accounts': null });"
|
115
|
-
|
116
|
-
click_button 'Save'
|
117
|
-
|
118
|
-
page.find('.notice').visible?
|
119
|
-
end
|
120
|
-
|
121
|
-
Then %r{^there should not be any notified accounts on the "([^"]*)" model$} do |name|
|
122
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
123
|
-
content_type.reload.public_submission_accounts.should eq([])
|
124
|
-
end
|
125
|
-
|
126
|
-
Given(/^I click on the (\d+)[a-z]+ required flag$/) do |nth|
|
127
|
-
find(".custom-field:nth-child(#{nth}) .required-input .switchHandle").click
|
128
|
-
sleep(0.1)
|
129
|
-
end
|
130
|
-
|
131
|
-
Given(/^I have the "(.*?)" entries ordered by the "(.*?)" field$/) do |name, field|
|
132
|
-
content_type = Locomotive::ContentType.where(name: name).first
|
133
|
-
field = content_type.entries_custom_fields.detect { |f| f.label == field }
|
134
|
-
content_type.update_attribute :order_by, field.name
|
135
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
Then /^I should see the role dropdown on the "([^"]*)"$/ do |user|
|
2
|
-
find(:css, "#site_memberships_input div.entry[data-role=#{user}] select").should be_present
|
3
|
-
end
|
4
|
-
|
5
|
-
Then /^I should see the role dropdown on the "([^"]*)" without the "([^"]*)" option$/ do |user, option|
|
6
|
-
find(:css, "#site_memberships_input div.entry[data-role=#{user}] select").text.should_not include option
|
7
|
-
end
|
8
|
-
|
9
|
-
Then /^I should see the role dropdown on myself$/ do
|
10
|
-
step %{I should see the role dropdown on the "#{@member.role}"}
|
11
|
-
end
|
12
|
-
|
13
|
-
Then /^I should not see the role dropdown on the "([^"]*)"$/ do |user|
|
14
|
-
page.has_css?("#site_memberships_input div.entry[data-role=#{user}] select").should be_false
|
15
|
-
end
|
16
|
-
|
17
|
-
Then /^I should not see the role dropdown on myself$/ do
|
18
|
-
step %{I should not see the role dropdown on the "#{@member.role}"}
|
19
|
-
end
|
20
|
-
|
21
|
-
Then /^I should not see any role dropdowns$/ do
|
22
|
-
page.has_css?('#site_memberships_input div.entry select').should be_false
|
23
|
-
end
|
24
|
-
|
25
|
-
Then /^I should see delete on the "([^"]*)"$/ do |role|
|
26
|
-
page.has_css?("#site_memberships_input div.entry[data-role=#{role}] .actions a.remove").should be_true
|
27
|
-
end
|
28
|
-
|
29
|
-
Then /^I should not see delete on the "([^"]*)"$/ do |role|
|
30
|
-
page.has_css?("#site_memberships_input div.entry[data-role=#{role}] .actions a.remove").should be_false
|
31
|
-
end
|
32
|
-
|
33
|
-
Then /^I should not see delete on myself$/ do
|
34
|
-
step %{I should not see delete on the "#{@member.role}"}
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /^I should not see any delete buttons$/ do
|
38
|
-
page.has_css?('#site_memberships_input div.entry .actions a.remove').should be_false
|
39
|
-
end
|
40
|
-
|
41
|
-
When /^I select the "([^"]*)" role for the "author" user/ do |role|
|
42
|
-
step %{I select "#{role}" from "site[memberships_attributes][2][role]"}
|
43
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# modify an editable element
|
2
|
-
Given /^the editable element "([^"]*)" in the "([^"]*)" page with the content "([^"]*)"$/ do |slug, page_slug, content|
|
3
|
-
page = @site.pages.where(:slug => page_slug).first
|
4
|
-
page.find_editable_element(nil, slug).content = content
|
5
|
-
page.save!
|
6
|
-
end
|
7
|
-
|
8
|
-
# modify an editable element
|
9
|
-
Given /^the editable element "([^"]*)" for the "([^"]*)" block in the "([^"]*)" page with the content "([^"]*)"$/ do |slug, block, page_slug, content|
|
10
|
-
page = @site.pages.where(:slug => page_slug).first
|
11
|
-
page.find_editable_element(block, slug).content = content
|
12
|
-
page.save!
|
13
|
-
end
|
14
|
-
|
15
|
-
When /^I type the content "([^"]*)" into the first editable field$/ do |content|
|
16
|
-
page.execute_script %{
|
17
|
-
$(document).ready(function() {
|
18
|
-
editable = GENTICS.Aloha.editables[0];
|
19
|
-
editable.obj.text('#{content}');
|
20
|
-
editable.blur();
|
21
|
-
});
|
22
|
-
}
|
23
|
-
end
|
24
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
Given /^I have accounts:$/ do |accounts_table|
|
3
|
-
accounts_table.hashes.each do |account_hash|
|
4
|
-
FactoryGirl.create(:account, account_hash)
|
5
|
-
end
|
6
|
-
end
|
7
|
-
|
8
|
-
Given /^I have memberships:$/ do |members_table|
|
9
|
-
members_table.hashes.each do |member_hash|
|
10
|
-
email = member_hash[:email]
|
11
|
-
account = Locomotive::Account.where(:email => email).first \
|
12
|
-
|| FactoryGirl.create(:account, :email => email)
|
13
|
-
|
14
|
-
member_hash.delete(:email)
|
15
|
-
member_hash.merge!({ :account => account, :site => @site })
|
16
|
-
|
17
|
-
FactoryGirl.create(:membership, member_hash)
|
18
|
-
end
|
19
|
-
end
|
@@ -1,131 +0,0 @@
|
|
1
|
-
When(/^the locale of the current ruby thread changes to "(.*?)"$/) do |locale|
|
2
|
-
::I18n.locale = ::Mongoid::Fields::I18n.locale = 'fr'
|
3
|
-
end
|
4
|
-
|
5
|
-
When /^I follow image link "([^"]*)"$/ do |img_alt|
|
6
|
-
find(:xpath, "//img[@alt = '#{img_alt}']/parent::a").click()
|
7
|
-
end
|
8
|
-
|
9
|
-
When /^I click on the "([^"]*)" folder$/ do |name|
|
10
|
-
find('fieldset.foldable legend span', text: name).click
|
11
|
-
end
|
12
|
-
|
13
|
-
Then /^I should get a download with the filename "([^\"]*)"$/ do |filename|
|
14
|
-
page.response_headers['Content-Disposition'].should include("filename=#{filename}")
|
15
|
-
end
|
16
|
-
|
17
|
-
When /^I wait until "([^"]*)" is visible$/ do |selector|
|
18
|
-
page.has_css?("#{selector}", visible: true)
|
19
|
-
end
|
20
|
-
|
21
|
-
When /^I wait until ([^"]*) is visible$/ do |locator|
|
22
|
-
page.has_css?(selector_for(locator), visible: true)
|
23
|
-
end
|
24
|
-
|
25
|
-
When /^I sync my form with my backbone model because of Firefox$/ do
|
26
|
-
page.execute_script("$(':input').trigger('change')")
|
27
|
-
end
|
28
|
-
|
29
|
-
When /^I fill in "(.*?)" with the tags "(.*?)"$/ do |field, tags|
|
30
|
-
input = field_labeled(field)
|
31
|
-
tags.split(',').each do |tag|
|
32
|
-
_tag = tag.strip
|
33
|
-
page.execute_script("$('input[name=\"#{input[:name]}\"]').tagit('createTag', '#{_tag}')")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
Then /^"([^"]*)" should not be visible$/ do |text|
|
38
|
-
begin
|
39
|
-
assert page.find(text).visible? != true
|
40
|
-
rescue Capybara::ElementNotFound
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
Then(/^I should see "(.*?)" in the html code$/) do |content|
|
45
|
-
page.body.include?(content).should be_true
|
46
|
-
end
|
47
|
-
|
48
|
-
Then(/^I should not see "(.*?)" in the html code$/) do |content|
|
49
|
-
page.body.include?(content).should be_false
|
50
|
-
end
|
51
|
-
|
52
|
-
Then /^"([^"]*)" should( not)? be an option for "([^"]*)"(?: within "([^\"]*)")?$/ do |value, negate, field, selector|
|
53
|
-
with_scope(selector) do
|
54
|
-
expectation = negate ? :should_not : :should
|
55
|
-
field_labeled(field).first(:xpath, ".//option[text() = '#{value}']").send(expectation, be_present)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
Then /^"([^"]*)" should be selected for "([^"]*)"$/ do |value, field|
|
60
|
-
assert page.has_xpath?("//select[@name='#{field}' and option[@selected and contains(text(), '#{value}')]]")
|
61
|
-
end
|
62
|
-
|
63
|
-
When /^I reload the page$/ do
|
64
|
-
visit current_path
|
65
|
-
end
|
66
|
-
|
67
|
-
When(/^I switch the locale to "(.*?)"$/) do |locale|
|
68
|
-
click_on 'content-locale-picker-link'
|
69
|
-
within '#content-locale-picker' do
|
70
|
-
find("[data-locale='#{locale}']").click
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
Then(/^I should see a "(.*?)" link to "(.*?)"$/) do |text, path|
|
75
|
-
page.should have_link(text, href: path)
|
76
|
-
end
|
77
|
-
|
78
|
-
Given /^I enable the CSRF protection for public submission requests$/ do
|
79
|
-
Locomotive.config.csrf_protection = true
|
80
|
-
Locomotive::Public::ContentEntriesController.any_instance.stubs(:protect_against_forgery?).returns(true)
|
81
|
-
end
|
82
|
-
|
83
|
-
Given /^I disable the CSRF protection for public submission requests$/ do
|
84
|
-
Locomotive.config.csrf_protection = false
|
85
|
-
# pending # express the regexp above with the code you wish you had
|
86
|
-
end
|
87
|
-
|
88
|
-
Then /^the response status should be (\d+)$/ do |status|
|
89
|
-
page.status_code.should == status.to_i
|
90
|
-
end
|
91
|
-
|
92
|
-
Then /^it returns a (\d+) error page$/ do |code|
|
93
|
-
page.status_code.should == code.to_i
|
94
|
-
end
|
95
|
-
|
96
|
-
Then /^I should see the following xml output:$/ do |xml_output|
|
97
|
-
xml_output.gsub!(':now', Time.now.utc.to_date.to_s)
|
98
|
-
response = Hash.from_xml(page.source)
|
99
|
-
expected = Hash.from_xml(xml_output)
|
100
|
-
expected.diff(response).should == {}
|
101
|
-
end
|
102
|
-
|
103
|
-
When /^I take a screenshot$/ do
|
104
|
-
page.save_screenshot('/Users/didier/Desktop/cucumber.png', full: true)
|
105
|
-
end
|
106
|
-
|
107
|
-
def wait_for_ajax(&block)
|
108
|
-
start_time = Time.now
|
109
|
-
while Time.now < start_time + Capybara.default_wait_time
|
110
|
-
begin
|
111
|
-
block.call
|
112
|
-
break
|
113
|
-
rescue RSpec::Expectations::ExpectationNotMetError => e
|
114
|
-
raise e
|
115
|
-
rescue
|
116
|
-
# Try again
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
Then /^after the AJAX finishes, (.*)$/ do |*args|
|
122
|
-
step_str = args[0]
|
123
|
-
step_arg = args[1]
|
124
|
-
wait_for_ajax do
|
125
|
-
step(step_str, step_arg)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
When(/^I wait (\d+)ms$/) do |delay|
|
130
|
-
sleep(delay.to_i / 1000.0)
|
131
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
### Pages
|
2
|
-
|
3
|
-
# helps create a simple content page (parent: "index") with a slug and template
|
4
|
-
def create_content_page(slug, template = nil)
|
5
|
-
new_content_page(slug, template).tap do |page|
|
6
|
-
page.save!.should be_true
|
7
|
-
end
|
8
|
-
# page = new_content_page(slug, page_contents, template)
|
9
|
-
# raise "Invalid page: #{page.errors.full_messages}" unless page.valid?
|
10
|
-
# page.should be_valid
|
11
|
-
# page.save!
|
12
|
-
# page
|
13
|
-
end
|
14
|
-
|
15
|
-
# build page without saving
|
16
|
-
def new_content_page(slug, template = nil)
|
17
|
-
@home = @site.pages.where(slug: 'index').first || FactoryGirl.create(:page)
|
18
|
-
title = slug.gsub(/-/, '_').humanize
|
19
|
-
@site.pages.new(title: title, slug: slug, parent: @home, published: true, raw_template: template)
|
20
|
-
end
|
21
|
-
|
22
|
-
# creates a page
|
23
|
-
# Given /^a simple page named "([^"]*)" with the body:$/ do |page_slug, page_contents|
|
24
|
-
# @page = create_content_page(page_slug, page_contents)
|
25
|
-
# end
|
26
|
-
|
27
|
-
Given /^a page named "([^"]*)" with the template:$/ do |slug, template|
|
28
|
-
@page = create_content_page(slug, template)
|
29
|
-
end
|
30
|
-
|
31
|
-
Given /^a page named "([^"]*)" with id "([^"]*)"$/ do |slug, id|
|
32
|
-
@page = new_content_page(slug, '')
|
33
|
-
@page.id = BSON::ObjectId(id)
|
34
|
-
@page.save!
|
35
|
-
end
|
36
|
-
|
37
|
-
Given /^a page named "([^"]*)" with id "([^"]*)" and template:$/ do |slug, id, template|
|
38
|
-
@page = new_content_page(slug, template)
|
39
|
-
@page.id = BSON::ObjectId(id)
|
40
|
-
@page.save!
|
41
|
-
end
|
42
|
-
|
43
|
-
Given(/^a page named "(.*?)" with the handle "(.*?)"$/) do |slug, handle|
|
44
|
-
page = new_content_page(slug, '')
|
45
|
-
page.handle = handle
|
46
|
-
page.save!
|
47
|
-
end
|
48
|
-
|
49
|
-
Given(/^the page named "(.*?)" has the title "(.*?)" in the "(.*?)" locale$/) do |slug, title, locale|
|
50
|
-
page = @site.pages.where(slug: slug).first
|
51
|
-
::Mongoid::Fields::I18n.with_locale(locale) do
|
52
|
-
page.update_attributes!(title: title, slug: title.permalink)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
Given /^a templatized page for the "(.*?)" model and with the template:$/ do |model_name, template|
|
57
|
-
content_type = Locomotive::ContentType.where(name: model_name).first
|
58
|
-
parent = create_content_page(content_type.slug, '')
|
59
|
-
@page = @site.pages.new(parent: parent, title: "Template for #{model_name}", published: true,
|
60
|
-
templatized: true, target_klass_name: content_type.entries_class_name,
|
61
|
-
raw_template: template)
|
62
|
-
@page.save!
|
63
|
-
end
|
64
|
-
|
65
|
-
# change the title
|
66
|
-
When /^I change the page title to "([^"]*)"$/ do |title|
|
67
|
-
page.evaluate_script "window.prompt = function() { return '#{title}'; }"
|
68
|
-
page.find('h2 a.editable').click
|
69
|
-
end
|
70
|
-
|
71
|
-
# change the template
|
72
|
-
When /^I change the page template to "([^"]*)"$/ do |template|
|
73
|
-
page.evaluate_script "window.application_view.view.model.set({ 'raw_template': '#{template}' })"
|
74
|
-
end
|
75
|
-
|
76
|
-
# update a page
|
77
|
-
When /^I update the "([^"]*)" page with the template:$/ do |slug, template|
|
78
|
-
page = @site.pages.where(slug: slug).first
|
79
|
-
page.raw_template = template
|
80
|
-
page.save!
|
81
|
-
end
|
82
|
-
|
83
|
-
Given /^I delete the following code "([^"]*)" from the "([^"]*)" page$/ do |code, slug|
|
84
|
-
page = @site.pages.where(slug: slug).first
|
85
|
-
page.raw_template = page.raw_template.gsub(code, '')
|
86
|
-
page.save!
|
87
|
-
end
|
88
|
-
|
89
|
-
Given(/^the page "(.*?)" is unpublished$/) do |slug|
|
90
|
-
page = @site.pages.where(slug: slug).first
|
91
|
-
page.published = false
|
92
|
-
page.save!
|
93
|
-
end
|
94
|
-
|
95
|
-
|
96
|
-
# try to render a page by slug
|
97
|
-
When /^I view the rendered page at "([^"]*)"$/ do |path|
|
98
|
-
# If we're running poltergeist then we need to use a different port
|
99
|
-
if Capybara.current_driver == :poltergeist
|
100
|
-
visit "http://#{@site.domains.first}:#{Capybara.server_port}#{path}"
|
101
|
-
else
|
102
|
-
visit "http://#{@site.domains.first}#{path}"
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
# checks to see if a string is in the slug
|
107
|
-
Then /^I should have "(.*)" in the (.*) page$/ do |content, slug|
|
108
|
-
page = @site.pages.where(slug: slug).first
|
109
|
-
raise "Could not find page: #{slug}" unless page
|
110
|
-
page.raw_template.should == content
|
111
|
-
end
|
112
|
-
|
113
|
-
# checks if the rendered body matches a string
|
114
|
-
Then /^the rendered output should look like:$/ do |body_contents|
|
115
|
-
# page.source.should == body_contents
|
116
|
-
page.source.index(body_contents).should_not be_nil
|
117
|
-
end
|
118
|
-
|
119
|
-
Then /^I should see delete page buttons$/ do
|
120
|
-
page.has_css?("ul#pages-list li .more a.remove").should be_true
|
121
|
-
end
|
122
|
-
|
123
|
-
Then /^I should not see delete page buttons$/ do
|
124
|
-
page.has_css?("ul#pages-list li .more a.remove").should be_false
|
125
|
-
end
|
126
|
-
|
127
|
-
Then /^updated_at of the (.*) page should respect site's timezone$/ do |slug|
|
128
|
-
edited_page = @site.pages.where(slug: slug).first
|
129
|
-
t = edited_page.updated_at.in_time_zone(@site.timezone)
|
130
|
-
page.source.should =~ /#{t.strftime('%-d %b %H:%M')}/
|
131
|
-
end
|
132
|
-
|
133
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
Then /^I should be able to display paginated models$/ do
|
2
|
-
# Create our article model and three articles
|
3
|
-
@article_model = FactoryGirl.build(:content_type, site: @site, name: 'Articles', order_by: '_position').tap do |ct|
|
4
|
-
ct.entries_custom_fields.build label: 'Body', type: 'string', required: false
|
5
|
-
ct.save!
|
6
|
-
end
|
7
|
-
|
8
|
-
%w(First Second Third).each do |body|
|
9
|
-
@article_model.entries.create!(body: body)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Create a page with template
|
13
|
-
raw_template = %{
|
14
|
-
{% paginate contents.articles by 2 %}
|
15
|
-
{% for article in paginate.collection %}
|
16
|
-
{{ article.body }}
|
17
|
-
{% endfor %}
|
18
|
-
{{ paginate | default_pagination }}
|
19
|
-
{% endpaginate %}
|
20
|
-
}
|
21
|
-
FactoryGirl.create(:page, site: @site, slug: 'hello', parent: @site.pages.root.first, raw_template: raw_template)
|
22
|
-
|
23
|
-
# The page should have the first two articles
|
24
|
-
visit '/hello'
|
25
|
-
page.should have_content 'First'
|
26
|
-
page.should have_content 'Second'
|
27
|
-
page.should_not have_content 'Third'
|
28
|
-
|
29
|
-
# The second page should have the last article
|
30
|
-
click_link '2'
|
31
|
-
page.should_not have_content 'First'
|
32
|
-
page.should_not have_content 'Second'
|
33
|
-
page.should have_content 'Third'
|
34
|
-
end
|
35
|
-
|
@@ -1,100 +0,0 @@
|
|
1
|
-
# this file generated by script/generate pickle
|
2
|
-
|
3
|
-
# create a model
|
4
|
-
Given(/^#{capture_model} exists?(?: with #{capture_fields})?$/) do |name, fields|
|
5
|
-
create_model(name, fields)
|
6
|
-
end
|
7
|
-
|
8
|
-
# create n models
|
9
|
-
Given(/^(\d+) #{capture_plural_factory} exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
10
|
-
count.to_i.times { create_model(plural_factory.singularize, fields) }
|
11
|
-
end
|
12
|
-
|
13
|
-
# create models from a table
|
14
|
-
Given(/^the following #{capture_plural_factory} exists?:?$/) do |plural_factory, table|
|
15
|
-
create_models_from_table(plural_factory, table)
|
16
|
-
end
|
17
|
-
|
18
|
-
# find a model
|
19
|
-
Then(/^#{capture_model} should exist(?: with #{capture_fields})?$/) do |name, fields|
|
20
|
-
find_model!(name, fields)
|
21
|
-
end
|
22
|
-
|
23
|
-
# not find a model
|
24
|
-
Then(/^#{capture_model} should not exist(?: with #{capture_fields})?$/) do |name, fields|
|
25
|
-
find_model(name, fields).should be_nil
|
26
|
-
end
|
27
|
-
|
28
|
-
# find models with a table
|
29
|
-
Then(/^the following #{capture_plural_factory} should exists?:?$/) do |plural_factory, table|
|
30
|
-
find_models_from_table(plural_factory, table).should_not be_any(&:nil?)
|
31
|
-
end
|
32
|
-
|
33
|
-
# find exactly n models
|
34
|
-
Then(/^(\d+) #{capture_plural_factory} should exist(?: with #{capture_fields})?$/) do |count, plural_factory, fields|
|
35
|
-
find_models(plural_factory.singularize, fields).size.should == count.to_i
|
36
|
-
end
|
37
|
-
|
38
|
-
# assert equality of models
|
39
|
-
Then(/^#{capture_model} should be #{capture_model}$/) do |a, b|
|
40
|
-
model!(a).should == model!(b)
|
41
|
-
end
|
42
|
-
|
43
|
-
# assert model is in another model's has_many assoc
|
44
|
-
Then(/^#{capture_model} should be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
45
|
-
model!(owner).send(association).should include(model!(target))
|
46
|
-
end
|
47
|
-
|
48
|
-
# assert model is not in another model's has_many assoc
|
49
|
-
Then(/^#{capture_model} should not be (?:in|one of|amongst) #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
50
|
-
model!(owner).send(association).should_not include(model!(target))
|
51
|
-
end
|
52
|
-
|
53
|
-
# assert model is another model's has_one/belongs_to assoc
|
54
|
-
Then(/^#{capture_model} should be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
55
|
-
model!(owner).send(association).should == model!(target)
|
56
|
-
end
|
57
|
-
|
58
|
-
# assert model is not another model's has_one/belongs_to assoc
|
59
|
-
Then(/^#{capture_model} should not be #{capture_model}(?:'s)? (\w+)$/) do |target, owner, association|
|
60
|
-
model!(owner).send(association).should_not == model!(target)
|
61
|
-
end
|
62
|
-
|
63
|
-
# assert model.predicate?
|
64
|
-
Then(/^#{capture_model} should (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
65
|
-
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
66
|
-
model!(name).should send("have_#{predicate.gsub(' ', '_')}")
|
67
|
-
else
|
68
|
-
model!(name).should send("be_#{predicate.gsub(' ', '_')}")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
# assert not model.predicate?
|
73
|
-
Then(/^#{capture_model} should not (?:be|have) (?:an? )?#{capture_predicate}$/) do |name, predicate|
|
74
|
-
if model!(name).respond_to?("has_#{predicate.gsub(' ', '_')}")
|
75
|
-
model!(name).should_not send("have_#{predicate.gsub(' ', '_')}")
|
76
|
-
else
|
77
|
-
model!(name).should_not send("be_#{predicate.gsub(' ', '_')}")
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# model.attribute.should eql(value)
|
82
|
-
# model.attribute.should_not eql(value)
|
83
|
-
Then(/^#{capture_model}'s (\w+) (should(?: not)?) be #{capture_value}$/) do |name, attribute, expectation, expected|
|
84
|
-
actual_value = model(name).send(attribute)
|
85
|
-
expectation = expectation.gsub(' ', '_')
|
86
|
-
|
87
|
-
case expected
|
88
|
-
when 'nil', 'true', 'false'
|
89
|
-
actual_value.send(expectation, send("be_#{expected}"))
|
90
|
-
when /^[+-]?[0-9_]+(\.\d+)?$/
|
91
|
-
actual_value.send(expectation, eql(expected.to_f))
|
92
|
-
else
|
93
|
-
actual_value.to_s.send(expectation, eql(eval(expected)))
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# assert size of association
|
98
|
-
Then /^#{capture_model} should have (\d+) (\w+)$/ do |name, size, association|
|
99
|
-
model!(name).send(association).size.should == size.to_i
|
100
|
-
end
|