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
@@ -4,28 +4,28 @@ module Landable
|
|
4
4
|
describe Landable::Traffic::Tracker do
|
5
5
|
let(:referer) { '/something/ valid' }
|
6
6
|
let(:user_agent) { 'type' }
|
7
|
-
let(:format) { double('format',
|
8
|
-
let(:request) { double('request',
|
9
|
-
let(:controller) { double('controller',
|
7
|
+
let(:format) { double('format', html?: true) }
|
8
|
+
let(:request) { double('request', query_parameters: {}, user_agent: user_agent, referer: referer, format: format) }
|
9
|
+
let(:controller) { double('controller', request: request) }
|
10
10
|
|
11
|
-
describe
|
11
|
+
describe '#for' do
|
12
12
|
it 'should default to UserTracker if user_agent does not exist' do
|
13
13
|
Landable::Traffic::Tracker.for(controller).should be_a(Landable::Traffic::UserTracker)
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should create the appropriate type of tracker based on user_agent' do
|
17
|
-
type = double('type',
|
17
|
+
type = double('type', user_agent_type: 'Scan')
|
18
18
|
fake_agent = {}
|
19
|
-
fake_agent[
|
20
|
-
stub_const(
|
19
|
+
fake_agent['type'] = type
|
20
|
+
stub_const('Landable::Traffic::UserAgent', fake_agent)
|
21
21
|
|
22
22
|
Landable::Traffic::Tracker.for(controller).should be_a(Landable::Traffic::ScanTracker)
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should not bark if user_agent is nil' do
|
26
26
|
user_agent = nil
|
27
|
-
request = double('request',
|
28
|
-
controller = double('controller',
|
27
|
+
request = double('request', query_parameters: {}, user_agent: user_agent, format: format)
|
28
|
+
controller = double('controller', request: request)
|
29
29
|
|
30
30
|
Landable::Traffic::Tracker.for(controller).should be_a(Landable::Traffic::UserTracker)
|
31
31
|
end
|
@@ -33,31 +33,31 @@ module Landable
|
|
33
33
|
it 'should set type to noop when non-html content' do
|
34
34
|
user_agent = nil
|
35
35
|
Landable.configuration.stub(:traffic_enabled).and_return(:html)
|
36
|
-
format = double('format',
|
37
|
-
request = double('request',
|
38
|
-
controller = double('controller',
|
36
|
+
format = double('format', html?: false)
|
37
|
+
request = double('request', query_parameters: {}, user_agent: user_agent, format: format)
|
38
|
+
controller = double('controller', request: request)
|
39
39
|
|
40
40
|
Landable::Traffic::Tracker.for(controller).should be_a(Landable::Traffic::NoopTracker)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should allow non-html content if config says so' do
|
44
|
-
format = double('format',
|
45
|
-
request = double('request',
|
46
|
-
controller = double('controller',
|
44
|
+
format = double('format', html?: false)
|
45
|
+
request = double('request', query_parameters: {}, user_agent: user_agent, format: format)
|
46
|
+
controller = double('controller', request: request)
|
47
47
|
|
48
48
|
Landable::Traffic::Tracker.for(controller).should be_a(Landable::Traffic::UserTracker)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
context 'referer' do
|
53
|
-
let(:visit_referer) { double('visit_referer',
|
54
|
-
let(:visit) { double('visit',
|
53
|
+
let(:visit_referer) { double('visit_referer', url: 'http://www.fakedomain.yes/mypath', uri: URI('http://www.fakedomain.yes/mypath')) }
|
54
|
+
let(:visit) { double('visit', referer: visit_referer) }
|
55
55
|
|
56
56
|
describe '#referer_uri' do
|
57
57
|
it 'should encode special characters' do
|
58
58
|
tracker = Landable::Traffic::UserTracker.new controller
|
59
59
|
|
60
|
-
tracker.send(:referer_uri).path.should
|
60
|
+
tracker.send(:referer_uri).path.should eq '/something/%20valid'
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -66,7 +66,7 @@ module Landable
|
|
66
66
|
tracker = Landable::Traffic::UserTracker.new controller
|
67
67
|
tracker.stub(:visit) { visit }
|
68
68
|
|
69
|
-
tracker.send(:visit_referer_domain).should
|
69
|
+
tracker.send(:visit_referer_domain).should eq 'www.fakedomain.yes'
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -75,7 +75,7 @@ module Landable
|
|
75
75
|
tracker = Landable::Traffic::UserTracker.new controller
|
76
76
|
tracker.stub(:visit) { visit }
|
77
77
|
|
78
|
-
tracker.send(:visit_referer_path).should
|
78
|
+
tracker.send(:visit_referer_path).should eq '/mypath'
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -84,7 +84,7 @@ module Landable
|
|
84
84
|
tracker = Landable::Traffic::UserTracker.new controller
|
85
85
|
tracker.stub(:visit) { visit }
|
86
86
|
|
87
|
-
tracker.send(:visit_referer_url).should
|
87
|
+
tracker.send(:visit_referer_url).should eq 'http://www.fakedomain.yes/mypath'
|
88
88
|
end
|
89
89
|
end
|
90
90
|
end
|
@@ -98,7 +98,7 @@ module Landable
|
|
98
98
|
tracker = Landable::Traffic::UserTracker.new controller
|
99
99
|
tracker.stub(:user_agent) { user_agent }
|
100
100
|
|
101
|
-
tracker.send(:get_user_agent).should
|
101
|
+
tracker.send(:get_user_agent).should eq user_agent
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -114,8 +114,8 @@ module Landable
|
|
114
114
|
end
|
115
115
|
|
116
116
|
context 'no referer' do
|
117
|
-
let(:referer) { double('referer',
|
118
|
-
let(:visit) { double('visit',
|
117
|
+
let(:referer) { double('referer', path: nil) }
|
118
|
+
let(:visit) { double('visit', referer: nil) }
|
119
119
|
|
120
120
|
describe '#referer_uri_path' do
|
121
121
|
it 'should return empty string' do
|
@@ -131,7 +131,7 @@ module Landable
|
|
131
131
|
tracker = Landable::Traffic::UserTracker.new controller
|
132
132
|
tracker.stub(:visit) { visit }
|
133
133
|
|
134
|
-
tracker.send(:visit_referer_domain).should
|
134
|
+
tracker.send(:visit_referer_domain).should.nil?
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -140,7 +140,7 @@ module Landable
|
|
140
140
|
tracker = Landable::Traffic::UserTracker.new controller
|
141
141
|
tracker.stub(:visit) { visit }
|
142
142
|
|
143
|
-
tracker.send(:visit_referer_path).should
|
143
|
+
tracker.send(:visit_referer_path).should.nil?
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
@@ -149,11 +149,9 @@ module Landable
|
|
149
149
|
tracker = Landable::Traffic::UserTracker.new controller
|
150
150
|
tracker.stub(:visit) { visit }
|
151
151
|
|
152
|
-
tracker.send(:visit_referer_url).should
|
152
|
+
tracker.send(:visit_referer_url).should.nil?
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
156
|
-
|
157
156
|
end
|
158
|
-
|
159
157
|
end
|
@@ -1,45 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
|
3
|
-
module Landable
|
4
2
|
|
3
|
+
module Landable
|
5
4
|
class TrackError < StandardError
|
6
5
|
end
|
7
6
|
|
8
7
|
class SaveError < StandardError
|
9
8
|
end
|
10
|
-
|
11
|
-
describe Traffic, type: :controller do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
|
10
|
+
describe Traffic, type: :controller do
|
11
|
+
controller(ApplicationController) do
|
12
|
+
include Landable::Traffic
|
13
|
+
prepend_around_action :track_with_landable!
|
14
|
+
|
15
|
+
def my_method
|
16
|
+
render nothing: true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
before do
|
21
|
+
routes.draw do
|
22
|
+
get 'my_method' => 'anonymous#my_method'
|
23
|
+
end
|
19
24
|
end
|
20
|
-
end
|
21
|
-
|
22
|
-
before do
|
23
|
-
routes.draw do
|
24
|
-
get 'my_method' => 'anonymous#my_method'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe 'track_with_landable!' do
|
29
|
-
it 'should log errors' do
|
30
|
-
tracker = double('tracker')
|
31
25
|
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
describe 'track_with_landable!' do
|
27
|
+
it 'should log errors' do
|
28
|
+
tracker = double('tracker')
|
35
29
|
|
36
|
-
|
37
|
-
|
30
|
+
Landable::Traffic::Tracker.stub(:for).and_return(tracker)
|
31
|
+
tracker.stub(:track).and_raise(TrackError)
|
32
|
+
tracker.stub(:save).and_raise(SaveError)
|
38
33
|
|
39
|
-
|
40
|
-
|
34
|
+
controller.should_receive(:newrelic_notice_error) { |error| error.should be_an_instance_of TrackError }
|
35
|
+
controller.should_receive(:newrelic_notice_error) { |error| error.should be_an_instance_of SaveError }
|
36
|
+
|
37
|
+
get :my_method
|
38
|
+
end
|
39
|
+
end
|
41
40
|
end
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
41
|
+
end
|
@@ -4,7 +4,7 @@ module Landable
|
|
4
4
|
describe AccessToken do
|
5
5
|
it { should_not have_valid(:author_id).when(nil) }
|
6
6
|
|
7
|
-
it
|
7
|
+
it 'generates an expiration timestamp before creation' do
|
8
8
|
author = create :author
|
9
9
|
token = AccessToken.create!(author: author)
|
10
10
|
expect(token.expires_at).not_to be_nil
|
@@ -19,30 +19,28 @@ describe Landable::Asset do
|
|
19
19
|
it { should_not have_valid(:mime_type).when(nil, '') }
|
20
20
|
it { should_not have_valid(:file_size).when(nil, 1.5) }
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'stores an md5sum of its contents' do
|
23
23
|
asset = build(:asset, data: png)
|
24
|
-
expect {
|
25
|
-
asset.valid?
|
26
|
-
}.to change { asset.md5sum }.from(nil).to('0f62ef551dbebcdb7379401528b6115c')
|
24
|
+
expect { asset.valid? }.to change { asset.md5sum }.from(nil).to('0f62ef551dbebcdb7379401528b6115c')
|
27
25
|
end
|
28
26
|
|
29
|
-
it
|
30
|
-
|
27
|
+
it 'requires the md5sum to be unique' do
|
28
|
+
create(:asset, data: png)
|
31
29
|
dupe = build(:asset, data: png)
|
32
30
|
|
33
31
|
expect(dupe).not_to be_valid
|
34
32
|
expect(dupe.errors_on(:md5sum)).to eql(['has already been taken'])
|
35
33
|
end
|
36
34
|
|
37
|
-
it
|
35
|
+
it 'provides access to the other asset with the same contents' do
|
38
36
|
orig = create(:asset, data: png)
|
39
37
|
dupe = build(:asset, data: png)
|
40
38
|
expect(dupe.duplicate_of).to eql(orig)
|
41
39
|
end
|
42
40
|
|
43
|
-
it
|
44
|
-
|
45
|
-
asset = create(:asset, data:pdf, name:
|
46
|
-
asset.associated_pages.should eq([
|
41
|
+
it 'returns a list of pages using the asset' do
|
42
|
+
create(:page, body: 'panda.png', path: '/testing/assets')
|
43
|
+
asset = create(:asset, data: pdf, name: 'panda.png')
|
44
|
+
asset.associated_pages.should eq(['/testing/assets'])
|
47
45
|
end
|
48
46
|
end
|
@@ -10,27 +10,27 @@ module Landable
|
|
10
10
|
|
11
11
|
it 'knows its own path' do
|
12
12
|
dir = Directory.listing '/'
|
13
|
-
dir.path.should
|
13
|
+
dir.path.should eq '/'
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'lists immediate children' do
|
17
17
|
stub_contents
|
18
18
|
|
19
19
|
dir = Directory.listing '/'
|
20
|
-
dir.subdirectories.map(&:path).should
|
21
|
-
dir.pages.map(&:path).should
|
20
|
+
dir.subdirectories.map(&:path).should eq ['/aff', '/seo']
|
21
|
+
dir.pages.map(&:path).should eq ['/quux']
|
22
22
|
|
23
23
|
dir = Directory.listing '/aff'
|
24
|
-
dir.subdirectories.map(&:path).should
|
25
|
-
dir.pages.map(&:path).should
|
24
|
+
dir.subdirectories.map(&:path).should eq ['/aff/deeply']
|
25
|
+
dir.pages.map(&:path).should eq ['/aff/bar', '/aff/deeply_nested']
|
26
26
|
|
27
27
|
dir = Directory.listing '/seo'
|
28
28
|
dir.subdirectories.should be_empty
|
29
|
-
dir.pages.map(&:path).should
|
29
|
+
dir.pages.map(&:path).should eq ['/seo/baz', '/seo/foo']
|
30
30
|
|
31
31
|
dir = Directory.listing '/aff/deeply'
|
32
32
|
dir.subdirectories.should be_empty
|
33
|
-
dir.pages.map(&:path).should
|
33
|
+
dir.pages.map(&:path).should eq ['/aff/deeply/nested']
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -2,7 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Landable
|
4
4
|
describe Page do
|
5
|
-
|
6
5
|
describe '#error?' do
|
7
6
|
describe 'yep' do
|
8
7
|
specify { build(:page, status_code: 418).should be_error }
|
@@ -16,7 +15,7 @@ module Landable
|
|
16
15
|
end
|
17
16
|
|
18
17
|
describe '#error' do
|
19
|
-
def error_for
|
18
|
+
def error_for(code)
|
20
19
|
build(:page, status_code: code).error
|
21
20
|
end
|
22
21
|
|
@@ -25,6 +24,5 @@ module Landable
|
|
25
24
|
specify { error_for(200).should be_nil }
|
26
25
|
specify { error_for(302).should be_nil }
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
30
28
|
end
|
@@ -7,8 +7,8 @@ module Landable
|
|
7
7
|
|
8
8
|
let(:page) do
|
9
9
|
create(:page, path: '/test/path', title: 'title', status_code: 200,
|
10
|
-
|
11
|
-
|
10
|
+
body: 'body', redirect_url: 'http://www.redirect.com/here',
|
11
|
+
meta_tags: { 'key' => 'value' }, head_content: 'head_content')
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:revision) do
|
@@ -18,12 +18,12 @@ module Landable
|
|
18
18
|
it { should be_a HasAssets }
|
19
19
|
|
20
20
|
it 'defaults to is_published = true' do
|
21
|
-
PageRevision.new.is_published.should
|
21
|
+
PageRevision.new.is_published.should eq true
|
22
22
|
end
|
23
23
|
|
24
24
|
describe '#page_id=' do
|
25
25
|
it 'should set page revision attributes matching the page' do
|
26
|
-
attrs = revision.attributes.except('page_revision_id','ordinal','notes','is_minor','is_published','author_id','created_at','updated_at', 'page_id', 'audit_flags')
|
26
|
+
attrs = revision.attributes.except('page_revision_id', 'ordinal', 'notes', 'is_minor', 'is_published', 'author_id', 'created_at', 'updated_at', 'page_id', 'audit_flags')
|
27
27
|
attrs.should include(page.attributes.except(*PageRevision.ignored_page_attributes))
|
28
28
|
end
|
29
29
|
end
|
@@ -33,15 +33,15 @@ module Landable
|
|
33
33
|
snapshot = revision.snapshot
|
34
34
|
snapshot.should be_new_record
|
35
35
|
snapshot.should be_an_instance_of Page
|
36
|
-
snapshot.title.should
|
37
|
-
snapshot.path.should
|
38
|
-
snapshot.head_content.should
|
39
|
-
snapshot.meta_tags.should
|
40
|
-
snapshot.body.should
|
41
|
-
snapshot.redirect_url.should
|
42
|
-
snapshot.category_id.should
|
43
|
-
snapshot.theme_id.should
|
44
|
-
snapshot.status_code.should
|
36
|
+
snapshot.title.should eq page.title
|
37
|
+
snapshot.path.should eq page.path
|
38
|
+
snapshot.head_content.should eq page.head_content
|
39
|
+
snapshot.meta_tags.should eq page.meta_tags
|
40
|
+
snapshot.body.should eq page.body
|
41
|
+
snapshot.redirect_url.should eq page.redirect_url
|
42
|
+
snapshot.category_id.should eq page.category_id
|
43
|
+
snapshot.theme_id.should eq page.theme_id
|
44
|
+
snapshot.status_code.should eq page.status_code
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -51,9 +51,9 @@ module Landable
|
|
51
51
|
revision.page_id = page.id
|
52
52
|
revision.author_id = author.id
|
53
53
|
revision.unpublish!
|
54
|
-
revision.is_published.should
|
54
|
+
revision.is_published.should eq false
|
55
55
|
revision.publish!
|
56
|
-
revision.is_published.should
|
56
|
+
revision.is_published.should eq true
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -62,20 +62,20 @@ module Landable
|
|
62
62
|
template = create :template, name: 'Basic'
|
63
63
|
old = PageRevision.create!(page_id: page.id, author_id: author.id, is_published: true)
|
64
64
|
new_author = create :author
|
65
|
-
old.republish!(
|
65
|
+
old.republish!(author_id: new_author.id, notes: 'Great Note', template: template.name)
|
66
66
|
|
67
67
|
new_record = PageRevision.order('created_at ASC').last
|
68
|
-
new_record.author_id.should
|
69
|
-
new_record.notes.should
|
70
|
-
new_record.page_id.should
|
71
|
-
new_record.body.should
|
68
|
+
new_record.author_id.should eq new_author.id
|
69
|
+
new_record.notes.should eq "Publishing update for template #{template.name}: Great Note"
|
70
|
+
new_record.page_id.should eq page.id
|
71
|
+
new_record.body.should eq page.body
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
describe '#preview_path' do
|
76
76
|
it 'should return the preview path' do
|
77
77
|
revision.should_receive(:public_preview_page_revision_path) { 'foo' }
|
78
|
-
revision.preview_path.should
|
78
|
+
revision.preview_path.should eq 'foo'
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -83,7 +83,7 @@ module Landable
|
|
83
83
|
it 'should return the preview url' do
|
84
84
|
Landable.configuration.stub(:public_host) { 'foo' }
|
85
85
|
revision.should_receive(:public_preview_page_revision_url).with(revision, host: 'foo') { 'bar' }
|
86
|
-
revision.preview_url.should
|
86
|
+
revision.preview_url.should eq 'bar'
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
@@ -132,7 +132,7 @@ module Landable
|
|
132
132
|
screenshot = double('screenshot', url: 'foobar')
|
133
133
|
|
134
134
|
revision.stub(:screenshot) { screenshot }
|
135
|
-
revision.screenshot_url.should
|
135
|
+
revision.screenshot_url.should eq screenshot.url
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -143,6 +143,5 @@ module Landable
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
end
|
146
|
-
|
147
146
|
end
|
148
147
|
end
|