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
@@ -5,43 +5,43 @@ module Landable
|
|
5
5
|
module Traffic
|
6
6
|
class Tracker
|
7
7
|
TRACKING_PARAMS = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
8
|
+
'ad_type' => %w(ad_type adtype),
|
9
|
+
'ad_group' => %w(ad_group adgroup ovadgrpid ysmadgrpid),
|
10
|
+
'bid_match_type' => %w(bidmatchtype bid_match_type bmt),
|
11
|
+
'campaign' => %w(campaign utm_campaign ovcampgid ysmcampgid),
|
12
|
+
'content' => %w(content utm_content),
|
13
|
+
'creative' => %w(creative adid ovadid),
|
14
|
+
'device_type' => %w(device_type devicetype device),
|
15
|
+
'click_id' => %w(gclid click_id clickid),
|
16
|
+
'experiment' => %w(experiment aceid),
|
17
|
+
'keyword' => %w(keyword kw utm_term ovkey ysmkey),
|
18
|
+
'match_type' => %w(match_type matchtype match ovmtc ysmmtc),
|
19
|
+
'medium' => %w(medium utm_medium),
|
20
|
+
'network' => %w(network),
|
21
|
+
'placement' => %w(placement),
|
22
|
+
'position' => %w(position adposition ad_position),
|
23
|
+
'search_term' => %w(search_term searchterm q querystring ovraw ysmraw),
|
24
|
+
'source' => %w(source utm_source),
|
25
|
+
'target' => %w(target)
|
26
26
|
}.freeze
|
27
27
|
|
28
28
|
TRACKING_KEYS = TRACKING_PARAMS.values.flatten.freeze
|
29
|
-
ATTRIBUTION_KEYS = TRACKING_PARAMS.except(
|
29
|
+
ATTRIBUTION_KEYS = TRACKING_PARAMS.except('click_id').keys
|
30
30
|
|
31
31
|
TRACKING_PARAMS_TRANSFORM = {
|
32
|
-
|
32
|
+
'ad_type' => { 'pe' => 'product_extensions',
|
33
33
|
'pla' => 'product_listing' },
|
34
34
|
|
35
|
-
|
35
|
+
'bid_match_type' => { 'bb' => 'bidded broad',
|
36
36
|
'bc' => 'bidded content',
|
37
37
|
'be' => 'bidded exact',
|
38
38
|
'bp' => 'bidded phrase' },
|
39
39
|
|
40
|
-
|
40
|
+
'device_type' => { 'c' => 'computer',
|
41
41
|
'm' => 'mobile',
|
42
42
|
't' => 'tablet' },
|
43
43
|
|
44
|
-
|
44
|
+
'match_type' => { 'b' => 'broad',
|
45
45
|
'c' => 'content',
|
46
46
|
'e' => 'exact',
|
47
47
|
'p' => 'phrase',
|
@@ -49,9 +49,9 @@ module Landable
|
|
49
49
|
'adv' => 'advanced',
|
50
50
|
'cnt' => 'content' },
|
51
51
|
|
52
|
-
|
52
|
+
'network' => { 'g' => 'google_search',
|
53
53
|
's' => 'search_partner',
|
54
|
-
'd' => 'display_network' }
|
54
|
+
'd' => 'display_network' }
|
55
55
|
}.freeze
|
56
56
|
|
57
57
|
UUID_REGEX = /\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\Z/
|
@@ -75,7 +75,7 @@ module Landable
|
|
75
75
|
class << self
|
76
76
|
def for(controller)
|
77
77
|
type = controller.request.user_agent.presence && Landable::Traffic::UserAgent[controller.request.user_agent].user_agent_type
|
78
|
-
type = 'noop' if Landable.configuration.traffic_enabled == :html
|
78
|
+
type = 'noop' if Landable.configuration.traffic_enabled == :html && !controller.request.format.html?
|
79
79
|
type = 'user' if type.nil?
|
80
80
|
type = 'user' if controller.request.query_parameters.with_indifferent_access.slice(*TRACKING_KEYS).any?
|
81
81
|
|
@@ -85,13 +85,13 @@ module Landable
|
|
85
85
|
|
86
86
|
def initialize(controller)
|
87
87
|
# Allow subclasses to super from initialize
|
88
|
-
|
88
|
+
fail NotImplementedError, 'You must subclass Tracker' if self.class == Tracker
|
89
89
|
@controller = controller
|
90
90
|
@start_time = Time.now
|
91
91
|
end
|
92
92
|
|
93
93
|
def track
|
94
|
-
|
94
|
+
fail NotImplementedError, 'You must subclass Tracker' if self.class == Tracker
|
95
95
|
end
|
96
96
|
|
97
97
|
def visitor_id
|
@@ -101,7 +101,6 @@ module Landable
|
|
101
101
|
|
102
102
|
def create_event(type, meta = {})
|
103
103
|
return unless @visit_id
|
104
|
-
|
105
104
|
Event.create(visit_id: @visit_id, event_type: type, meta: meta)
|
106
105
|
end
|
107
106
|
|
@@ -118,23 +117,25 @@ module Landable
|
|
118
117
|
end
|
119
118
|
|
120
119
|
def landing_path
|
121
|
-
@visit_id
|
120
|
+
@visit_id && PageView.where(visit_id: @visit_id).order(:page_view_id).first.try(:path)
|
122
121
|
end
|
123
122
|
|
123
|
+
# TODO: Is this used in multiple applications outside Landable. If not,
|
124
|
+
# then lets get rid of this method.
|
125
|
+
# rubocop:disable Style/AccessorMethodName
|
124
126
|
def get_user_agent
|
125
127
|
user_agent
|
126
128
|
end
|
127
129
|
|
128
|
-
|
130
|
+
protected
|
131
|
+
|
129
132
|
def cookies
|
130
133
|
request.cookie_jar
|
131
134
|
end
|
132
135
|
|
133
136
|
def cookie
|
134
137
|
validate_cookie
|
135
|
-
|
136
138
|
@cookie_id ||= Cookie.create.id
|
137
|
-
|
138
139
|
set_cookie
|
139
140
|
end
|
140
141
|
|
@@ -155,9 +156,8 @@ module Landable
|
|
155
156
|
end
|
156
157
|
|
157
158
|
def do_not_track
|
158
|
-
return unless headers[
|
159
|
-
|
160
|
-
headers["DNT"] == "1"
|
159
|
+
return unless headers['DNT']
|
160
|
+
headers['DNT'] == '1'
|
161
161
|
end
|
162
162
|
|
163
163
|
def user_agent
|
@@ -172,10 +172,14 @@ module Landable
|
|
172
172
|
attribution = Attribution.lookup params.slice(*ATTRIBUTION_KEYS)
|
173
173
|
query = params.except(*ATTRIBUTION_KEYS)
|
174
174
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
175
|
+
begin
|
176
|
+
@referer = Referer.where(domain_id: Domain[referer_uri.host],
|
177
|
+
path_id: Path[referer_uri_path],
|
178
|
+
query_string_id: QueryString[query.to_query],
|
179
|
+
attribution_id: attribution.id).first_or_create
|
180
|
+
rescue ActiveRecord::RecordNotUnique
|
181
|
+
retry
|
182
|
+
end
|
179
183
|
end
|
180
184
|
|
181
185
|
def ip_address
|
@@ -254,7 +258,6 @@ module Landable
|
|
254
258
|
|
255
259
|
def visit_stale?
|
256
260
|
return false unless @last_visit_time
|
257
|
-
|
258
261
|
Time.current - @last_visit_time > 30.minutes
|
259
262
|
end
|
260
263
|
|
@@ -262,13 +265,13 @@ module Landable
|
|
262
265
|
hash = {}
|
263
266
|
|
264
267
|
TRACKING_PARAMS.each do |key, names|
|
265
|
-
|
268
|
+
param = names.find { |name| params.key?(name) }
|
269
|
+
next unless param
|
266
270
|
hash[key] = params[param]
|
267
271
|
end
|
268
272
|
|
269
273
|
TRACKING_PARAMS_TRANSFORM.each do |key, transform|
|
270
274
|
next unless hash.key? key
|
271
|
-
|
272
275
|
hash[key] = transform[hash[key]] if transform.key? hash[key]
|
273
276
|
end
|
274
277
|
|
@@ -297,6 +300,8 @@ module Landable
|
|
297
300
|
|
298
301
|
def visitor
|
299
302
|
@visitor ||= Visitor.with_ip_address(ip_address).with_user_agent(user_agent).first_or_create
|
303
|
+
rescue ActiveRecord::RecordNotUnique
|
304
|
+
retry
|
300
305
|
end
|
301
306
|
|
302
307
|
def visit
|
@@ -28,23 +28,20 @@ module Landable
|
|
28
28
|
p.query_string = untracked_parameters.to_query
|
29
29
|
p.request_id = request.uuid
|
30
30
|
|
31
|
-
p.click_id = tracking_parameters[
|
31
|
+
p.click_id = tracking_parameters['click_id']
|
32
32
|
|
33
33
|
p.http_status = response.status
|
34
34
|
|
35
35
|
p.visit_id = @visit_id
|
36
|
-
|
37
|
-
p.created_at =
|
38
|
-
|
39
|
-
p.response_time = ( Time.now - @start_time ) * 1000
|
36
|
+
current_time = Time.now
|
37
|
+
p.created_at = current_time
|
38
|
+
p.response_time = (current_time - @start_time) * 1000
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
42
|
def save
|
44
43
|
p = record_page_view
|
45
|
-
if Landable.configuration.amqp_service_enabled
|
46
|
-
EventPublisher.publish(p)
|
47
|
-
end
|
44
|
+
EventPublisher.publish(p) if Landable.configuration.amqp_service_enabled
|
48
45
|
|
49
46
|
session[:landable] = {
|
50
47
|
KEYS[:visit_id] => @visit_id,
|
@@ -58,12 +55,20 @@ module Landable
|
|
58
55
|
|
59
56
|
def identify(identifier)
|
60
57
|
visit = Visit.find(@visit_id)
|
61
|
-
|
58
|
+
begin
|
59
|
+
owner = Owner.where(owner: identifier).first_or_create
|
60
|
+
rescue ActiveRecord::RecordNotUnique
|
61
|
+
retry
|
62
|
+
end
|
62
63
|
|
63
64
|
visit.owner = owner
|
64
65
|
visit.save!
|
65
66
|
|
66
|
-
|
67
|
+
begin
|
68
|
+
Ownership.where(cookie_id: @cookie_id, owner: owner).first_or_create
|
69
|
+
rescue ActiveRecord::RecordNotUnique
|
70
|
+
retry
|
71
|
+
end
|
67
72
|
end
|
68
73
|
end
|
69
74
|
end
|
data/lib/landable/version.rb
CHANGED
data/lib/schema_moves.rb
CHANGED
@@ -3,9 +3,9 @@ module SchemaMoves
|
|
3
3
|
def create_schema(schema)
|
4
4
|
connection = ActiveRecord::Base.connection
|
5
5
|
|
6
|
-
sql = %
|
6
|
+
sql = %(
|
7
7
|
CREATE SCHEMA #{schema};
|
8
|
-
|
8
|
+
)
|
9
9
|
puts "Creating #{schema} schema"
|
10
10
|
connection.execute sql
|
11
11
|
end
|
@@ -13,9 +13,9 @@ module SchemaMoves
|
|
13
13
|
def drop_schema(schema)
|
14
14
|
connection = ActiveRecord::Base.connection
|
15
15
|
|
16
|
-
sql = %
|
16
|
+
sql = %(
|
17
17
|
DROP SCHEMA #{schema};
|
18
|
-
|
18
|
+
)
|
19
19
|
puts "Dropping #{schema} schema"
|
20
20
|
connection.execute sql
|
21
21
|
end
|
@@ -35,10 +35,10 @@ module SchemaMoves
|
|
35
35
|
")
|
36
36
|
|
37
37
|
objects.each do |object|
|
38
|
-
sql = %
|
38
|
+
sql = %(
|
39
39
|
ALTER #{object_type} #{from_schema}.#{object['relname']}
|
40
40
|
SET SCHEMA #{to_schema}
|
41
|
-
|
41
|
+
)
|
42
42
|
puts "Moving #{from_schema}.#{object['relname']} TO #{to_schema}"
|
43
43
|
connection.execute sql
|
44
44
|
end
|
@@ -129,7 +129,7 @@ module SchemaMoves
|
|
129
129
|
BEFORE UPDATE OF notes, is_minor, page_id, author_id, created_at, ordinal ON #{new_schema}.page_revisions
|
130
130
|
FOR EACH STATEMENT EXECUTE PROCEDURE #{new_schema}.tg_disallow();
|
131
131
|
}
|
132
|
-
puts
|
132
|
+
puts 'Creating new triggers...'
|
133
133
|
connection.execute sql
|
134
134
|
end
|
135
135
|
|
@@ -148,7 +148,7 @@ module SchemaMoves
|
|
148
148
|
DROP FUNCTION IF EXISTS #{old_schema}.template_revision_ordinal();
|
149
149
|
DROP FUNCTION IF EXISTS #{old_schema}.tg_disallow();
|
150
150
|
}
|
151
|
-
puts
|
151
|
+
puts 'Dropping old triggers...'
|
152
152
|
connection.execute sql
|
153
153
|
end
|
154
154
|
|
@@ -158,14 +158,13 @@ module SchemaMoves
|
|
158
158
|
|
159
159
|
def get_schema_names(new = true)
|
160
160
|
# Always get old schemas
|
161
|
-
@old_landable = ask(
|
162
|
-
@old_traffic = ask(
|
161
|
+
@old_landable = ask('Enter the OLD main landable schema: ') { |q| q.default = 'landable' }
|
162
|
+
@old_traffic = ask('Enter the OLD traffic schema: ') { |q| q.default = 'landable_traffic' }
|
163
163
|
|
164
164
|
# Only ask for new names if new == true
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
end
|
165
|
+
return unless new
|
166
|
+
@new_landable = ask('Enter the NEW main landable schema: ') { |q| q.default = "#{appname}_landable" }
|
167
|
+
@new_traffic = ask('Enter the NEW traffic schema: ') { |q| q.default = "#{appname}_landable_traffic" }
|
169
168
|
end
|
170
169
|
|
171
170
|
def create_schemas
|
@@ -195,8 +194,8 @@ module SchemaMoves
|
|
195
194
|
|
196
195
|
def want_to_drop_old_schemas?
|
197
196
|
drop = nil
|
198
|
-
until
|
199
|
-
drop = ask(
|
197
|
+
until %w(yes no).include?(drop.to_s.downcase)
|
198
|
+
drop = ask('Would you like to drop the old schemas? (Yes or No)') { |q| q.default = 'no' }
|
200
199
|
end
|
201
200
|
drop.to_s.downcase == 'yes'
|
202
201
|
end
|
@@ -1,67 +1,66 @@
|
|
1
1
|
namespace :landable do
|
2
2
|
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
3
|
-
# It is recommended to regenerate this file in the future when you upgrade to a
|
4
|
-
# newer version of cucumber-rails. Consider adding your own code to a new file
|
3
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
4
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
5
5
|
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
6
6
|
# files.
|
7
7
|
|
8
|
+
unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks
|
8
9
|
|
9
|
-
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({ ok: 'db:test:prepare' }, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
25
|
-
t.binary = vendored_cucumber_bin
|
26
|
-
t.fork = true # You may get faster startup if you set this to false
|
27
|
-
t.profile = 'wip'
|
28
|
-
end
|
23
|
+
Cucumber::Rake::Task.new({ wip: 'db:test:prepare' }, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
Cucumber::Rake::Task.new({ rerun: 'db:test:prepare' }, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
desc 'Run all features'
|
36
|
+
task all: [:ok, :wip]
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
task :statsetup do
|
39
|
+
require 'rails/code_statistics'
|
40
|
+
::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
|
41
|
+
::CodeStatistics::TEST_TYPES << 'Cucumber features' if File.exist?('features')
|
42
|
+
end
|
43
43
|
end
|
44
|
-
|
45
|
-
|
46
|
-
task :cucumber => 'cucumber:ok'
|
44
|
+
desc 'Alias for cucumber:ok'
|
45
|
+
task cucumber: 'cucumber:ok'
|
47
46
|
|
48
|
-
|
47
|
+
task default: :cucumber
|
49
48
|
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
task features: :cucumber do
|
50
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
51
|
+
end
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
# In case we don't have ActiveRecord, append a no-op task that we can depend upon.
|
54
|
+
task 'db:test:prepare' do
|
55
|
+
end
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
task stats: 'cucumber:statsetup'
|
58
|
+
rescue LoadError
|
59
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
60
|
+
task :cucumber do
|
61
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
62
|
+
end
|
63
63
|
end
|
64
|
-
end
|
65
64
|
|
66
65
|
end
|
67
|
-
end
|
66
|
+
end
|