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
data/.rubocop.yml ADDED
@@ -0,0 +1,281 @@
1
+ Lint/AmbiguousOperator:
2
+ Enabled: true
3
+
4
+ Lint/AmbiguousRegexpLiteral:
5
+ Enabled: true
6
+
7
+ Lint/AssignmentInCondition:
8
+ Enabled: true
9
+
10
+ Lint/BlockAlignment:
11
+ Enabled: true
12
+
13
+ Lint/Debugger:
14
+ Enabled: true
15
+ Exclude:
16
+ - features/step_definitions/debug_steps.rb
17
+
18
+ Lint/DeprecatedClassMethods:
19
+ Enabled: true
20
+
21
+ Lint/Eval:
22
+ Enabled: true
23
+
24
+ Lint/LiteralInInterpolation:
25
+ Enabled: true
26
+
27
+ Lint/ShadowingOuterLocalVariable:
28
+ Enabled: true
29
+
30
+ Lint/StringConversionInInterpolation:
31
+ Enabled: true
32
+
33
+ Lint/UnusedBlockArgument:
34
+ Enabled: true
35
+
36
+ Lint/UnusedMethodArgument:
37
+ Enabled: true
38
+
39
+ Lint/UselessAssignment:
40
+ Enabled: true
41
+
42
+ Lint/Void:
43
+ Enabled: true
44
+
45
+ Metrics/AbcSize:
46
+ Max: 391
47
+
48
+ Metrics/ClassLength:
49
+ Max: 240
50
+
51
+ Metrics/CyclomaticComplexity:
52
+ Max: 12
53
+
54
+ Metrics/LineLength:
55
+ Max: 298
56
+
57
+ Metrics/MethodLength:
58
+ Max: 224
59
+
60
+ Metrics/ModuleLength:
61
+ Max: 160
62
+ Exclude:
63
+ - spec/**/*
64
+
65
+ Metrics/PerceivedComplexity:
66
+ Max: 13
67
+
68
+ Performance/Detect:
69
+ Enabled: true
70
+
71
+ Style/AccessModifierIndentation:
72
+ Enabled: true
73
+
74
+ Style/AccessorMethodName:
75
+ Enabled: true
76
+
77
+ Style/Alias:
78
+ Enabled: true
79
+
80
+ Style/AlignHash:
81
+ Enabled: true
82
+
83
+ Style/AlignParameters:
84
+ Enabled: true
85
+
86
+ Style/AndOr:
87
+ Enabled: true
88
+
89
+ Style/BarePercentLiterals:
90
+ Enabled: true
91
+
92
+ Style/BlockDelimiters:
93
+ Enabled: true
94
+
95
+ Style/BlockEndNewline:
96
+ Enabled: true
97
+
98
+ Style/BracesAroundHashParameters:
99
+ Enabled: true
100
+
101
+ Style/CaseEquality:
102
+ Enabled: true
103
+
104
+ Style/ClassAndModuleChildren:
105
+ Enabled: true
106
+ Exclude:
107
+ - db/migrate/*
108
+
109
+ Style/ClassCheck:
110
+ Enabled: true
111
+
112
+ Style/ClassVars:
113
+ Enabled: true
114
+
115
+ Style/ColonMethodCall:
116
+ Enabled: true
117
+
118
+ Style/CommentAnnotation:
119
+ Enabled: true
120
+
121
+ Style/Documentation:
122
+ Enabled: false
123
+
124
+ Style/DotPosition:
125
+ Enabled: true
126
+
127
+ Style/DoubleNegation:
128
+ Enabled: true
129
+
130
+ Style/EmptyLines:
131
+ Enabled: true
132
+
133
+ Style/EmptyLinesAroundAccessModifier:
134
+ Enabled: true
135
+
136
+ Style/EmptyLinesAroundBlockBody:
137
+ Enabled: true
138
+
139
+ Style/EmptyLinesAroundClassBody:
140
+ Enabled: true
141
+
142
+ Style/EmptyLinesAroundMethodBody:
143
+ Enabled: true
144
+
145
+ Style/EmptyLinesAroundModuleBody:
146
+ Enabled: true
147
+
148
+ Style/FormatString:
149
+ Enabled: true
150
+
151
+ Style/GuardClause:
152
+ Enabled: true
153
+
154
+ Style/HashSyntax:
155
+ Enabled: true
156
+
157
+ Style/IfUnlessModifier:
158
+ Enabled: true
159
+
160
+ Style/IndentHash:
161
+ Enabled: true
162
+
163
+ Style/IndentationConsistency:
164
+ Enabled: true
165
+
166
+ Style/IndentationWidth:
167
+ Enabled: true
168
+
169
+ Style/Lambda:
170
+ Enabled: true
171
+
172
+ Style/MethodCallParentheses:
173
+ Enabled: true
174
+
175
+ Style/MethodDefParentheses:
176
+ Enabled: true
177
+
178
+ Style/MultilineBlockLayout:
179
+ Enabled: true
180
+
181
+ Style/MultilineOperationIndentation:
182
+ Enabled: true
183
+
184
+ Style/NegatedIf:
185
+ Enabled: true
186
+
187
+ Style/NilComparison:
188
+ Enabled: true
189
+
190
+ Style/Not:
191
+ Enabled: true
192
+
193
+ Style/PercentLiteralDelimiters:
194
+ Enabled: true
195
+
196
+ Style/PerlBackrefs:
197
+ Enabled: true
198
+
199
+ Style/PredicateName:
200
+ Enabled: true
201
+
202
+ Style/RaiseArgs:
203
+ Enabled: true
204
+
205
+ Style/RedundantBegin:
206
+ Enabled: true
207
+
208
+ Style/RedundantSelf:
209
+ Enabled: true
210
+
211
+ Style/RegexpLiteral:
212
+ Enabled: true
213
+
214
+ Style/RescueModifier:
215
+ Enabled: true
216
+
217
+ Style/SignalException:
218
+ Enabled: true
219
+
220
+ Style/SingleSpaceBeforeFirstArg:
221
+ Enabled: true
222
+
223
+ Style/SpaceAfterColon:
224
+ Enabled: true
225
+
226
+ Style/SpaceAfterComma:
227
+ Enabled: true
228
+
229
+ Style/SpaceAroundEqualsInParameterDefault:
230
+ Enabled: true
231
+
232
+ Style/SpaceAroundOperators:
233
+ Enabled: true
234
+
235
+ Style/SpaceBeforeBlockBraces:
236
+ Enabled: true
237
+
238
+ Style/SpaceBeforeModifierKeyword:
239
+ Enabled: true
240
+
241
+ Style/SpaceInsideBlockBraces:
242
+ Enabled: true
243
+
244
+ Style/SpaceInsideBrackets:
245
+ Enabled: true
246
+
247
+ Style/SpaceInsideHashLiteralBraces:
248
+ Enabled: true
249
+
250
+ Style/SpaceInsideParens:
251
+ Enabled: true
252
+
253
+ Style/SpecialGlobalVars:
254
+ Enabled: true
255
+
256
+ Style/StringLiterals:
257
+ Enabled: true
258
+
259
+ Style/StringLiteralsInInterpolation:
260
+ Enabled: true
261
+
262
+ Style/Tab:
263
+ Enabled: true
264
+
265
+ Style/TrailingBlankLines:
266
+ Enabled: true
267
+
268
+ Style/TrailingComma:
269
+ Enabled: true
270
+
271
+ Style/TrailingWhitespace:
272
+ Enabled: true
273
+
274
+ Style/TrivialAccessors:
275
+ Enabled: true
276
+
277
+ Style/VariableInterpolation:
278
+ Enabled: true
279
+
280
+ Style/WordArray:
281
+ MinSize: 11
data/.travis.yml CHANGED
@@ -7,7 +7,6 @@ env:
7
7
  - RAILS_VERSION=4.1.1
8
8
 
9
9
  rvm:
10
- - 1.9.3-p448
11
10
  - 2.0.0-p247
12
11
  - 2.1.2
13
12
 
data/CHANGELOG.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  See README.md before updating this file.
4
4
 
5
- ## Unreleased [#](https://github.com/enova/landable/compare/v1.13.0...v1.13.1)
5
+ ## Unreleased [#](https://github.com/enova/landable/compare/v1.13.2...master)
6
+
7
+ ## 1.13.2 [#](https://github.com/enova/landable/compare/v1.13.1...v1.13.2)
8
+ * Bugfix: Fix landable traffic errors
9
+ * Remove support for Ruby < 2.0.0
6
10
 
7
11
  ## 1.13.1 [#](https://github.com/enova/landable/compare/v1.12.3...v1.13.1)
8
12
  * BugFix: Default referer.path to '' [#60]
data/Gemfile CHANGED
@@ -1,17 +1,16 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
3
  # load dependencies from landable.gemspec
4
4
  gemspec
5
5
 
6
6
  # allow us to load up a specific version of rails, since the gemspec is
7
7
  # concerned only with compatibility (see bin/test)
8
- if ENV.key? 'RAILS_VERSION'
9
- gem 'rails', ENV['RAILS_VERSION']
10
- end
8
+ gem 'rails', ENV['RAILS_VERSION'] if ENV.key? 'RAILS_VERSION'
11
9
 
12
10
  # development/test dependencies, and anything else that doesn't belong or fit
13
11
  # in the gemspec
14
12
  group :test do
13
+ gem 'rubocop'
15
14
  gem 'minitest'
16
15
  gem 'shoulda-matchers'
17
16
  gem 'cucumber-rails', require: false
data/README.md CHANGED
@@ -49,6 +49,8 @@ Run `./script/redb` to refresh the dummy app's database.
49
49
 
50
50
  Run the test suite with `rake landable`.
51
51
 
52
+ We use [Rubocop](https://github.com/bbatsov/rubocop), so your test must all pass Rubocops Tests in order for your PR to be accepted!
53
+
52
54
  ## Contributing
53
55
  Contributions are welcome - submit a pull request.
54
56
 
data/Rakefile CHANGED
@@ -1,10 +1,11 @@
1
1
  begin
2
2
  require 'bundler/setup'
3
+ require 'rubocop/rake_task'
3
4
  rescue LoadError
4
5
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
6
  end
6
7
 
7
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
8
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
8
9
  load 'rails/tasks/engine.rake'
9
10
 
10
11
  Bundler::GemHelper.install_tasks
@@ -12,10 +13,12 @@ Bundler::GemHelper.install_tasks
12
13
  Dir.glob(File.expand_path('../lib/tasks/landable/*.rake', __FILE__)).each { |f| load f }
13
14
 
14
15
  desc 'Landable test suite'
15
- task :landable => [
16
+ task landable: [
17
+ 'rubocop',
16
18
  'app:db:test:prepare',
17
19
  'landable:seed',
18
20
  'landable:spec',
19
21
  'landable:cucumber',
20
22
  'landable:pgtap'
21
- ]
23
+ ]
24
+ RuboCop::RakeTask.new
@@ -4,35 +4,35 @@ module Landable
4
4
  module VariablesConcern
5
5
  # includes
6
6
  extend ActiveSupport::Concern
7
-
7
+
8
8
  included do
9
9
  # attribute definitions
10
10
  cattr_accessor :imported_variables do
11
11
  {}
12
12
  end
13
13
  end
14
-
14
+
15
15
  # standard methods
16
-
16
+
17
17
  # custom methods
18
18
  module ClassMethods
19
19
  def register_landable_variable(variable_name, method_name = nil)
20
20
  method_name ||= variable_name
21
-
21
+
22
22
  imported_variables[variable_name] = method_name
23
23
  end
24
24
  end
25
-
25
+
26
26
  def fetch_landable_variables
27
27
  variables = {}
28
-
29
- imported_variables.each do |variable_name, method_name|
28
+
29
+ imported_variables.each do |variable_name, method_name|
30
30
  variables[variable_name] = send(method_name)
31
31
  end
32
32
 
33
33
  variables.with_indifferent_access
34
34
  end
35
-
35
+
36
36
  # end
37
37
  end
38
- end
38
+ end
@@ -1,4 +1,4 @@
1
- require_dependency "landable/api_controller"
1
+ require_dependency 'landable/api_controller'
2
2
 
3
3
  module Landable
4
4
  module Api
@@ -33,16 +33,15 @@ module Landable
33
33
  head :unauthorized
34
34
  end
35
35
 
36
-
37
36
  private
38
37
 
39
- def find_own_access_token(id = params[:id])
40
- current_author.access_tokens.fresh.find(id)
41
- end
38
+ def find_own_access_token(id = params[:id])
39
+ current_author.access_tokens.fresh.find(id)
40
+ end
42
41
 
43
- def asset_token_params
44
- params.require(:access_token).permit(:username, :password)
45
- end
42
+ def asset_token_params
43
+ params.require(:access_token).permit(:username, :password)
44
+ end
46
45
  end
47
46
  end
48
47
  end
@@ -6,30 +6,31 @@ module Landable
6
6
  class AssetsController < ApiController
7
7
  # filters
8
8
  before_filter :load_asset, except: [:create, :index]
9
-
9
+
10
10
  # RESTful methods
11
11
  def create
12
12
  asset = Asset.new(asset_params)
13
+ original = asset.duplicate_of
13
14
 
14
- if original = asset.duplicate_of
15
+ if original
15
16
  head :moved_permanently, location: asset_url(original)
16
17
  return
17
18
  end
18
-
19
+
19
20
  Asset.transaction do
20
21
  asset.author = current_author
21
22
  asset.save!
22
23
  end
23
-
24
+
24
25
  respond_with asset, status: :created, location: asset_url(asset)
25
26
  end
26
-
27
+
27
28
  def destroy
28
29
  @asset.try(:deactivate)
29
-
30
+
30
31
  respond_with @asset
31
32
  end
32
-
33
+
33
34
  def index
34
35
  search = Landable::AssetSearchEngine.new(search_params.merge(ids: params[:ids]))
35
36
  respond_with search.results, meta: search.meta
@@ -37,37 +38,39 @@ module Landable
37
38
 
38
39
  def reactivate
39
40
  @asset.try(:reactivate)
40
-
41
+
41
42
  respond_with @asset
42
43
  end
43
-
44
+
44
45
  def show
45
46
  respond_with @asset
46
47
  end
47
-
48
+
48
49
  def update
49
50
  @asset.update_attributes!(asset_params)
50
51
 
51
52
  respond_with @asset
52
53
  end
53
-
54
+
54
55
  # custom methods
56
+
55
57
  private
56
- def asset_params
57
- params.require(:asset).permit(:id, :name, :description, :data, :file)
58
- end
59
-
60
- def load_asset
61
- @asset = Asset.find(params[:id])
62
- end
63
-
64
- def search_params
65
- @search_params ||=
66
- begin
67
- hash = params.permit(search: [:name])
68
- hash[:search] || {}
69
- end
70
- end
58
+
59
+ def asset_params
60
+ params.require(:asset).permit(:id, :name, :description, :data, :file)
61
+ end
62
+
63
+ def load_asset
64
+ @asset = Asset.find(params[:id])
65
+ end
66
+
67
+ def search_params
68
+ @search_params ||=
69
+ begin
70
+ hash = params.permit(search: [:name])
71
+ hash[:search] || {}
72
+ end
73
+ end
71
74
  end
72
75
  end
73
76
  end