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
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Upload a design through graphQL', :js do
include_context 'file upload requests helpers'
let_it_be(:query) do
"
mutation uploadDesign($files: [Upload!]!, $projectPath: ID!, $iid: ID!) {
designManagementUpload(input: { projectPath: $projectPath, iid: $iid, files: $files}) {
clientMutationId,
errors
}
}
"
end
let_it_be(:user) { create(:user, :admin) }
let_it_be(:personal_access_token) { create(:personal_access_token, user: user) }
let_it_be(:design) { create(:design) }
let_it_be(:operations) { { "operationName": "uploadDesign", "variables": { "files": [], "projectPath": design.project.full_path, "iid": design.issue.iid }, "query": query }.to_json }
let_it_be(:map) { { "1": ["variables.files.0"] }.to_json }
let(:url) { capybara_url("/api/graphql?private_token=#{personal_access_token.token}") }
let(:file) { fixture_file_upload('spec/fixtures/dk.png') }
subject do
HTTParty.post(
url,
body: {
operations: operations,
map: map,
"1": file
}
)
end
before do
stub_lfs_setting(enabled: true)
end
RSpec.shared_examples 'for a design upload through graphQL' do
it 'creates proper objects' do
expect { subject }
.to change { ::DesignManagement::Design.count }.by(1)
.and change { ::LfsObject.count }.by(1)
end
it { expect(subject.code).to eq(200) }
end
it_behaves_like 'handling file uploads', 'for a design upload through graphQL'
end
|