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
@@ -2,33 +2,35 @@
|
|
2
2
|
|
3
3
|
expand_mustache = lambda do |context, str|
|
4
4
|
if str.respond_to?(:gsub)
|
5
|
-
str.gsub(/\{\{([^ ].+?)\}\}/) { context.eval(
|
5
|
+
str.gsub(/\{\{([^ ].+?)\}\}/) { context.eval(Regexp.last_match(1)) }
|
6
6
|
else
|
7
7
|
str
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
module Landable
|
12
|
-
|
13
|
-
basic_authorize
|
14
|
-
|
11
|
+
module Landable
|
12
|
+
module FeatureHelper
|
13
|
+
def basic_authorize!(author = current_author, token = current_access_token)
|
14
|
+
basic_authorize author.username, token.id
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
def current_author
|
18
|
+
@current_author ||= create :author
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def current_access_token
|
22
|
+
@current_access_token ||= create :access_token, author: @current_author
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
def last_json(body = last_response.body)
|
26
|
+
JSON.parse body
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def latest(model)
|
30
|
+
model = model.to_s.classify
|
31
|
+
klass = "Landable::#{model}".constantize
|
32
|
+
klass.order('created_at DESC').first!
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -68,11 +70,11 @@ Given 'my access token expired 2 minutes ago' do
|
|
68
70
|
current_access_token.update_attributes!(expires_at: 2.minutes.ago)
|
69
71
|
end
|
70
72
|
|
71
|
-
When
|
73
|
+
When(/^I (HEAD|GET|POST|PUT|PATCH|DELETE|OPTIONS)(?: to)? "(.+?)"$/) do |http_method, path|
|
72
74
|
request expand_mustache[binding, path], method: http_method
|
73
75
|
end
|
74
76
|
|
75
|
-
When
|
77
|
+
When(/^I (POST|PUT|PATCH|DELETE|OPTIONS)(?: to)? "(.+?)"(?: with)?:$/) do |http_method, path, body|
|
76
78
|
request expand_mustache[binding, path], method: http_method, params: body
|
77
79
|
end
|
78
80
|
|
@@ -93,7 +95,7 @@ Then 'my access token should not expire for at least 2 hours' do
|
|
93
95
|
token.expires_at.should be >= 2.hours.from_now
|
94
96
|
end
|
95
97
|
|
96
|
-
Then
|
98
|
+
Then(/^the response(?: status)? should(?: (not))? be (\d{3})(?: "[A-Za-z ]+")?$/) do |negate, code|
|
97
99
|
code = Integer(code)
|
98
100
|
if negate == 'not'
|
99
101
|
last_response.status.should_not eq(code)
|
@@ -102,13 +104,13 @@ Then /^the response(?: status)? should(?: (not))? be (\d{3})(?: "[A-Za-z ]+")?$/
|
|
102
104
|
end
|
103
105
|
end
|
104
106
|
|
105
|
-
Then
|
107
|
+
Then(/^the response should contain (?:a|an) "([^"]+)"$/) do |model|
|
106
108
|
last_json.should have_key(model)
|
107
109
|
last_json[model].should have_key('id')
|
108
110
|
end
|
109
111
|
|
110
|
-
Then
|
111
|
-
last_json[kind].length.should
|
112
|
+
Then(/^the response should contain (\d+) "([^"]+)"$/) do |count, kind|
|
113
|
+
last_json[kind].length.should eq Integer(count)
|
112
114
|
end
|
113
115
|
|
114
116
|
Then 'the response body should be empty' do
|
@@ -116,11 +118,11 @@ Then 'the response body should be empty' do
|
|
116
118
|
end
|
117
119
|
|
118
120
|
Then 'the response body should be "$body"' do |body|
|
119
|
-
last_response.body.should
|
121
|
+
last_response.body.should eq body
|
120
122
|
end
|
121
123
|
|
122
124
|
Then 'I should have been redirected to "$url"' do |url|
|
123
|
-
last_response.headers['Location'].should
|
125
|
+
last_response.headers['Location'].should eq url
|
124
126
|
end
|
125
127
|
|
126
128
|
Then 'the response headers should include:' do |table|
|
@@ -131,7 +133,7 @@ Then 'the response headers should include:' do |table|
|
|
131
133
|
end
|
132
134
|
|
133
135
|
Then 'the JSON at "$path" should be "$value"' do |json_path, value|
|
134
|
-
at_json(json_path).should
|
136
|
+
at_json(json_path).should eq value
|
135
137
|
end
|
136
138
|
|
137
139
|
Then 'the response header "$header" should be "$content_type"' do |header, content_type|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Given
|
1
|
+
Given(/^(\d+) ([\w\s]+)$/) do |count, kind|
|
2
2
|
klass = kind.gsub(/\s+/, '_').singularize.classify.gsub(/^/, 'Landable::').constantize
|
3
3
|
klass.destroy_all
|
4
4
|
|
@@ -14,7 +14,7 @@ Given 'there are 3 templates' do
|
|
14
14
|
FactoryGirl.create_list(:template, number_needed)
|
15
15
|
end
|
16
16
|
|
17
|
-
Given
|
17
|
+
Given(/^an author "([^"]+)"$/) do |username|
|
18
18
|
create :author, username: username
|
19
19
|
end
|
20
20
|
|
@@ -30,33 +30,33 @@ Given "there is another author's access token in the database" do
|
|
30
30
|
@foreign_access_token = create :access_token, author: create(:author)
|
31
31
|
end
|
32
32
|
|
33
|
-
Given
|
33
|
+
Given(/^an? (page|theme|asset|template)$/) do |model|
|
34
34
|
instance_variable_set :"@#{model}", create(model.to_sym)
|
35
35
|
end
|
36
36
|
|
37
|
-
Given
|
37
|
+
Given(/^a (page|theme) with an asset attached$/) do |model|
|
38
38
|
record = create model.to_sym
|
39
39
|
@asset = create :asset
|
40
40
|
record.assets.push @asset
|
41
41
|
instance_variable_set :"@#{model}", record
|
42
42
|
end
|
43
43
|
|
44
|
-
Given
|
45
|
-
create :page, path: path, body:
|
44
|
+
Given(/^a page "([^"]+)"$/) do |path|
|
45
|
+
create :page, path: path, body: '<HTML>BODY</HTML>'
|
46
46
|
end
|
47
47
|
|
48
|
-
Given
|
49
|
-
create :page, path: path, title: title, body:
|
48
|
+
Given(/^a page "([^"]+)" with title "(.+)"$/) do |path, title|
|
49
|
+
create :page, path: path, title: title, body: '<HTML>BODY</HTML>'
|
50
50
|
end
|
51
51
|
|
52
|
-
Given
|
52
|
+
Given(/^a "(\w+)" page with title "(.+)" and category "(.+)"$/) do |published, title, category|
|
53
53
|
category_obj = Landable::Category.where('lower(name) = ?', category.downcase).first
|
54
54
|
@page = create :page, title: title, category: category_obj
|
55
55
|
@page.publish! author: create(:author) if published == 'published'
|
56
56
|
end
|
57
57
|
|
58
58
|
Given 'page "$path" redirects to "$url" with status $code' do |path, url, code|
|
59
|
-
page = create :page, :redirect, path: path, redirect_url: url, status_code: code, body:
|
59
|
+
page = create :page, :redirect, path: path, redirect_url: url, status_code: code, body: 'BODY'
|
60
60
|
page.publish! author: create(:author)
|
61
61
|
end
|
62
62
|
|
@@ -68,9 +68,9 @@ end
|
|
68
68
|
Given 'a published page "$path" with status $code' do |path, code|
|
69
69
|
code = Integer(code)
|
70
70
|
page = case code
|
71
|
-
when 301, 302 then create :page, :redirect, path: path, status_code: code, body:
|
72
|
-
when 410 then create :page, :gone, path: path, body:
|
73
|
-
else create :page, path: path, body:
|
71
|
+
when 301, 302 then create :page, :redirect, path: path, status_code: code, body: 'BODY'
|
72
|
+
when 410 then create :page, :gone, path: path, body: 'BODY'
|
73
|
+
else create :page, path: path, body: 'BODY'
|
74
74
|
end
|
75
75
|
page.publish! author: create(:author)
|
76
76
|
end
|
@@ -105,7 +105,7 @@ When(/^I change the page to a (\d+)$/) do |code|
|
|
105
105
|
@page.save!
|
106
106
|
end
|
107
107
|
|
108
|
-
Then
|
108
|
+
Then(/^there should be (\d+) ([\w\s]+) in the database$/) do |count, kind|
|
109
109
|
name = kind.gsub(/\s+/, '_').classify
|
110
110
|
klass = "Landable::#{name}".constantize
|
111
111
|
klass.count.should eql(Integer(count))
|
@@ -119,9 +119,9 @@ Given 'an author "$username" does not exist' do |username|
|
|
119
119
|
Landable::Author.where(username: username).present?.should be_false
|
120
120
|
end
|
121
121
|
|
122
|
-
Then
|
122
|
+
Then(/^the author "(.+?)" should have (\d+) access tokens?$/) do |username, n|
|
123
123
|
author = Landable::Author.where(username: username).first!
|
124
|
-
author.access_tokens.count.should
|
124
|
+
author.access_tokens.count.should eq Integer(n)
|
125
125
|
end
|
126
126
|
|
127
127
|
Then 'the response body should include the body of page "$path"' do |path|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
Given 'the asset URI prefix is "$uri"' do |uri|
|
2
2
|
# Kinda bogus, but makes explicit tests significantly easier
|
3
3
|
Landable::Asset.stub(:url_generator) do
|
4
|
-
proc
|
4
|
+
proc do |asset|
|
5
5
|
uri = "#{uri}/" unless uri.ends_with?('/')
|
6
6
|
"#{uri}#{asset.data}"
|
7
|
-
|
7
|
+
end
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
Given
|
12
|
-
@page = Landable::Page.new(title:
|
11
|
+
Given(/^a page under test$/) do
|
12
|
+
@page = Landable::Page.new(title: 'Page Under Test')
|
13
13
|
end
|
14
14
|
|
15
15
|
Given "the page's body is \"$body\"" do |body|
|
@@ -31,13 +31,13 @@ Given "the page's head tag is \"$tag\"" do |tag|
|
|
31
31
|
@page.head_content = tag
|
32
32
|
end
|
33
33
|
|
34
|
-
Given
|
34
|
+
Given 'the page uses a theme with the body:' do |body|
|
35
35
|
@page.theme ||= Landable::Theme.new
|
36
36
|
@theme ||= @page.theme
|
37
37
|
@page.theme.body = body
|
38
38
|
end
|
39
39
|
|
40
|
-
Given
|
40
|
+
Given 'these assets:' do |table|
|
41
41
|
table.hashes.each do |attrs|
|
42
42
|
create :asset, attrs
|
43
43
|
end
|
@@ -59,7 +59,7 @@ Given 'the template "$template_slug" with the body:' do |template_slug, template
|
|
59
59
|
@template = Landable::Template.create! name: template_slug, slug: template_slug, body: template_body, description: template_slug
|
60
60
|
end
|
61
61
|
|
62
|
-
When
|
62
|
+
When 'the template "$published_variable" been published' do |published_variable|
|
63
63
|
if published_variable == 'has'
|
64
64
|
@template.publish! author: create(:author), notes: 'initial revision', is_minor: true
|
65
65
|
end
|
@@ -86,5 +86,5 @@ end
|
|
86
86
|
Then 'the rendered content should be:' do |body|
|
87
87
|
@responder ||= nil
|
88
88
|
@rendered_content ||= Landable::RenderService.call(@page, responder: @responder)
|
89
|
-
@rendered_content.strip.should
|
89
|
+
@rendered_content.strip.should eq body.strip
|
90
90
|
end
|
@@ -18,22 +18,22 @@ When 'I change the theme to contain "$body"' do |body|
|
|
18
18
|
@page.save
|
19
19
|
end
|
20
20
|
|
21
|
-
And
|
21
|
+
And "I GET '/pubbed'" do
|
22
22
|
make_request
|
23
23
|
end
|
24
24
|
|
25
|
-
Then 'I should see "$body"' do |
|
25
|
+
Then 'I should see "$body"' do |_body|
|
26
26
|
@page.reload
|
27
27
|
last_response.body.should include(@page.theme.body)
|
28
28
|
end
|
29
29
|
|
30
|
-
When
|
30
|
+
When 'I publish the page with another theme' do
|
31
31
|
@page.theme = @new_theme
|
32
32
|
@page.save
|
33
33
|
@page.publish! author: create(:author)
|
34
34
|
end
|
35
35
|
|
36
|
-
When
|
36
|
+
When(/^I publish the page$/) do
|
37
37
|
@page.publish! author: create(:author)
|
38
38
|
end
|
39
39
|
|
data/features/support/env.rb
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
5
|
# files.
|
6
6
|
|
7
|
-
ENV[
|
7
|
+
ENV['RAILS_ENV'] ||= 'test'
|
8
8
|
require 'simplecov'
|
9
9
|
SimpleCov.start 'rails'
|
10
10
|
|
11
|
-
require File.expand_path(
|
12
|
-
ENV[
|
11
|
+
require File.expand_path('../../../spec/dummy/config/environment.rb', __FILE__)
|
12
|
+
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '../../../spec/dummy'
|
13
13
|
|
14
14
|
require 'cucumber/rails'
|
15
15
|
require 'cucumber/rspec/doubles'
|
@@ -42,14 +42,14 @@ ActionController::Base.allow_rescue = false
|
|
42
42
|
begin
|
43
43
|
DatabaseCleaner.strategy = :transaction
|
44
44
|
rescue NameError
|
45
|
-
raise
|
45
|
+
raise 'You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it.'
|
46
46
|
end
|
47
47
|
|
48
48
|
# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
|
49
49
|
# See the DatabaseCleaner documentation for details. Example:
|
50
50
|
#
|
51
51
|
# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
52
|
-
# # { :
|
52
|
+
# # { except: [:widgets] } may not do what you expect here
|
53
53
|
# # as tCucumber::Rails::Database.javascript_strategy overrides
|
54
54
|
# # this setting.
|
55
55
|
# DatabaseCleaner.strategy = :truncation
|
data/landable.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
|
-
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
# Maintain your gem's version:
|
7
7
|
require 'landable/version'
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.summary = 'Mountable CMS engine for Rails'
|
22
22
|
gem.description = 'Landing page storage, rendering, tracking, and management API'
|
23
23
|
|
24
|
-
gem.files = `git ls-files`.split(
|
24
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
25
25
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
26
26
|
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
27
27
|
|
@@ -10,11 +10,11 @@ module Landable
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def source_root
|
13
|
-
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
|
13
|
+
@source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'landable', generator_name, 'templates'))
|
14
14
|
end
|
15
15
|
|
16
16
|
def target_root
|
17
|
-
File.expand_path(Rails.root.join(
|
17
|
+
File.expand_path(Rails.root.join('app', 'assets'))
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -77,6 +77,6 @@ end
|
|
77
77
|
|
78
78
|
# Configure asset uploads. Assets will be uploaded to public/uploads by default.
|
79
79
|
# More configuration options: https://github.com/carrierwaveuploader/carrierwave#using-amazon-s3
|
80
|
-
CarrierWave.configure do |
|
80
|
+
CarrierWave.configure do |_config|
|
81
81
|
# config.asset_host = 'http://cdn.myapp.com'
|
82
82
|
end
|
data/lib/landable.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'landable/version'
|
2
|
-
require
|
2
|
+
require 'landable/engine'
|
3
3
|
require 'landable/liquid'
|
4
|
-
require
|
4
|
+
require 'landable/error'
|
5
5
|
require 'landable/mime_types'
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
6
|
+
require 'landable/inflections'
|
7
|
+
require 'landable/traffic'
|
8
|
+
require 'landable/migration'
|
9
9
|
|
10
|
-
require
|
10
|
+
require 'landable/core_ext/ipaddr'
|
11
11
|
|
12
|
-
require
|
12
|
+
require 'lookup_by'
|
13
13
|
|
14
14
|
module Landable
|
15
15
|
# This absurd configuration loading code is not intended to live long.
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Landable
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :api_url, :public_url, :amqp_configuration
|
3
|
+
attr_accessor :api_url, :public_url, :amqp_configuration, :sitemap_host
|
4
4
|
attr_writer :api_namespace, :public_namespace
|
5
5
|
attr_writer :api_host, :public_host
|
6
6
|
attr_writer :categories
|
7
7
|
attr_writer :screenshots_enabled
|
8
8
|
attr_writer :traffic_enabled
|
9
|
-
attr_writer :sitemap_exclude_categories, :sitemap_protocol, :
|
9
|
+
attr_writer :sitemap_exclude_categories, :sitemap_protocol, :sitemap_additional_paths
|
10
10
|
attr_writer :reserved_paths, :partials_to_templates, :database_schema_prefix
|
11
11
|
attr_writer :publicist_url, :audit_flags
|
12
12
|
attr_writer :blank_user_agent_string, :untracked_paths
|
@@ -18,23 +18,21 @@ module Landable
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def authenticators
|
21
|
-
@authenticators ||
|
21
|
+
@authenticators || fail('No Landable authenticator configured.')
|
22
22
|
end
|
23
23
|
|
24
24
|
def authenticators=(authenticators)
|
25
25
|
@authenticators = Array(authenticators)
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
alias_method :authenticator=, :authenticators=
|
29
29
|
|
30
30
|
def publicist_url
|
31
31
|
@publicist_url ||= 'publicist.dev'
|
32
32
|
end
|
33
33
|
|
34
34
|
def api_uri
|
35
|
-
if api_url.present?
|
36
|
-
@api_uri ||= URI(api_url)
|
37
|
-
end
|
35
|
+
@api_uri ||= URI(api_url) if api_url.present?
|
38
36
|
end
|
39
37
|
|
40
38
|
def api_host
|
@@ -46,9 +44,7 @@ module Landable
|
|
46
44
|
end
|
47
45
|
|
48
46
|
def public_uri
|
49
|
-
if public_url.present?
|
50
|
-
@public_uri ||= URI(public_url)
|
51
|
-
end
|
47
|
+
@public_uri ||= URI(public_url) if public_url.present?
|
52
48
|
end
|
53
49
|
|
54
50
|
def public_host
|
@@ -79,7 +75,7 @@ module Landable
|
|
79
75
|
'SEO' => 'Search engine optimization',
|
80
76
|
'Social' => '',
|
81
77
|
'Email' => '',
|
82
|
-
'Traditional' => ''
|
78
|
+
'Traditional' => ''
|
83
79
|
}
|
84
80
|
end
|
85
81
|
|
@@ -100,11 +96,7 @@ module Landable
|
|
100
96
|
end
|
101
97
|
|
102
98
|
def sitemap_protocol
|
103
|
-
@sitemap_protocol ||=
|
104
|
-
end
|
105
|
-
|
106
|
-
def sitemap_host
|
107
|
-
@sitemap_host
|
99
|
+
@sitemap_protocol ||= 'http'
|
108
100
|
end
|
109
101
|
|
110
102
|
def screenshots_enabled
|
@@ -116,7 +108,7 @@ module Landable
|
|
116
108
|
end
|
117
109
|
|
118
110
|
def traffic_enabled=(val)
|
119
|
-
|
111
|
+
fail(ArgumentError, 'Landable::Configuration#traffic_enabled accepts false, true, :all or :html') unless [true, false, :all, :html].include? val
|
120
112
|
@traffic_enabled = val
|
121
113
|
end
|
122
114
|
|
@@ -125,7 +117,7 @@ module Landable
|
|
125
117
|
end
|
126
118
|
|
127
119
|
def cors=(bool)
|
128
|
-
|
120
|
+
fail(ArgumentError, "Landable::Configuration#cors should be assigned 'false' to disable CORS support") if bool != false
|
129
121
|
cors.origins = []
|
130
122
|
end
|
131
123
|
|
@@ -172,7 +164,6 @@ module Landable
|
|
172
164
|
amqp_configuration[:enabled] && amqp_configuration[:messaging_service]
|
173
165
|
end
|
174
166
|
|
175
|
-
|
176
167
|
class Screenshots
|
177
168
|
attr_accessor :autorun
|
178
169
|
attr_accessor :browserstack_username, :browserstack_password
|