Skip to content

Commit

Permalink
Fix attachment spec
Browse files Browse the repository at this point in the history
  • Loading branch information
marlinpierce committed Jan 13, 2025
1 parent fbab302 commit 38dc22b
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions spec/jira/resource/attachment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
require 'spec_helper'

describe JIRA::Resource::Attachment do
let(:issue_id) { 27676 }
let(:attachment_id) { 30076 }
subject(:attachment) do
JIRA::Resource::Attachment.new(
client,
issue: JIRA::Resource::Issue.new(client, attrs: {'id' => issue_id}),
attrs: { 'author' => { 'foo' => 'bar' }, 'id' => attachment_id }
described_class.new(
client,
issue: JIRA::Resource::Issue.new(client, attrs: {'id' => issue_id}),

Check failure on line 7 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 7 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
attrs: { 'author' => { 'foo' => 'bar' }, 'id' => attachment_id }
)
end

Check failure on line 10 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

RSpec/EmptyLineAfterSubject: Add an empty line after `subject`.

let(:issue_id) { 27_676 }
let(:attachment_id) { 30_076 }
let(:client) do
double(
'client',
Expand Down Expand Up @@ -69,21 +68,13 @@
attrs: { 'author' => { 'foo' => 'bar' }, 'content' => attachment_url }
)
end

Check failure on line 70 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

RSpec/EmptyLineAfterSubject: Add an empty line after `subject`.

let(:attachment_url) { 'https://localhost:2990/secure/attachment/32323/myfile.txt' }
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' }
let(:issue_id) { 3232 }
let(:issue) { JIRA::Resource::Issue.new(client, attrs: {'id' => issue_id}) }

Check failure on line 77 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 77 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
subject(:attachment) do
JIRA::Resource::Attachment.new(
client,
issue: issue,
attrs: { 'author' => { 'foo' => 'bar' } }
)
end

before do
stub_request(:get, attachment_url).to_return(body: attachment_file_contents)
Expand Down Expand Up @@ -126,7 +117,7 @@
].to_json
)
end
let(:issue) { JIRA::Resource::Issue.new(client) }
let(:issue) { JIRA::Resource::Issue.new(client, attrs: {'id' => issue_id}) }

Check failure on line 120 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.

Check failure on line 120 in spec/jira/resource/attachment_spec.rb

View workflow job for this annotation

GitHub Actions / rubocop

Layout/SpaceInsideHashLiteralBraces: Space inside } missing.

describe '#save' do
subject { attachment.save('file' => path_to_file) }
Expand All @@ -136,7 +127,7 @@
end

it 'successfully update the attachment' do
expect(client).to receive(:post_multipart).and_return(response).with("/jira/rest/api/2/issue/#{issue.id}/attachments", anything, anything)
expect(client).to receive(:post_multipart).and_return(response).with("/jira/rest/api/2/issue/#{issue.id}/attachments/#{attachment.id}", anything, anything)

subject

Expand Down

0 comments on commit 38dc22b

Please sign in to comment.