Project

General

Profile

Revision 367f39d2

Added by Sebastian Gräßl over 5 years ago

Fixes #19694 - Align rubocop configuration with foreman-core

And fix offenses

View differences:

.rubocop.yml
1
# TODO: remove this file by either moving cops here or fixing code
2
inherit_from:
3
  - .rubocop_todo.yml
4

  
1 5
AllCops:
2
  RunRailsCops: true # always run the rails cops
6
  TargetRubyVersion: 2.0
7

  
8
Rails: # always run the rails cops
9
  Enabled: true
10

  
11
# Don't is_a? over kind_of?
12
Style/ClassCheck:
13
  Enabled: false
3 14

  
4 15
# Don't enforce documentation
5 16
Style/Documentation:
6 17
  Enabled: false
7 18

  
8
# Need to support ruby 1.8
19
# Support both ruby19 and hash_rockets
9 20
Style/HashSyntax:
10
  EnforcedStyle: hash_rockets
11

  
12
# Force before_filter until upgrade to Rails 4
13
Rails/ActionFilter:
14
  EnforcedStyle: filter
15

  
16
Metrics/LineLength:
17
  Max: 100
21
  Enabled: false
18 22

  
19
Metrics/MethodLength:
20
  Max: 20
23
Style/StringLiterals:
24
  Enabled: false
21 25

  
22
StringLiterals:
26
Style/FrozenStringLiteralComment:
23 27
  Enabled: false
24 28

  
25 29
Metrics/ClassLength:
26
  Max: 200
27

  
28
Metrics/AbcSize:
29
  Enabled: false # should we turn this on?
30

  
31
Style/MethodCalledOnDoEndBlock:
32
  Enabled: true
30
  Exclude:
31
    - 'test/**/*'
33 32

  
34
Style/DotPosition:
35
  EnforcedStyle: 'leading'
33
Performance/FixedSize:
34
  Exclude:
35
    - 'test/**/*'
36 36

  
37 37
Rails/Date:
38 38
  Exclude:
.rubocop_todo.yml
1
# This configuration was generated by
2
# `rubocop --auto-gen-config`
3
# on 2017-05-29 13:29:35 +0200 using RuboCop version 0.46.0.
4
# The point is for the user to remove these configuration records
5
# one by one as the offenses are removed from the code base.
6
# Note that changes in the inspected code, or installation of new
7
# versions of RuboCop, may require this file to be generated again.
8

  
9
# Offense count: 1
10
Lint/AmbiguousRegexpLiteral:
11
  Exclude:
12
    - 'test/functionals/api/v2/containers_controller_test.rb'
13

  
14
# Offense count: 1
15
# Cop supports --auto-correct.
16
Lint/UnifiedInteger:
17
  Exclude:
18
    - 'app/controllers/api/v2/containers_controller.rb'
19

  
20
# Offense count: 16
21
Metrics/AbcSize:
22
  Max: 30
23

  
24
# Offense count: 14
25
# Configuration parameters: CountComments.
26
Metrics/BlockLength:
27
  Max: 130
28

  
29
# Offense count: 3
30
# Configuration parameters: CountComments.
31
Metrics/ClassLength:
32
  Max: 172
33

  
34
# Offense count: 198
35
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
36
# URISchemes: http, https
37
Metrics/LineLength:
38
  Max: 181
39

  
40
# Offense count: 21
41
# Configuration parameters: CountComments.
42
Metrics/MethodLength:
43
  Max: 23
44

  
45
# Offense count: 7
46
# Cop supports --auto-correct.
47
# Configuration parameters: EnforcedStyle, SupportedStyles, Include.
48
# SupportedStyles: action, filter
49
# Include: app/controllers/**/*.rb
50
Rails/ActionFilter:
51
  Exclude:
52
    - 'app/controllers/api/v2/containers_controller.rb'
53
    - 'app/controllers/api/v2/registries_controller.rb'
54
    - 'app/controllers/containers/steps_controller.rb'
55
    - 'app/controllers/containers_controller.rb'
56
    - 'app/controllers/registries_controller.rb'
57

  
58
# Offense count: 3
59
# Cop supports --auto-correct.
60
# Configuration parameters: Whitelist.
61
# Whitelist: find_by_sql
62
Rails/DynamicFindBy:
63
  Exclude:
64
    - 'app/controllers/containers_controller.rb'
65
    - 'app/helpers/containers_helper.rb'
66

  
67
# Offense count: 34
68
# Cop supports --auto-correct.
69
# Configuration parameters: Include.
70
# Include: spec/**/*, test/**/*
71
Rails/HttpPositionalArguments:
72
  Exclude:
73
    - 'test/functionals/api/v2/containers_controller_test.rb'
74
    - 'test/functionals/api/v2/registries_controller_test.rb'
75
    - 'test/functionals/containers_controller_test.rb'
76
    - 'test/functionals/containers_steps_controller_test.rb'
77

  
78
# Offense count: 8
79
# Cop supports --auto-correct.
80
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
81
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
82
Style/AlignHash:
83
  Exclude:
84
    - 'app/models/docker_container_wizard_states/dns.rb'
85
    - 'app/models/docker_container_wizard_states/exposed_port.rb'
86
    - 'app/models/docker_registry.rb'
87
    - 'app/models/exposed_port.rb'
88
    - 'app/models/foreman_docker/dns.rb'
89
    - 'test/functionals/containers_steps_controller_test.rb'
90

  
91
# Offense count: 20
92
# Cop supports --auto-correct.
93
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
94
# SupportedStyles: with_first_parameter, with_fixed_indentation
95
Style/AlignParameters:
96
  Exclude:
97
    - 'test/functionals/containers_controller_test.rb'
98
    - 'test/functionals/image_search_controller_test.rb'
99
    - 'test/units/container_remover_test.rb'
100

  
101
# Offense count: 9
102
# Cop supports --auto-correct.
103
# Configuration parameters: EnforcedStyle, SupportedStyles.
104
# SupportedStyles: braces, no_braces, context_dependent
105
Style/BracesAroundHashParameters:
106
  Exclude:
107
    - 'app/controllers/image_search_controller.rb'
108
    - 'app/models/service/registry_api.rb'
109
    - 'test/functionals/containers_steps_controller_test.rb'
110
    - 'test/functionals/image_search_controller_test.rb'
111
    - 'test/test_plugin_helper.rb'
112
    - 'test/units/image_search_service_test.rb'
113

  
114
# Offense count: 1
115
# Configuration parameters: EnforcedStyle, SupportedStyles.
116
# SupportedStyles: nested, compact
117
Style/ClassAndModuleChildren:
118
  Exclude:
119
    - 'app/controllers/concerns/foreman/controller/parameters/docker_registry.rb'
120

  
121
# Offense count: 1
122
Style/ClassVars:
123
  Exclude:
124
    - 'app/models/service/registry_api.rb'
125

  
126
# Offense count: 1
127
# Cop supports --auto-correct.
128
Style/CommentIndentation:
129
  Exclude:
130
    - 'db/migrate/20160605134652_move_parameters_to_docker_parameters.rb'
131

  
132
# Offense count: 13
133
# Cop supports --auto-correct.
134
# Configuration parameters: EnforcedStyle, SupportedStyles.
135
# SupportedStyles: leading, trailing
136
Style/DotPosition:
137
  Exclude:
138
    - 'app/models/service/containers.rb'
139
    - 'app/services/foreman_docker/container_remover.rb'
140
    - 'test/functionals/api/v2/containers_controller_test.rb'
141
    - 'test/functionals/containers_controller_test.rb'
142
    - 'test/units/container_remover_test.rb'
143

  
144
# Offense count: 2
145
# Cop supports --auto-correct.
146
Style/EmptyLines:
147
  Exclude:
148
    - 'app/helpers/container_steps_helper.rb'
149
    - 'test/units/docker_container_wizard_states/image_test.rb'
150

  
151
# Offense count: 1
152
# Cop supports --auto-correct.
153
# Configuration parameters: EnforcedStyle, SupportedStyles.
154
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
155
Style/EmptyLinesAroundClassBody:
156
  Exclude:
157
    - 'app/models/docker_container_wizard_states/environment.rb'
158

  
159
# Offense count: 1
160
# Cop supports --auto-correct.
161
Style/EmptyLiteral:
162
  Exclude:
163
    - 'test/units/image_search_service_test.rb'
164

  
165
# Offense count: 4
166
# Cop supports --auto-correct.
167
# Configuration parameters: EnforcedStyle, SupportedStyles.
168
# SupportedStyles: compact, expanded
169
Style/EmptyMethod:
170
  Exclude:
171
    - 'app/controllers/api/v2/containers_controller.rb'
172
    - 'app/controllers/api/v2/registries_controller.rb'
173
    - 'app/controllers/containers_controller.rb'
174
    - 'app/controllers/registries_controller.rb'
175

  
176
# Offense count: 5
177
# Cop supports --auto-correct.
178
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
179
Style/ExtraSpacing:
180
  Exclude:
181
    - 'app/models/concerns/foreman_docker/parameter_validators.rb'
182
    - 'app/models/docker_container_wizard_states/exposed_port.rb'
183
    - 'db/migrate/20160605133025_create_docker_parameters.rb'
184
    - 'test/functionals/image_search_controller_test.rb'
185

  
186
# Offense count: 1
187
# Cop supports --auto-correct.
188
# Configuration parameters: MaxLineLength.
189
Style/IfUnlessModifier:
190
  Exclude:
191
    - 'app/models/service/containers.rb'
192

  
193
# Offense count: 8
194
# Cop supports --auto-correct.
195
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
196
# SupportedStyles: special_inside_parentheses, consistent, align_braces
197
Style/IndentHash:
198
  Exclude:
199
    - 'app/controllers/image_search_controller.rb'
200
    - 'test/functionals/containers_steps_controller_test.rb'
201

  
202
# Offense count: 1
203
# Cop supports --auto-correct.
204
# Configuration parameters: Width.
205
Style/IndentationWidth:
206
  Exclude:
207
    - 'db/migrate/20160605134652_move_parameters_to_docker_parameters.rb'
208

  
209
# Offense count: 4
210
# Cop supports --auto-correct.
211
Style/LineEndConcatenation:
212
  Exclude:
213
    - 'app/controllers/api/v2/containers_controller.rb'
214

  
215
# Offense count: 2
216
# Cop supports --auto-correct.
217
# Configuration parameters: EnforcedStyle, SupportedStyles.
218
# SupportedStyles: symmetrical, new_line, same_line
219
Style/MultilineArrayBraceLayout:
220
  Exclude:
221
    - 'app/controllers/containers/steps_controller.rb'
222
    - 'lib/foreman_docker/engine.rb'
223

  
224
# Offense count: 1
225
Style/MultilineBlockChain:
226
  Exclude:
227
    - 'app/models/service/registry_api.rb'
228

  
229
# Offense count: 7
230
# Cop supports --auto-correct.
231
# Configuration parameters: EnforcedStyle, SupportedStyles.
232
# SupportedStyles: symmetrical, new_line, same_line
233
Style/MultilineHashBraceLayout:
234
  Exclude:
235
    - 'app/controllers/api/v2/containers_controller.rb'
236
    - 'app/models/docker_container_wizard_state.rb'
237
    - 'app/models/docker_container_wizard_states/dns.rb'
238
    - 'app/models/foreman_docker/dns.rb'
239
    - 'test/functionals/containers_steps_controller_test.rb'
240
    - 'test/functionals/image_search_controller_test.rb'
241

  
242
# Offense count: 17
243
# Cop supports --auto-correct.
244
# Configuration parameters: EnforcedStyle, SupportedStyles.
245
# SupportedStyles: symmetrical, new_line, same_line
246
Style/MultilineMethodCallBraceLayout:
247
  Exclude:
248
    - 'app/controllers/api/v2/containers_controller.rb'
249
    - 'app/controllers/concerns/foreman/controller/parameters/docker_registry.rb'
250
    - 'app/controllers/containers/steps_controller.rb'
251
    - 'app/controllers/containers_controller.rb'
252
    - 'app/helpers/containers_helper.rb'
253
    - 'app/models/docker_container_wizard_states/preliminary.rb'
254
    - 'app/models/docker_registry.rb'
255
    - 'app/models/service/containers.rb'
256
    - 'test/functionals/containers_controller_test.rb'
257
    - 'test/units/container_remover_test.rb'
258
    - 'test/units/containers_service_test.rb'
259

  
260
# Offense count: 43
261
# Cop supports --auto-correct.
262
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
263
# SupportedStyles: aligned, indented, indented_relative_to_receiver
264
Style/MultilineMethodCallIndentation:
265
  Exclude:
266
    - 'app/controllers/api/v2/containers_controller.rb'
267
    - 'app/controllers/api/v2/registries_controller.rb'
268
    - 'app/controllers/concerns/foreman_docker/find_container.rb'
269
    - 'app/controllers/image_search_controller.rb'
270
    - 'app/controllers/registries_controller.rb'
271
    - 'app/helpers/container_steps_helper.rb'
272
    - 'app/helpers/containers_helper.rb'
273
    - 'app/models/service/containers.rb'
274
    - 'test/functionals/api/v2/containers_controller_test.rb'
275
    - 'test/functionals/containers_controller_test.rb'
276
    - 'test/functionals/containers_steps_controller_test.rb'
277
    - 'test/functionals/image_search_controller_test.rb'
278
    - 'test/units/containers_service_test.rb'
279
    - 'test/units/docker_registry_test.rb'
280
    - 'test/units/image_search_service_test.rb'
281

  
282
# Offense count: 4
283
# Cop supports --auto-correct.
284
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
285
# SupportedStyles: aligned, indented
286
Style/MultilineOperationIndentation:
287
  Exclude:
288
    - 'app/controllers/api/v2/containers_controller.rb'
289
    - 'app/controllers/containers_controller.rb'
290

  
291
# Offense count: 2
292
# Cop supports --auto-correct.
293
Style/MutableConstant:
294
  Exclude:
295
    - 'app/models/service/registry_api.rb'
296
    - 'lib/foreman_docker/version.rb'
297

  
298
# Offense count: 2
299
# Cop supports --auto-correct.
300
# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles.
301
# SupportedStyles: predicate, comparison
302
Style/NumericPredicate:
303
  Exclude:
304
    - 'spec/**/*'
305
    - 'app/helpers/container_steps_helper.rb'
306
    - 'test/functionals/containers_steps_controller_test.rb'
307

  
308
# Offense count: 2
309
# Cop supports --auto-correct.
310
Style/RedundantParentheses:
311
  Exclude:
312
    - 'test/units/docker_registry_test.rb'
313

  
314
# Offense count: 3
315
# Cop supports --auto-correct.
316
Style/RedundantSelf:
317
  Exclude:
318
    - 'app/models/concerns/foreman_docker/parameter_validators.rb'
319
    - 'app/models/docker_parameter.rb'
320
    - 'app/services/foreman_docker/image_search.rb'
321

  
322
# Offense count: 3
323
# Cop supports --auto-correct.
324
# Configuration parameters: EnforcedStyle, SupportedStyles.
325
# SupportedStyles: only_raise, only_fail, semantic
326
Style/SignalException:
327
  Exclude:
328
    - 'app/models/service/containers.rb'
329
    - 'app/services/foreman_docker/utility.rb'
330
    - 'db/migrate/20141209182008_remove_docker_tables.rb'
331

  
332
# Offense count: 1
333
# Configuration parameters: Methods.
334
# Methods: {"reduce"=>["acc", "elem"]}, {"inject"=>["acc", "elem"]}
335
Style/SingleLineBlockParams:
336
  Exclude:
337
    - 'app/models/concerns/fog_extensions/fogdocker/images.rb'
338

  
339
# Offense count: 4
340
# Cop supports --auto-correct.
341
# Configuration parameters: AllowForAlignment.
342
Style/SpaceAroundOperators:
343
  Exclude:
344
    - 'app/controllers/containers_controller.rb'
345
    - 'app/models/concerns/foreman_docker/parameter_validators.rb'
346
    - 'test/functionals/image_search_controller_test.rb'
347

  
348
# Offense count: 1
349
# Cop supports --auto-correct.
350
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
351
# SupportedStyles: space, no_space
352
Style/SpaceInsideBlockBraces:
353
  Exclude:
354
    - 'test/functionals/image_search_controller_test.rb'
355

  
356
# Offense count: 11
357
# Cop supports --auto-correct.
358
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
359
# SupportedStyles: space, no_space, compact
360
Style/SpaceInsideHashLiteralBraces:
361
  Exclude:
362
    - 'app/models/service/registry_api.rb'
363
    - 'test/functionals/api/v2/containers_controller_test.rb'
364
    - 'test/functionals/containers_steps_controller_test.rb'
365
    - 'test/functionals/image_search_controller_test.rb'
366
    - 'test/test_plugin_helper.rb'
367
    - 'test/units/image_search_service_test.rb'
368

  
369
# Offense count: 1
370
# Cop supports --auto-correct.
371
# Configuration parameters: EnforcedStyle, SupportedStyles.
372
# SupportedStyles: final_newline, final_blank_line
373
Style/TrailingBlankLines:
374
  Exclude:
375
    - 'app/services/foreman_docker/image_search.rb'
376

  
377
# Offense count: 2
378
# Cop supports --auto-correct.
379
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
380
# SupportedStyles: comma, consistent_comma, no_comma
381
Style/TrailingCommaInLiteral:
382
  Exclude:
383
    - 'app/models/docker_container_wizard_states/image.rb'
384
    - 'test/functionals/containers_steps_controller_test.rb'
385

  
386
# Offense count: 1
387
# Cop supports --auto-correct.
388
Style/TrailingWhitespace:
389
  Exclude:
390
    - 'app/controllers/containers/steps_controller.rb'
391

  
392
# Offense count: 1
393
# Cop supports --auto-correct.
394
Style/UnlessElse:
395
  Exclude:
396
    - 'app/services/foreman_docker/image_search.rb'
397

  
398
# Offense count: 4
399
# Cop supports --auto-correct.
400
Style/UnneededInterpolation:
401
  Exclude:
402
    - 'app/models/container.rb'
403
    - 'app/models/docker_container_wizard_states/image.rb'
404
    - 'app/models/service/registry_api.rb'
405
    - 'release/changelog'
406

  
407
# Offense count: 7
408
# Cop supports --auto-correct.
409
# Configuration parameters: SupportedStyles, WordRegex.
410
# SupportedStyles: percent, brackets
411
Style/WordArray:
412
  EnforcedStyle: percent
413
  MinSize: 3
414

  
415
# Offense count: 2
416
# Cop supports --auto-correct.
417
Style/ZeroLengthPredicate:
418
  Exclude:
419
    - 'app/helpers/container_steps_helper.rb'
420
    - 'test/functionals/containers_steps_controller_test.rb'
app/controllers/api/v2/containers_controller.rb
17 17
      param_group :search_and_pagination, ::Api::V2::BaseController
18 18

  
19 19
      def index
20
        if params[:compute_resource_id].present?
21
          scoped = Container.where(:compute_resource_id => params[:compute_resource_id])
22
        else
23
          scoped = Container.where(nil)
20
        compute_resource_id = params[:compute_resource_id].tap do |id|
21
          id.present? ? { :compute_resource_id => id } : nil
24 22
        end
23
        scoped = Container.where(compute_resource_id)
25 24
        @containers = scoped.search_for(params[:search], :order => params[:order])
26 25
                      .paginate(:page => params[:page])
27 26
      end
app/controllers/containers_controller.rb
99 99
  end
100 100

  
101 101
  def container_deletion
102
    if params[:compute_resource_id].present?
103
      compute_resource_id = params[:compute_resource_id]
104
      container_uuid      = params[:id]
102
    # TODO: Refactor to recognize params[:compute_resource_id] as well.
103
    compute_resource_id = params[:compute_resource_id].tap { |id| id.present? ? id : nil }
104
    if compute_resource_id
105
      container_uuid = params[:id]
105 106
      @container ||= Container.authorized("#{action_permission}_#{controller_name}".to_sym).find_by_uuid(container_uuid)
106 107
    else
107 108
      find_container
db/migrate/.rubocop.yml
1 1
inherit_from: ../../.rubocop.yml
2 2

  
3 3
# migrations line up column names
4
Style/SingleSpaceBeforeFirstArg:
5
  Enabled: false
4

  
5
Style/SpaceBeforeFirstArg:
6
  Enabled: false
foreman_docker.gemspec
23 23
  s.add_dependency 'excon', '~> 0.46'
24 24
  s.add_dependency 'deface', '< 2.0'
25 25
  s.add_dependency 'wicked', '~> 1.1'
26

  
27
  s.add_development_dependency 'rubocop', '0.46.0'
26 28
end
test/units/registry_api_test.rb
18 18
      let(:password) { 'secretpassword' }
19 19

  
20 20
      subject do
21
        Service::RegistryApi.new({
22
          url: url,
23
          password: password,
24
          user: user })
21
        Service::RegistryApi.new(
22
          :url => url,
23
          :password => password,
24
          :user => user
25
        )
25 26
      end
26 27

  
27 28
      test 'it sets the same user and password' do
......
37 38

  
38 39
    test 'calls get on #connection' do
39 40
      subject.connection
40
        .expects(:get).at_least_once
41
        .returns(json)
41
             .expects(:get).at_least_once
42
             .returns(json)
42 43

  
43 44
      subject.get(path)
44 45
    end
......
73 74
    test 'returns the response raw body if it is not JSON' do
74 75
      response = 'This is not JSON'
75 76
      subject.connection.stubs(:get)
76
        .returns(response)
77
             .returns(response)
77 78
      assert_equal response, subject.get('/v1/')
78 79
    end
79 80
  end
......
83 84
    let(:query) { 'centos' }
84 85

  
85 86
    test "calls #get with path and query" do
86
      subject.expects(:get).with(path, {q: query}) do |path_param, params|
87
      subject.expects(:get).with(path, q: query) do |path_param, params|
87 88
        assert_equal path, path_param
88 89
        assert_equal query, params[:q]
89 90
      end.returns({})
......
94 95
    test "falls back to #catalog if #get fails" do
95 96
      subject.expects(:catalog).with(query)
96 97

  
97
      subject.expects(:get).with(path, {q: query})
98
        .raises('Error')
98
      subject.expects(:get).with(path, q: query)
99
             .raises('Error')
99 100

  
100 101
      subject.search(query)
101 102
    end
......
112 113

  
113 114
    test "calls #get with path" do
114 115
      subject.expects(:get).with(path)
115
        .returns(catalog)
116
             .returns(catalog)
116 117

  
117 118
      subject.catalog(query)
118 119
    end
......
139 140

  
140 141
    test "falls back to #tags_v2 if #get fails" do
141 142
      subject.expects(:get).with(path)
142
        .raises('Error')
143
             .raises('Error')
143 144

  
144 145
      subject.expects(:tags_v2).with(query)
145 146
      subject.tags(query)
......
148 149
    # https://registry.access.redhat.com returns a hash not an array
149 150
    test 'handles a hash response correctly' do
150 151
      tags_hash = {
151
        "7.0-21": "e1f5733f050b2488a17b7630cb038bfbea8b7bdfa9bdfb99e63a33117e28d02f",
152
	"7.0-23": "bef54b8f8a2fdd221734f1da404d4c0a7d07ee9169b1443a338ab54236c8c91a",
153
	"7.0-27": "8e6704f39a3d4a0c82ec7262ad683a9d1d9a281e3c1ebbb64c045b9af39b3940"
152
        "7.0-21" => "e1f5733f050b2488a17b7630cb038bfbea8b7bdfa9bdfb99e63a33117e28d02f",
153
        "7.0-23" => "bef54b8f8a2fdd221734f1da404d4c0a7d07ee9169b1443a338ab54236c8c91a",
154
        "7.0-27" => "8e6704f39a3d4a0c82ec7262ad683a9d1d9a281e3c1ebbb64c045b9af39b3940"
154 155
      }
155 156
      subject.expects(:get).with(path)
156
        .returns(tags_hash)
157
             .returns(tags_hash)
157 158
      assert_equal '7.0-21', subject.tags(query).first['name']
158 159
    end
159 160
  end
......
166 167

  
167 168
    setup do
168 169
      subject.stubs(:get).with(v1_path)
169
        .raises('404 Not found')
170
             .raises('404 Not found')
170 171
    end
171 172

  
172 173
    test 'calls #get with path' do
173 174
      subject.expects(:get).with(path)
174
        .returns(tags)
175
             .returns(tags)
175 176
      subject.tags(query)
176 177
    end
177 178

  
......
185 186
  describe '#ok?' do
186 187
    test 'calls the API via #get with /v1/' do
187 188
      subject.connection.expects(:get)
188
        .with('/', nil, Service::RegistryApi::DEFAULTS[:connection].merge({ path: '/v1/' }))
189
        .returns('Docker Registry API')
189
             .with('/', nil, Service::RegistryApi::DEFAULTS[:connection].merge(path: '/v1/'))
190
             .returns('Docker Registry API')
190 191
      assert subject.ok?
191 192
    end
192 193

  
193 194
    test 'calls #get with /v2/ if /v1/fails' do
194 195
      subject.stubs(:get).with('/v1/')
195
        .raises('404 page not found')
196
             .raises('404 page not found')
196 197
      subject.expects(:get).with('/v2/')
197
        .returns({})
198
             .returns({})
198 199
      assert subject.ok?
199 200
    end
200 201
  end

Also available in: Unified diff