landable 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/.rubocop.yml +281 -0
  2. data/.travis.yml +0 -1
  3. data/CHANGELOG.md +5 -1
  4. data/Gemfile +3 -4
  5. data/README.md +2 -0
  6. data/Rakefile +6 -3
  7. data/app/controllers/concerns/landable/variables_concern.rb +9 -9
  8. data/app/controllers/landable/api/access_tokens_controller.rb +7 -8
  9. data/app/controllers/landable/api/assets_controller.rb +29 -26
  10. data/app/controllers/landable/api/audits_controller.rb +6 -5
  11. data/app/controllers/landable/api/configurations_controller.rb +1 -1
  12. data/app/controllers/landable/api/directories_controller.rb +2 -2
  13. data/app/controllers/landable/api/page_revisions_controller.rb +2 -4
  14. data/app/controllers/landable/api/pages_controller.rb +39 -40
  15. data/app/controllers/landable/api/template_revisions_controller.rb +1 -2
  16. data/app/controllers/landable/api/templates_controller.rb +15 -14
  17. data/app/controllers/landable/api/themes_controller.rb +15 -14
  18. data/app/controllers/landable/api_controller.rb +10 -11
  19. data/app/controllers/landable/public/pages_controller.rb +2 -2
  20. data/app/controllers/landable/public/preview/page_revisions_controller.rb +2 -2
  21. data/app/controllers/landable/public/preview/pages_controller.rb +1 -1
  22. data/app/controllers/landable/public/sitemap_controller.rb +2 -2
  23. data/app/decorators/landable/page_decorator.rb +3 -3
  24. data/app/helpers/landable/pages_helper.rb +2 -2
  25. data/app/helpers/landable/traffic_helper.rb +2 -4
  26. data/app/models/concerns/landable/has_assets.rb +6 -9
  27. data/app/models/concerns/landable/has_templates.rb +6 -7
  28. data/app/models/concerns/landable/librarian.rb +5 -5
  29. data/app/models/concerns/landable/table_name.rb +2 -2
  30. data/app/models/landable/access_token.rb +1 -1
  31. data/app/models/landable/asset.rb +8 -8
  32. data/app/models/landable/asset_search_engine.rb +7 -8
  33. data/app/models/landable/author.rb +2 -1
  34. data/app/models/landable/category.rb +1 -3
  35. data/app/models/landable/directory.rb +2 -2
  36. data/app/models/landable/page.rb +44 -50
  37. data/app/models/landable/page_revision.rb +27 -41
  38. data/app/models/landable/page_search_engine.rb +5 -6
  39. data/app/models/landable/search_engine.rb +2 -2
  40. data/app/models/landable/template.rb +9 -11
  41. data/app/models/landable/template_revision.rb +4 -14
  42. data/app/models/landable/theme.rb +1 -1
  43. data/app/models/landable/traffic/attribution.rb +3 -1
  44. data/app/models/landable/traffic/page_view.rb +1 -1
  45. data/app/models/landable/traffic/user_agent.rb +1 -1
  46. data/app/models/landable/traffic/visit.rb +1 -1
  47. data/app/responders/landable/api_responder.rb +5 -3
  48. data/app/responders/landable/page_render_responder.rb +1 -1
  49. data/app/serializers/landable/asset_serializer.rb +1 -1
  50. data/app/serializers/landable/audit_serializer.rb +2 -3
  51. data/app/serializers/landable/directory_serializer.rb +2 -2
  52. data/app/serializers/landable/page_revision_serializer.rb +0 -1
  53. data/app/serializers/landable/page_serializer.rb +5 -5
  54. data/app/serializers/landable/template_serializer.rb +2 -2
  55. data/app/services/landable/authentication_service.rb +1 -1
  56. data/app/services/landable/registration_service.rb +3 -2
  57. data/app/services/landable/render_service.rb +16 -18
  58. data/app/services/landable/screenshot_service.rb +3 -4
  59. data/app/services/landable/tidy_service.rb +32 -37
  60. data/app/validators/path_validator.rb +1 -3
  61. data/app/validators/url_validator.rb +4 -7
  62. data/config/routes.rb +3 -6
  63. data/db/migrate/20130510221424_create_landable_schema.rb +45 -56
  64. data/db/migrate/20130909182713_landable_pages__add_updated_by.rb +2 -2
  65. data/db/migrate/20130909182715_landable_page_revisions__break_out_snapshot.rb +9 -12
  66. data/db/migrate/20131002220041_file_based_themes.rb +3 -3
  67. data/db/migrate/20131008164204_create_head_tag_on_page.rb +4 -4
  68. data/db/migrate/20131008193544_drop_status_codes_model.rb +1 -2
  69. data/db/migrate/20131028145652_add_traffic_schema.rb +5 -5
  70. data/db/migrate/20131101213623_add_dnt_column_to_visits.rb +1 -1
  71. data/db/migrate/20131106185946_add_index_on_page_revisions_path.rb +1 -1
  72. data/db/migrate/20131106193021_page_revisisons__path_status_code_index.rb +1 -1
  73. data/db/migrate/20131121150902_add_attribution_id_to_unique_index.rb +2 -2
  74. data/db/migrate/20131216214027_drop_browser_screenshot_tables.rb +3 -3
  75. data/db/migrate/20140128170659_file_backed_templates.rb +1 -1
  76. data/db/migrate/20140205193757_fix_status_codes.rb +3 -3
  77. data/db/migrate/20140220170324_add_slug_to_categories.rb +1 -1
  78. data/db/migrate/20140224205516_rename_traffic_schema.rb +7 -9
  79. data/db/migrate/20140509190128_create_template_revisions.rb +13 -15
  80. data/db/migrate/20140509192856_create_audits.rb +3 -3
  81. data/db/migrate/20140602213937_path_response_time_view.rb +20 -19
  82. data/features/step_definitions/asset_steps.rb +10 -12
  83. data/features/step_definitions/core_api_steps.rb +29 -27
  84. data/features/step_definitions/factory_steps.rb +16 -16
  85. data/features/step_definitions/html_steps.rb +1 -1
  86. data/features/step_definitions/liquid_steps.rb +8 -8
  87. data/features/step_definitions/theme_steps.rb +4 -4
  88. data/features/support/env.rb +5 -5
  89. data/landable.gemspec +2 -2
  90. data/lib/generators/landable/landable_generator.rb +2 -2
  91. data/lib/generators/templates/landable.rb +1 -1
  92. data/lib/landable.rb +7 -7
  93. data/lib/landable/configuration.rb +10 -19
  94. data/lib/landable/engine.rb +19 -19
  95. data/lib/landable/error.rb +1 -3
  96. data/lib/landable/layout.rb +6 -6
  97. data/lib/landable/liquid/asset_tags.rb +3 -5
  98. data/lib/landable/liquid/drops.rb +3 -8
  99. data/lib/landable/liquid/filters.rb +1 -3
  100. data/lib/landable/liquid/tags.rb +10 -10
  101. data/lib/landable/migration.rb +30 -30
  102. data/lib/landable/mime_types.rb +1 -1
  103. data/lib/landable/partial.rb +2 -2
  104. data/lib/landable/seeds.rb +3 -4
  105. data/lib/landable/traffic.rb +4 -8
  106. data/lib/landable/traffic/tracker.rb +48 -43
  107. data/lib/landable/traffic/user_tracker.rb +15 -10
  108. data/lib/landable/version.rb +1 -1
  109. data/lib/schema_moves.rb +15 -16
  110. data/lib/tasks/landable/cucumber.rake +46 -47
  111. data/lib/tasks/landable/data.rake +13 -14
  112. data/lib/tasks/landable/pgtap.rake +12 -18
  113. data/lib/tasks/landable/seed.rake +4 -4
  114. data/spec/concerns/landable/has_assets_spec.rb +15 -19
  115. data/spec/concerns/landable/has_templates_spec.rb +10 -13
  116. data/spec/concerns/landable/librarian.rb +4 -4
  117. data/spec/concerns/landable/table_name_spec.rb +3 -5
  118. data/spec/concerns/landable/traffic/table_name_spec.rb +2 -4
  119. data/spec/controllers/concerns/landable/variables_concern_spec.rb +11 -10
  120. data/spec/controllers/landable/api/assets_controller_spec.rb +15 -14
  121. data/spec/controllers/landable/api/audits_controller_spec.rb +104 -102
  122. data/spec/controllers/landable/api/categories_controller_spec.rb +36 -34
  123. data/spec/controllers/landable/api/configuration_controller_spec.rb +14 -12
  124. data/spec/controllers/landable/api/directories_controller_spec.rb +52 -50
  125. data/spec/controllers/landable/api/page_revisions_controller_spec.rb +20 -18
  126. data/spec/controllers/landable/api/pages_controller_spec.rb +204 -203
  127. data/spec/controllers/landable/api/template_revisions_controller_spec.rb +20 -18
  128. data/spec/controllers/landable/api/templates_controller_spec.rb +39 -37
  129. data/spec/controllers/landable/api_controller_spec.rb +24 -26
  130. data/spec/controllers/public/preview/page_revisions_controller_spec.rb +36 -34
  131. data/spec/controllers/public/preview/pages_controller_spec.rb +32 -30
  132. data/spec/controllers/public/sitemap_controller_spec.rb +19 -17
  133. data/spec/decorators/page_decorator_spec.rb +9 -9
  134. data/spec/dummy/app/helpers/application_helper.rb +1 -1
  135. data/spec/dummy/config/application.rb +5 -6
  136. data/spec/dummy/config/boot.rb +1 -1
  137. data/spec/dummy/config/environments/test.rb +1 -1
  138. data/spec/dummy/config/initializers/landable.rb +7 -6
  139. data/spec/factories/asset.rb +1 -1
  140. data/spec/factories/audit.rb +1 -1
  141. data/spec/factories/authors.rb +1 -1
  142. data/spec/factories/category.rb +1 -1
  143. data/spec/factories/pages.rb +4 -4
  144. data/spec/factories/template.rb +3 -3
  145. data/spec/factories/theme.rb +2 -2
  146. data/spec/helpers/pages_helper_spec.rb +5 -5
  147. data/spec/lib/landable/configuration_spec.rb +2 -4
  148. data/spec/lib/landable/event_publisher_spec.rb +1 -3
  149. data/spec/lib/landable/layout_spec.rb +4 -4
  150. data/spec/lib/landable/liquid_spec.rb +12 -14
  151. data/spec/lib/landable/migration_spec.rb +4 -4
  152. data/spec/lib/landable/partial_spec.rb +18 -18
  153. data/spec/lib/landable/tracking_spec.rb +27 -29
  154. data/spec/lib/landable/traffic_spec.rb +29 -33
  155. data/spec/models/landable/access_token_spec.rb +1 -1
  156. data/spec/models/landable/asset_spec.rb +9 -11
  157. data/spec/models/landable/directory_spec.rb +7 -7
  158. data/spec/models/landable/page/errors_spec.rb +1 -3
  159. data/spec/models/landable/page_revision_spec.rb +23 -24
  160. data/spec/models/landable/page_spec.rb +41 -42
  161. data/spec/models/landable/template_revision_spec.rb +3 -3
  162. data/spec/models/landable/template_spec.rb +11 -11
  163. data/spec/models/landable/theme_spec.rb +2 -2
  164. data/spec/models/landable/traffic/referer_spec.rb +3 -3
  165. data/spec/responders/page_render_responder_spec.rb +0 -2
  166. data/spec/routing/public_page_route_spec.rb +4 -5
  167. data/spec/services/landable/authentication_service_spec.rb +7 -7
  168. data/spec/services/landable/render_service_spec.rb +8 -8
  169. data/spec/services/landable/screenshot_service_spec.rb +3 -3
  170. data/spec/services/landable/tidy_service_spec.rb +20 -20
  171. data/spec/spec_helper.rb +3 -3
  172. data/spec/support/behaviors.rb +4 -4
  173. data/spec/support/helpers.rb +1 -1
  174. metadata +86 -35
  175. checksums.yaml +0 -7
@@ -5,43 +5,43 @@ module Landable
5
5
  module Traffic
6
6
  class Tracker
7
7
  TRACKING_PARAMS = {
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],
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("click_id").keys
29
+ ATTRIBUTION_KEYS = TRACKING_PARAMS.except('click_id').keys
30
30
 
31
31
  TRACKING_PARAMS_TRANSFORM = {
32
- "ad_type" => { 'pe' => 'product_extensions',
32
+ 'ad_type' => { 'pe' => 'product_extensions',
33
33
  'pla' => 'product_listing' },
34
34
 
35
- "bid_match_type" => { 'bb' => 'bidded broad',
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
- "device_type" => { 'c' => 'computer',
40
+ 'device_type' => { 'c' => 'computer',
41
41
  'm' => 'mobile',
42
42
  't' => 'tablet' },
43
43
 
44
- "match_type" => { 'b' => 'broad',
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
- "network" => { 'g' => 'google_search',
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 and not controller.request.format.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
- raise NotImplementedError, "You must subclass Tracker" if self.class == Tracker
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
- raise NotImplementedError, "You must subclass Tracker" if self.class == Tracker
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 and PageView.where(visit_id: @visit_id).order(:page_view_id).first.try(:path)
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
- protected
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["DNT"]
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
- @referer = Referer.where(domain_id: Domain[referer_uri.host],
176
- path_id: Path[referer_uri_path],
177
- query_string_id: QueryString[query.to_query],
178
- attribution_id: attribution.id).first_or_create
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
- next unless param = names.find { |name| params.key?(name) }
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["click_id"]
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
- # this is strange, yes, but is it better than a db call?
37
- p.created_at = Time.current
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
- owner = Owner.where(owner: identifier).first_or_create
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
- Ownership.where(cookie_id: @cookie_id, owner: owner).first_or_create
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
@@ -2,7 +2,7 @@ module Landable
2
2
  module VERSION
3
3
  MAJOR = 1
4
4
  MINOR = 13
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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 "Creating new triggers..."
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 "Dropping old triggers..."
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("Enter the OLD main landable schema: ") { |q| q.default = 'landable' }
162
- @old_traffic = ask("Enter the OLD traffic schema: ") { |q| q.default = 'landable_traffic' }
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
- if 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" }
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 ['yes', 'no'].include?(drop.to_s.downcase)
199
- drop = ask("Would you like to drop the old schemas? (Yes or No)") { |q| q.default = 'no' }
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
- unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
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
- vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
12
- $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
13
+ begin
14
+ require 'cucumber/rake/task'
13
15
 
14
- begin
15
- require 'cucumber/rake/task'
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
- namespace :cucumber do
18
- Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
19
- t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
20
- t.fork = true # You may get faster startup if you set this to false
21
- t.profile = 'default'
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
- Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
31
- t.binary = vendored_cucumber_bin
32
- t.fork = true # You may get faster startup if you set this to false
33
- t.profile = 'rerun'
34
- end
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
- desc 'Run all features'
37
- task :all => [:ok, :wip]
35
+ desc 'Run all features'
36
+ task all: [:ok, :wip]
38
37
 
39
- task :statsetup do
40
- require 'rails/code_statistics'
41
- ::STATS_DIRECTORIES << %w(Cucumber\ features features) if File.exist?('features')
42
- ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?('features')
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
- end
45
- desc 'Alias for cucumber:ok'
46
- task :cucumber => 'cucumber:ok'
44
+ desc 'Alias for cucumber:ok'
45
+ task cucumber: 'cucumber:ok'
47
46
 
48
- task :default => :cucumber
47
+ task default: :cucumber
49
48
 
50
- task :features => :cucumber do
51
- STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
52
- end
49
+ task features: :cucumber do
50
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
51
+ end
53
52
 
54
- # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
55
- task 'db:test:prepare' do
56
- end
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
- task :stats => 'cucumber:statsetup'
59
- rescue LoadError
60
- desc 'cucumber rake task not available (cucumber not installed)'
61
- task :cucumber do
62
- abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
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