Project

General

Profile

Revision 8138e503

Added by Sebastian Gräßl over 5 years ago

Fixes #19396 - Rename test variable name to more specific term

To avoid conflict with methods in the same scope less ambiguous
terms should be used.

View differences:

test/functionals/image_search_controller_test.rb
1 1
require 'test_plugin_helper'
2 2

  
3 3
class ImageSearchControllerTest < ActionController::TestCase
4
  let(:image) { 'centos' }
4
  let(:docker_image) { 'centos' }
5 5
  let(:tags) { ['latest', '5', '4.3'].map { |tag| "#{term}:#{tag}" } }
6
  let(:term) { image }
6
  let(:term) { docker_image }
7 7

  
8 8
  let(:docker_hub) { Service::RegistryApi.new(url: 'https://nothub.com') }
9 9
  let(:compute_resource) { FactoryGirl.create(:docker_cr) }
......
65 65

  
66 66
  describe '#auto_complete_image_tag' do
67 67
    let(:tag_fragment) { 'lat' }
68
    let(:term) { "#{image}:#{tag_fragment}"}
68
    let(:term) { "#{docker_image}:#{tag_fragment}"}
69 69

  
70 70
    test 'returns an array of { label:, value: } hashes' do
71 71
      search_type = ['hub', 'registry'].sample
......
83 83
      let(:search_type) { 'hub' }
84 84

  
85 85
      test 'it searches Docker Hub and the ComputeResource' do
86
        compute_resource.expects(:image).with(image)
86
        compute_resource.expects(:image).with(docker_image)
87 87
          .returns(term)
88 88
        compute_resource.expects(:tags_for_local_image)
89 89
          .returns(tags)
......
99 99
      let(:search_type) { 'registry' }
100 100

  
101 101
      test 'it only queries the registry api' do
102
        compute_resource.expects(:image).with(image).never
102
        compute_resource.expects(:image).with(docker_image).never
103 103
        docker_hub.expects(:tags).never
104
        registry.api.expects(:tags).with(image, tag_fragment)
104
        registry.api.expects(:tags).with(docker_image, tag_fragment)
105 105
          .returns([])
106 106

  
107 107
        xhr :get, :auto_complete_image_tag,
......
142 142
      let(:search_type) { 'registry' }
143 143

  
144 144
      test 'it only queries the registry api' do
145
        compute_resource.expects(:local_images).with(image).never
145
        compute_resource.expects(:local_images).with(docker_image).never
146 146
        docker_hub.expects(:search).never
147
        registry.api.expects(:search).with(image)
147
        registry.api.expects(:search).with(docker_image)
148 148
          .returns({})
149 149

  
150 150
        xhr :get, :search_repository,

Also available in: Unified diff