landable 1.13.1 → 1.13.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rubocop.yml +281 -0
- data/.travis.yml +0 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +3 -4
- data/README.md +2 -0
- data/Rakefile +6 -3
- data/app/controllers/concerns/landable/variables_concern.rb +9 -9
- data/app/controllers/landable/api/access_tokens_controller.rb +7 -8
- data/app/controllers/landable/api/assets_controller.rb +29 -26
- data/app/controllers/landable/api/audits_controller.rb +6 -5
- data/app/controllers/landable/api/configurations_controller.rb +1 -1
- data/app/controllers/landable/api/directories_controller.rb +2 -2
- data/app/controllers/landable/api/page_revisions_controller.rb +2 -4
- data/app/controllers/landable/api/pages_controller.rb +39 -40
- data/app/controllers/landable/api/template_revisions_controller.rb +1 -2
- data/app/controllers/landable/api/templates_controller.rb +15 -14
- data/app/controllers/landable/api/themes_controller.rb +15 -14
- data/app/controllers/landable/api_controller.rb +10 -11
- data/app/controllers/landable/public/pages_controller.rb +2 -2
- data/app/controllers/landable/public/preview/page_revisions_controller.rb +2 -2
- data/app/controllers/landable/public/preview/pages_controller.rb +1 -1
- data/app/controllers/landable/public/sitemap_controller.rb +2 -2
- data/app/decorators/landable/page_decorator.rb +3 -3
- data/app/helpers/landable/pages_helper.rb +2 -2
- data/app/helpers/landable/traffic_helper.rb +2 -4
- data/app/models/concerns/landable/has_assets.rb +6 -9
- data/app/models/concerns/landable/has_templates.rb +6 -7
- data/app/models/concerns/landable/librarian.rb +5 -5
- data/app/models/concerns/landable/table_name.rb +2 -2
- data/app/models/landable/access_token.rb +1 -1
- data/app/models/landable/asset.rb +8 -8
- data/app/models/landable/asset_search_engine.rb +7 -8
- data/app/models/landable/author.rb +2 -1
- data/app/models/landable/category.rb +1 -3
- data/app/models/landable/directory.rb +2 -2
- data/app/models/landable/page.rb +44 -50
- data/app/models/landable/page_revision.rb +27 -41
- data/app/models/landable/page_search_engine.rb +5 -6
- data/app/models/landable/search_engine.rb +2 -2
- data/app/models/landable/template.rb +9 -11
- data/app/models/landable/template_revision.rb +4 -14
- data/app/models/landable/theme.rb +1 -1
- data/app/models/landable/traffic/attribution.rb +3 -1
- data/app/models/landable/traffic/page_view.rb +1 -1
- data/app/models/landable/traffic/user_agent.rb +1 -1
- data/app/models/landable/traffic/visit.rb +1 -1
- data/app/responders/landable/api_responder.rb +5 -3
- data/app/responders/landable/page_render_responder.rb +1 -1
- data/app/serializers/landable/asset_serializer.rb +1 -1
- data/app/serializers/landable/audit_serializer.rb +2 -3
- data/app/serializers/landable/directory_serializer.rb +2 -2
- data/app/serializers/landable/page_revision_serializer.rb +0 -1
- data/app/serializers/landable/page_serializer.rb +5 -5
- data/app/serializers/landable/template_serializer.rb +2 -2
- data/app/services/landable/authentication_service.rb +1 -1
- data/app/services/landable/registration_service.rb +3 -2
- data/app/services/landable/render_service.rb +16 -18
- data/app/services/landable/screenshot_service.rb +3 -4
- data/app/services/landable/tidy_service.rb +32 -37
- data/app/validators/path_validator.rb +1 -3
- data/app/validators/url_validator.rb +4 -7
- data/config/routes.rb +3 -6
- data/db/migrate/20130510221424_create_landable_schema.rb +45 -56
- data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +2 -2
- data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +9 -12
- data/db/migrate/20131002220041_file_based_themes.rb +3 -3
- data/db/migrate/20131008164204_create_head_tag_on_page.rb +4 -4
- data/db/migrate/20131008193544_drop_status_codes_model.rb +1 -2
- data/db/migrate/20131028145652_add_traffic_schema.rb +5 -5
- data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +1 -1
- data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +1 -1
- data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +1 -1
- data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +2 -2
- data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +3 -3
- data/db/migrate/20140128170659_file_backed_templates.rb +1 -1
- data/db/migrate/20140205193757_fix_status_codes.rb +3 -3
- data/db/migrate/20140220170324_add_slug_to_categories.rb +1 -1
- data/db/migrate/20140224205516_rename_traffic_schema.rb +7 -9
- data/db/migrate/20140509190128_create_template_revisions.rb +13 -15
- data/db/migrate/20140509192856_create_audits.rb +3 -3
- data/db/migrate/20140602213937_path_response_time_view.rb +20 -19
- data/features/step_definitions/asset_steps.rb +10 -12
- data/features/step_definitions/core_api_steps.rb +29 -27
- data/features/step_definitions/factory_steps.rb +16 -16
- data/features/step_definitions/html_steps.rb +1 -1
- data/features/step_definitions/liquid_steps.rb +8 -8
- data/features/step_definitions/theme_steps.rb +4 -4
- data/features/support/env.rb +5 -5
- data/landable.gemspec +2 -2
- data/lib/generators/landable/landable_generator.rb +2 -2
- data/lib/generators/templates/landable.rb +1 -1
- data/lib/landable.rb +7 -7
- data/lib/landable/configuration.rb +10 -19
- data/lib/landable/engine.rb +19 -19
- data/lib/landable/error.rb +1 -3
- data/lib/landable/layout.rb +6 -6
- data/lib/landable/liquid/asset_tags.rb +3 -5
- data/lib/landable/liquid/drops.rb +3 -8
- data/lib/landable/liquid/filters.rb +1 -3
- data/lib/landable/liquid/tags.rb +10 -10
- data/lib/landable/migration.rb +30 -30
- data/lib/landable/mime_types.rb +1 -1
- data/lib/landable/partial.rb +2 -2
- data/lib/landable/seeds.rb +3 -4
- data/lib/landable/traffic.rb +4 -8
- data/lib/landable/traffic/tracker.rb +48 -43
- data/lib/landable/traffic/user_tracker.rb +15 -10
- data/lib/landable/version.rb +1 -1
- data/lib/schema_moves.rb +15 -16
- data/lib/tasks/landable/cucumber.rake +46 -47
- data/lib/tasks/landable/data.rake +13 -14
- data/lib/tasks/landable/pgtap.rake +12 -18
- data/lib/tasks/landable/seed.rake +4 -4
- data/spec/concerns/landable/has_assets_spec.rb +15 -19
- data/spec/concerns/landable/has_templates_spec.rb +10 -13
- data/spec/concerns/landable/librarian.rb +4 -4
- data/spec/concerns/landable/table_name_spec.rb +3 -5
- data/spec/concerns/landable/traffic/table_name_spec.rb +2 -4
- data/spec/controllers/concerns/landable/variables_concern_spec.rb +11 -10
- data/spec/controllers/landable/api/assets_controller_spec.rb +15 -14
- data/spec/controllers/landable/api/audits_controller_spec.rb +104 -102
- data/spec/controllers/landable/api/categories_controller_spec.rb +36 -34
- data/spec/controllers/landable/api/configuration_controller_spec.rb +14 -12
- data/spec/controllers/landable/api/directories_controller_spec.rb +52 -50
- data/spec/controllers/landable/api/page_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/pages_controller_spec.rb +204 -203
- data/spec/controllers/landable/api/template_revisions_controller_spec.rb +20 -18
- data/spec/controllers/landable/api/templates_controller_spec.rb +39 -37
- data/spec/controllers/landable/api_controller_spec.rb +24 -26
- data/spec/controllers/public/preview/page_revisions_controller_spec.rb +36 -34
- data/spec/controllers/public/preview/pages_controller_spec.rb +32 -30
- data/spec/controllers/public/sitemap_controller_spec.rb +19 -17
- data/spec/decorators/page_decorator_spec.rb +9 -9
- data/spec/dummy/app/helpers/application_helper.rb +1 -1
- data/spec/dummy/config/application.rb +5 -6
- data/spec/dummy/config/boot.rb +1 -1
- data/spec/dummy/config/environments/test.rb +1 -1
- data/spec/dummy/config/initializers/landable.rb +7 -6
- data/spec/factories/asset.rb +1 -1
- data/spec/factories/audit.rb +1 -1
- data/spec/factories/authors.rb +1 -1
- data/spec/factories/category.rb +1 -1
- data/spec/factories/pages.rb +4 -4
- data/spec/factories/template.rb +3 -3
- data/spec/factories/theme.rb +2 -2
- data/spec/helpers/pages_helper_spec.rb +5 -5
- data/spec/lib/landable/configuration_spec.rb +2 -4
- data/spec/lib/landable/event_publisher_spec.rb +1 -3
- data/spec/lib/landable/layout_spec.rb +4 -4
- data/spec/lib/landable/liquid_spec.rb +12 -14
- data/spec/lib/landable/migration_spec.rb +4 -4
- data/spec/lib/landable/partial_spec.rb +18 -18
- data/spec/lib/landable/tracking_spec.rb +27 -29
- data/spec/lib/landable/traffic_spec.rb +29 -33
- data/spec/models/landable/access_token_spec.rb +1 -1
- data/spec/models/landable/asset_spec.rb +9 -11
- data/spec/models/landable/directory_spec.rb +7 -7
- data/spec/models/landable/page/errors_spec.rb +1 -3
- data/spec/models/landable/page_revision_spec.rb +23 -24
- data/spec/models/landable/page_spec.rb +41 -42
- data/spec/models/landable/template_revision_spec.rb +3 -3
- data/spec/models/landable/template_spec.rb +11 -11
- data/spec/models/landable/theme_spec.rb +2 -2
- data/spec/models/landable/traffic/referer_spec.rb +3 -3
- data/spec/responders/page_render_responder_spec.rb +0 -2
- data/spec/routing/public_page_route_spec.rb +4 -5
- data/spec/services/landable/authentication_service_spec.rb +7 -7
- data/spec/services/landable/render_service_spec.rb +8 -8
- data/spec/services/landable/screenshot_service_spec.rb +3 -3
- data/spec/services/landable/tidy_service_spec.rb +20 -20
- data/spec/spec_helper.rb +3 -3
- data/spec/support/behaviors.rb +4 -4
- data/spec/support/helpers.rb +1 -1
- metadata +86 -35
- checksums.yaml +0 -7
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module Landable
|
4
4
|
describe Page do
|
5
5
|
it { should be_a HasAssets }
|
6
|
-
it { should_not have_valid(:status_code).when(nil,'') }
|
6
|
+
it { should_not have_valid(:status_code).when(nil, '') }
|
7
7
|
it { should have_valid(:status_code).when(200, 301, 302, 410) }
|
8
8
|
it { should_not have_valid(:status_code).when(201, 303, 405, 500, 404) }
|
9
9
|
|
@@ -14,7 +14,7 @@ module Landable
|
|
14
14
|
context 'PathValidator' do
|
15
15
|
it { should_not have_valid(:path).when(nil, '', '/reserved_path_set_in_initializer') }
|
16
16
|
it { should_not have_valid(:path).when('/reject/this', '/admin', '/ADMIN', '/admin_something' '/admin/path') }
|
17
|
-
it { should
|
17
|
+
it { should have_valid(:path).when('/reserved_path_set_in_initializer_not', '/do/not/reject/path', '/', '/rejectwhatever', '/reject') }
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should set is_publishable to true on before_save' do
|
@@ -23,9 +23,9 @@ module Landable
|
|
23
23
|
page.is_publishable.should be_true
|
24
24
|
end
|
25
25
|
|
26
|
-
specify
|
26
|
+
specify '#redirect?' do
|
27
|
+
Page.new.should_not be_redirect
|
27
28
|
Page.new.should_not be_redirect
|
28
|
-
Page.new().should_not be_redirect
|
29
29
|
Page.new(status_code: 200).should_not be_redirect
|
30
30
|
Page.new(status_code: 410).should_not be_redirect
|
31
31
|
|
@@ -52,33 +52,33 @@ module Landable
|
|
52
52
|
|
53
53
|
specify '#path_extension' do
|
54
54
|
Page.new(path: 'foo').path_extension.should be_nil
|
55
|
-
Page.new(path: 'foo.bar').path_extension.should
|
56
|
-
Page.new(path: 'foo.bar.baz').path_extension.should
|
55
|
+
Page.new(path: 'foo.bar').path_extension.should eq 'bar'
|
56
|
+
Page.new(path: 'foo.bar.baz').path_extension.should eq 'baz'
|
57
57
|
Page.new(path: 'foo.bar-baz').path_extension.should be_nil
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#content_type' do
|
61
|
-
def content_type_for
|
61
|
+
def content_type_for(path)
|
62
62
|
Page.new(path: path).content_type
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should be text/html for html pages' do
|
66
|
-
content_type_for('asdf').should
|
67
|
-
content_type_for('asdf.htm').should
|
68
|
-
content_type_for('asdf.html').should
|
66
|
+
content_type_for('asdf').should eq 'text/html'
|
67
|
+
content_type_for('asdf.htm').should eq 'text/html'
|
68
|
+
content_type_for('asdf.html').should eq 'text/html'
|
69
69
|
end
|
70
70
|
|
71
71
|
it 'should be application/json for json' do
|
72
|
-
content_type_for('asdf.json').should
|
72
|
+
content_type_for('asdf.json').should eq 'application/json'
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'should be application/xml for xml' do
|
76
|
-
content_type_for('asdf.xml').should
|
76
|
+
content_type_for('asdf.xml').should eq 'application/xml'
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should be text/plain for everything else' do
|
80
|
-
content_type_for('foo.bar').should
|
81
|
-
content_type_for('foo.txt').should
|
80
|
+
content_type_for('foo.bar').should eq 'text/plain'
|
81
|
+
content_type_for('foo.txt').should eq 'text/plain'
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -112,17 +112,17 @@ module Landable
|
|
112
112
|
describe '#meta_tags' do
|
113
113
|
it { subject.should have_valid(:meta_tags).when(nil) }
|
114
114
|
|
115
|
-
specify
|
115
|
+
specify 'quacks like a Hash' do
|
116
116
|
# Note the change from symbol to string; thus, always favor strings.
|
117
117
|
page = create :page, meta_tags: { keywords: 'foo' }
|
118
118
|
|
119
119
|
# rails 4.0 preserves the symbol for this instance; rails 4.1 switches straight to strings
|
120
|
-
page.meta_tags.keys.map(&:to_s).should
|
120
|
+
page.meta_tags.keys.map(&:to_s).should eq ['keywords']
|
121
121
|
|
122
122
|
tags = Page.first.meta_tags
|
123
123
|
tags.should be_a(Enumerable)
|
124
|
-
tags.keys.should
|
125
|
-
tags.values.should
|
124
|
+
tags.keys.should eq ['keywords']
|
125
|
+
tags.values.should eq ['foo']
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -131,23 +131,23 @@ module Landable
|
|
131
131
|
|
132
132
|
it 'works as a basic text area' do
|
133
133
|
page = create :page, head_content: "<head en='en'/>"
|
134
|
-
page.head_content.should
|
135
|
-
|
134
|
+
page.head_content.should eq "<head en='en'/>"
|
135
|
+
|
136
136
|
page.head_content = "<head en='magic'/>"
|
137
137
|
page.save
|
138
138
|
|
139
|
-
page.head_content.should
|
139
|
+
page.head_content.should eq "<head en='magic'/>"
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
143
|
describe '#path=' do
|
144
144
|
it 'ensures a leading "/" on path' do
|
145
|
-
Page.new(path: 'foo/bar').path.should
|
145
|
+
Page.new(path: 'foo/bar').path.should eq '/foo/bar'
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'leaves nil and empty paths alone' do
|
149
|
-
Page.new(path: '').path.should
|
150
|
-
Page.new(path: nil).path.should
|
149
|
+
Page.new(path: '').path.should eq ''
|
150
|
+
Page.new(path: nil).path.should.nil?
|
151
151
|
end
|
152
152
|
end
|
153
153
|
|
@@ -156,21 +156,21 @@ module Landable
|
|
156
156
|
let(:author) { FactoryGirl.create :author }
|
157
157
|
|
158
158
|
it 'should create a page_revision' do
|
159
|
-
expect {page.publish!(author: author)}.to change{page.revisions.count}.from(0).to(1)
|
159
|
+
expect { page.publish!(author: author) }.to change { page.revisions.count }.from(0).to(1)
|
160
160
|
end
|
161
161
|
|
162
162
|
it 'should have the provided author' do
|
163
163
|
page.publish! author: author
|
164
164
|
revision = page.revisions.last
|
165
165
|
|
166
|
-
revision.author.should
|
166
|
+
revision.author.should eq author
|
167
167
|
end
|
168
168
|
|
169
169
|
it 'should update the published_revision_id' do
|
170
170
|
page.publish! author: author
|
171
171
|
revision = page.revisions.last
|
172
172
|
|
173
|
-
page.published_revision.should
|
173
|
+
page.published_revision.should eq revision
|
174
174
|
end
|
175
175
|
|
176
176
|
it 'should set is_publishable to false' do
|
@@ -201,7 +201,7 @@ module Landable
|
|
201
201
|
|
202
202
|
page.revert_to! revision
|
203
203
|
|
204
|
-
page.published_revision.id.should_not
|
204
|
+
page.published_revision.id.should_not eq revision.id
|
205
205
|
end
|
206
206
|
|
207
207
|
it 'should copy revision attributes into the page model' do
|
@@ -232,7 +232,7 @@ module Landable
|
|
232
232
|
expect { page.save! }.to raise_error
|
233
233
|
|
234
234
|
page.reload
|
235
|
-
page.path.should
|
235
|
+
page.path.should eq '/test'
|
236
236
|
end
|
237
237
|
end
|
238
238
|
|
@@ -241,7 +241,7 @@ module Landable
|
|
241
241
|
page = build :page, path: '/test'
|
242
242
|
page.save!
|
243
243
|
|
244
|
-
page.path.should
|
244
|
+
page.path.should eq '/test'
|
245
245
|
end
|
246
246
|
end
|
247
247
|
end
|
@@ -250,7 +250,7 @@ module Landable
|
|
250
250
|
it 'should return the preview path' do
|
251
251
|
page = build :page
|
252
252
|
page.should_receive(:public_preview_page_path) { 'foo' }
|
253
|
-
page.preview_path.should
|
253
|
+
page.preview_path.should eq 'foo'
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
@@ -258,22 +258,22 @@ module Landable
|
|
258
258
|
it 'should return the preview url' do
|
259
259
|
page = build :page
|
260
260
|
page.should_receive(:public_preview_page_url) { 'foo' }
|
261
|
-
page.preview_url.should
|
261
|
+
page.preview_url.should eq 'foo'
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
265
|
describe '::sitemappable' do
|
266
|
-
let(:page)
|
266
|
+
let(:page) do
|
267
267
|
create :page do |page|
|
268
268
|
page.publish! author: create(:author), notes: 'yo'
|
269
269
|
end
|
270
|
-
|
270
|
+
end
|
271
271
|
let(:page_2) { create :page, :redirect }
|
272
272
|
let(:page_3) { create :page, meta_tags: { 'robots' => 'noindex' } }
|
273
273
|
let(:page_4) { create :page }
|
274
274
|
|
275
|
-
it 'only returns published pages with a status code of 200 and dont have a noindex tag' do
|
276
|
-
page_2.status_code.should
|
275
|
+
it 'only returns published pages with a status code of 200 and dont have a noindex tag' do
|
276
|
+
page_2.status_code.should eq 301
|
277
277
|
|
278
278
|
Landable::Page.sitemappable.should include(page)
|
279
279
|
Landable::Page.sitemappable.should_not include(page_2, page_3, page_4)
|
@@ -284,13 +284,13 @@ module Landable
|
|
284
284
|
it 'should force a path to be lowercase' do
|
285
285
|
page = build :page, path: '/SEO'
|
286
286
|
page.should be_valid
|
287
|
-
page.path.should
|
287
|
+
page.path.should eq '/seo'
|
288
288
|
end
|
289
289
|
|
290
290
|
it 'doesnt change a downcase path' do
|
291
291
|
page = build :page, path: '/seo'
|
292
292
|
page.should be_valid
|
293
|
-
page.path.should
|
293
|
+
page.path.should eq '/seo'
|
294
294
|
end
|
295
295
|
end
|
296
296
|
|
@@ -322,7 +322,6 @@ module Landable
|
|
322
322
|
@page.redirect_url = 'hdasdfpou'
|
323
323
|
@page.should_not be_valid
|
324
324
|
end
|
325
|
-
|
326
325
|
end
|
327
326
|
end
|
328
327
|
|
@@ -360,14 +359,14 @@ module Landable
|
|
360
359
|
Landable::Page.generate_sitemap(host: 'example.com',
|
361
360
|
protocol: 'https',
|
362
361
|
exclude_categories: [],
|
363
|
-
sitemap_additional_paths: ['/terms.html']).should include(
|
362
|
+
sitemap_additional_paths: ['/terms.html']).should include('<loc>https://example.com/terms.html</loc>')
|
364
363
|
end
|
365
364
|
end
|
366
365
|
|
367
366
|
describe '::by_path' do
|
368
367
|
it 'returns first page with path name' do
|
369
368
|
page = create :page, path: '/seo'
|
370
|
-
Landable::Page.by_path('/seo').should
|
369
|
+
Landable::Page.by_path('/seo').should eq page
|
371
370
|
end
|
372
371
|
end
|
373
372
|
|
@@ -384,7 +383,7 @@ module Landable
|
|
384
383
|
page.body = 'body'
|
385
384
|
page.should be_valid
|
386
385
|
page.save!
|
387
|
-
page.body.should
|
386
|
+
page.body.should eq 'body'
|
388
387
|
end
|
389
388
|
end
|
390
389
|
end
|
@@ -5,7 +5,7 @@ module Landable
|
|
5
5
|
let(:author) { create(:author) }
|
6
6
|
|
7
7
|
let(:template) do
|
8
|
-
create(:template, name: 'Title', body: 'body',
|
8
|
+
create(:template, name: 'Title', body: 'body',
|
9
9
|
slug: 'title', description: 'awesome template')
|
10
10
|
end
|
11
11
|
|
@@ -26,9 +26,9 @@ module Landable
|
|
26
26
|
revision.template_id = template.id
|
27
27
|
revision.author_id = author.id
|
28
28
|
revision.unpublish!
|
29
|
-
revision.is_published.should
|
29
|
+
revision.is_published.should eq false
|
30
30
|
revision.publish!
|
31
|
-
revision.is_published.should
|
31
|
+
revision.is_published.should eq true
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -17,8 +17,8 @@ module Landable
|
|
17
17
|
it 'should assign a slug' do
|
18
18
|
template = build(:template, slug: nil)
|
19
19
|
template.name = 'Six Seven'
|
20
|
-
template.name.should
|
21
|
-
template.slug.should
|
20
|
+
template.name.should eq 'Six Seven'
|
21
|
+
template.slug.should eq 'six_seven'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -26,8 +26,8 @@ module Landable
|
|
26
26
|
it 'should leave the slug alone' do
|
27
27
|
template = build(:template, slug: 'six')
|
28
28
|
template.name = 'seven'
|
29
|
-
template.name.should
|
30
|
-
template.slug.should
|
29
|
+
template.name.should eq 'seven'
|
30
|
+
template.slug.should eq 'six'
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -49,21 +49,21 @@ module Landable
|
|
49
49
|
let(:author) { FactoryGirl.create :author }
|
50
50
|
|
51
51
|
it 'should create a template_revision' do
|
52
|
-
expect {template.publish!(author: author)}.to change{template.revisions.count}.from(0).to(1)
|
52
|
+
expect { template.publish!(author: author) }.to change { template.revisions.count }.from(0).to(1)
|
53
53
|
end
|
54
54
|
|
55
55
|
it 'should have the provided author' do
|
56
56
|
template.publish! author: author
|
57
57
|
revision = template.revisions.last
|
58
58
|
|
59
|
-
revision.author.should
|
59
|
+
revision.author.should eq author
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'should update the published_revision_id' do
|
63
63
|
template.publish! author: author
|
64
64
|
revision = template.revisions.last
|
65
65
|
|
66
|
-
template.published_revision.should
|
66
|
+
template.published_revision.should eq revision
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should unset previous revision.is_published' do
|
@@ -97,7 +97,7 @@ module Landable
|
|
97
97
|
|
98
98
|
template.revert_to! revision
|
99
99
|
|
100
|
-
template.published_revision.id.should_not
|
100
|
+
template.published_revision.id.should_not eq revision.id
|
101
101
|
end
|
102
102
|
|
103
103
|
it 'should copy revision attributes into the page model' do
|
@@ -126,8 +126,8 @@ module Landable
|
|
126
126
|
t.name = 'No Space'
|
127
127
|
t.save!
|
128
128
|
|
129
|
-
t.slug.should_not
|
130
|
-
t.slug.should
|
129
|
+
t.slug.should_not eq 'I have no space'
|
130
|
+
t.slug.should eq 'i_have_no_space'
|
131
131
|
end
|
132
132
|
|
133
133
|
it 'should allow the name to set the slug' do
|
@@ -135,7 +135,7 @@ module Landable
|
|
135
135
|
t.name = 'I have no space'
|
136
136
|
t.save!
|
137
137
|
|
138
|
-
t.slug.should
|
138
|
+
t.slug.should eq 'i_have_no_space'
|
139
139
|
end
|
140
140
|
end
|
141
141
|
end
|
@@ -9,13 +9,13 @@ module Landable
|
|
9
9
|
it 'returns the most used theme' do
|
10
10
|
t = create :theme
|
11
11
|
t2 = create :theme
|
12
|
-
|
12
|
+
create :theme
|
13
13
|
create :page, theme: t
|
14
14
|
create :page, theme: t
|
15
15
|
create :page, theme: t2
|
16
16
|
create :page, theme: t
|
17
17
|
|
18
|
-
Theme.most_used_on_pages.should
|
18
|
+
Theme.most_used_on_pages.should eq t
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'return nil when there are no themes' do
|
@@ -7,14 +7,14 @@ module Landable
|
|
7
7
|
|
8
8
|
describe '#url' do
|
9
9
|
it 'should return the entire url as a string' do
|
10
|
-
referer.url.should
|
10
|
+
referer.url.should eq 'http://www.something.com/mypath'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe '#uri' do
|
15
15
|
it 'should return the URI object' do
|
16
|
-
test_uri = URI(
|
17
|
-
referer.uri.should
|
16
|
+
test_uri = URI('http://www.something.com/mypath')
|
17
|
+
referer.uri.should eq test_uri
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Landable::PageRenderResponder do
|
4
|
-
|
5
4
|
let(:page) { build :page }
|
6
5
|
let(:responder) { Landable::PageRenderResponder.new double(request: double, formats: []), [page] }
|
7
6
|
|
@@ -39,5 +38,4 @@ describe Landable::PageRenderResponder do
|
|
39
38
|
end
|
40
39
|
end
|
41
40
|
end
|
42
|
-
|
43
41
|
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'public page routes' do
|
4
|
-
|
5
4
|
routes { Landable::Engine.routes }
|
6
5
|
|
7
6
|
context 'should match' do
|
8
7
|
let(:author) { create :author }
|
9
8
|
let(:pages) do
|
10
|
-
[
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
[create(:page, status_code: 200),
|
10
|
+
create(:page, status_code: 301, redirect_url: 'http://google.com/'),
|
11
|
+
create(:page, status_code: 302, redirect_url: 'http://foobar.com/'),
|
12
|
+
create(:page, status_code: 410)
|
14
13
|
].each do |page|
|
15
14
|
page.publish! author: author, status_code: page.status_code
|
16
15
|
end
|
@@ -17,15 +17,15 @@ describe Landable::AuthenticationService do
|
|
17
17
|
Landable.configuration.stub(authenticators: [simple_auth, echo_auth])
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
21
|
-
described_class.call('simple', 'authenticator')[:username].should
|
22
|
-
described_class.call('echo', 'echo')[:username].should
|
20
|
+
it 'returns the result of the first successful authentication strategy' do
|
21
|
+
described_class.call('simple', 'authenticator')[:username].should eq 'simple'
|
22
|
+
described_class.call('echo', 'echo')[:username].should eq 'echo'
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
26
|
-
expect
|
25
|
+
it 'raises AuthenticationFailedError if no strategy worked' do
|
26
|
+
expect do
|
27
27
|
described_class.call('will', 'fail')
|
28
|
-
|
28
|
+
end.to raise_error(Landable::AuthenticationFailedError)
|
29
29
|
end
|
30
30
|
|
31
31
|
describe 'EchoAuthenticator' do
|
@@ -55,7 +55,7 @@ describe Landable::AuthenticationService do
|
|
55
55
|
instance = echo_auth.new('trogdor', 'some-pass')
|
56
56
|
instance.call('previously', 'worked').should be_nil
|
57
57
|
instance.call('trogdor', 'trogdor').should be_nil
|
58
|
-
instance.call('trogdor', 'some-pass')[:username].should
|
58
|
+
instance.call('trogdor', 'some-pass')[:username].should eq 'trogdor'
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|