mirror of
https://gitlab.com/gitlab-org/gitlab-foss.git
synced 2025-07-23 00:47:51 +00:00
Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
@ -30,6 +30,9 @@ module QA
|
||||
# @param [Integer] time fabrication time
|
||||
# @return [Hash]
|
||||
def collect(resource:, info:, fabrication_method:, fabrication_time:)
|
||||
# http_method is empty when we use the browser_ui to create a resource,
|
||||
# so assign it a default :post value if it is empty otherwise it will be set to :get in resource_api_path
|
||||
http_method = resource.api_fabrication_http_method || :post
|
||||
api_path = resource_api_path(resource)
|
||||
type = resource.class.name
|
||||
|
||||
@ -38,7 +41,7 @@ module QA
|
||||
api_path: api_path,
|
||||
fabrication_method: fabrication_method,
|
||||
fabrication_time: fabrication_time,
|
||||
http_method: resource.api_fabrication_http_method || :post,
|
||||
http_method: http_method,
|
||||
timestamp: Time.now.to_s
|
||||
}
|
||||
end
|
||||
|
@ -38,6 +38,55 @@ RSpec.describe QA::Tools::TestResourceDataProcessor do
|
||||
it 'collects and stores resource' do
|
||||
expect(processor.resources).to eq(result)
|
||||
end
|
||||
|
||||
context 'when fabrication_method is browser_ui' do
|
||||
let(:method) { :browser_ui }
|
||||
|
||||
let(:group_resource) do
|
||||
group = instance_double(QA::Resource::Group, 'Group Resource')
|
||||
allow(group).to receive(:class).and_return(QA::Resource::Group)
|
||||
|
||||
# Start with nil
|
||||
allow(group).to receive(:api_fabrication_http_method).and_return(nil)
|
||||
|
||||
allow(group).to receive(:api_delete_path) do
|
||||
# After this call, simulate that the method gets set to :get
|
||||
allow(group).to receive(:api_fabrication_http_method).and_return(:get)
|
||||
"/groups/123"
|
||||
end
|
||||
|
||||
allow(group).to receive(:respond_to?).with(:api_delete_path).and_return(true)
|
||||
allow(group).to receive(:respond_to?).with(:api_get_path).and_return(true)
|
||||
|
||||
group
|
||||
end
|
||||
|
||||
let(:expected_result_with_post) do
|
||||
{
|
||||
'QA::Resource::Group' => [{
|
||||
info: info,
|
||||
api_path: "/groups/123",
|
||||
fabrication_method: method,
|
||||
fabrication_time: time,
|
||||
http_method: :post,
|
||||
timestamp: Time.now.to_s
|
||||
}]
|
||||
}
|
||||
end
|
||||
|
||||
it 'defaults http_method to :post when api_fabrication_http_method is nil' do
|
||||
new_processor = Class.new(described_class).instance
|
||||
|
||||
new_processor.collect(
|
||||
resource: group_resource,
|
||||
info: info,
|
||||
fabrication_method: method,
|
||||
fabrication_time: time
|
||||
)
|
||||
|
||||
expect(new_processor.resources).to eq(expected_result_with_post)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '.write_to_file' do
|
||||
|
Reference in New Issue
Block a user