-
Notifications
You must be signed in to change notification settings - Fork 45
/
installer_controller_spec.rb
79 lines (61 loc) · 2.71 KB
/
installer_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require 'rails_helper'
RSpec.describe Api::Connect::V4::Repositories::InstallerController do
include_context 'version header', 4
let(:url) { connect_default_repositories_installer_url }
describe '#show' do
subject { response }
context 'without product' do
before { get url }
let(:error_response) do
{
type: 'error',
error: 'Required parameters are missing or empty: identifier, version, arch',
localized_error: 'Required parameters are missing or empty: identifier, version, arch'
}
end
its(:body) { is_expected.to eq error_response.to_json }
its(:code) { is_expected.to eq('422') }
end
context 'with unknown product' do
let(:params) { { identifier: 'dummy_product', version: '42', arch: 'x86_64' } }
let(:error_response) do
{
type: 'error',
error: 'No product found on RMT for: dummy_product 42 x86_64',
localized_error: 'No product found on RMT for: dummy_product 42 x86_64'
}
end
before { get url, params: params }
its(:body) { is_expected.to eq error_response.to_json }
its(:code) { is_expected.to eq('422') }
end
context 'with known product with not mirrored repositories' do
let(:product) { FactoryGirl.create(:product, :with_not_mirrored_repositories) }
let(:params) { { identifier: product.identifier, version: product.version, arch: product.arch } }
before { get url, params: params }
its(:body) { is_expected.to eq '[]' }
its(:code) { is_expected.to eq('200') }
end
describe 'response with "-" in product version' do
let(:product) { FactoryGirl.create(:product, :with_not_mirrored_repositories, version: '24.0') }
let(:params) { { identifier: product.identifier, version: '24.0-0', arch: product.arch } }
before { get url, params: params }
its(:body) { is_expected.to eq '[]' }
its(:code) { is_expected.to eq('200') }
end
context 'with known product with mirrored installer update repositories' do
let(:product) { FactoryGirl.create(:product, :with_mirrored_repositories) }
let(:params) { { identifier: product.identifier, version: product.version, arch: product.arch } }
let(:serialized_response) do
ActiveModel::Serializer::CollectionSerializer.new(
product.repositories.where(installer_updates: true),
serializer: ::V3::RepositorySerializer,
base_url: URI::HTTP.build({ scheme: response.request.scheme, host: response.request.host })
).to_json
end
before { get url, params: params }
its(:body) { is_expected.to eq serialized_response }
its(:code) { is_expected.to eq('200') }
end
end
end