Skip to content

Commit

Permalink
Update attachment spec for rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrodie committed Apr 30, 2024
1 parent 669a600 commit a975e58
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions spec/jira/resource/attachment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe JIRA::Resource::Attachment do
subject(:attachment) do
JIRA::Resource::Attachment.new(
described_class.new(
client,
issue: JIRA::Resource::Issue.new(client),
attrs: { 'author' => { 'foo' => 'bar' } }
Expand Down Expand Up @@ -35,7 +35,7 @@
end

describe '.meta' do
subject { JIRA::Resource::Attachment.meta(client) }
subject { described_class.meta(client) }

let(:response) do
double(
Expand All @@ -60,20 +60,21 @@
end

context 'there is an attachment on an issue' do
let(:client) do
JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false)
end
let(:attachment_file_contents) { 'file contents' }
let(:attachment_url) { 'https://localhost:2990/secure/attachment/32323/myfile.txt' }
subject(:attachment) do
JIRA::Resource::Attachment.new(
described_class.new(
client,
issue: JIRA::Resource::Issue.new(client),
attrs: { 'author' => { 'foo' => 'bar' }, 'content' => attachment_url }
)
end

before(:each) do
let(:client) do
JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false)
end
let(:attachment_file_contents) { 'file contents' }
let(:attachment_url) { 'https://localhost:2990/secure/attachment/32323/myfile.txt' }

before do
stub_request(:get, attachment_url).to_return(body: attachment_file_contents)
end

Expand Down Expand Up @@ -104,12 +105,12 @@
double(
body: [
{
"id": 10_001,
"self": 'http://www.example.com/jira/rest/api/2.0/attachments/10000',
"filename": file_name,
"created": '2017-07-19T12:23:06.572+0000',
"size": file_size,
"mimeType": file_mime_type
id: 10_001,
self: 'http://www.example.com/jira/rest/api/2.0/attachments/10000',
filename: file_name,
created: '2017-07-19T12:23:06.572+0000',
size: file_size,
mimeType: file_mime_type
}
].to_json
)
Expand All @@ -130,22 +131,24 @@
expect(attachment.mimeType).to eq file_mime_type
expect(attachment.size).to eq file_size
end

context 'when using custom client headers' do
subject(:bearer_attachment) do
JIRA::Resource::Attachment.new(
described_class.new(
bearer_client,
issue: JIRA::Resource::Issue.new(bearer_client),
attrs: { 'author' => { 'foo' => 'bar' } }
)
end
let(:default_headers_given) {

let(:default_headers_given) do
{
'authorization' => 'Bearer 83CF8B609DE60036A8277BD0E96135751BBC07EB234256D4B65B893360651BF2'
}
}
end
let(:bearer_client) do
JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false,
default_headers: default_headers_given )
default_headers: default_headers_given)
end
let(:merged_headers) do
{
Expand Down Expand Up @@ -193,16 +196,17 @@

context 'when using custom client headers' do
subject(:bearer_attachment) do
JIRA::Resource::Attachment.new(
described_class.new(
bearer_client,
issue: JIRA::Resource::Issue.new(bearer_client),
attrs: { 'author' => { 'foo' => 'bar' } }
)
end

let(:default_headers_given) { { 'authorization' => 'Bearer 83CF8B609DE60036A8277BD0E96135751BBC07EB234256D4B65B893360651BF2' } }
let(:bearer_client) do
JIRA::Client.new(username: 'username', password: 'password', auth_type: :basic, use_ssl: false,
default_headers: default_headers_given )
default_headers: default_headers_given)
end
let(:merged_headers) do
{
Expand All @@ -221,4 +225,4 @@
end
end
end
end
end

0 comments on commit a975e58

Please sign in to comment.