Skip to content

Commit

Permalink
Updates for attachment spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
marlinpierce committed Jan 13, 2025
1 parent afef22a commit fbab302
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions spec/jira/resource/attachment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
require 'spec_helper'

describe JIRA::Resource::Attachment do
let(:issue_id) { 27676 }

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

View workflow job for this annotation

GitHub Actions / rubocop

Style/NumericLiterals: Use underscores(_) as thousands separator and separate every 3 digits with them.
let(:attachment_id) { 30076 }

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

View workflow job for this annotation

GitHub Actions / rubocop

Style/NumericLiterals: Use underscores(_) as thousands separator and separate every 3 digits with them.
subject(:attachment) do

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

View workflow job for this annotation

GitHub Actions / rubocop

RSpec/LeadingSubject: Declare `subject` above any other `let` declarations.
described_class.new(
client,
issue: JIRA::Resource::Issue.new(client),
attrs: { 'author' => { 'foo' => 'bar' } }
JIRA::Resource::Attachment.new(

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

View workflow job for this annotation

GitHub Actions / rubocop

RSpec/DescribedClass: Use `described_class` instead of `JIRA::Resource::Attachment`.
client,

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

View workflow job for this annotation

GitHub Actions / rubocop

Layout/FirstArgumentIndentation: Indent the first argument one step more than the start of the previous line.
issue: JIRA::Resource::Issue.new(client, attrs: {'id' => issue_id}),

Check failure on line 9 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 9 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 }
)

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

View workflow job for this annotation

GitHub Actions / rubocop

Layout/ClosingParenthesisIndentation: Indent `)` to column 6 (not 4)
end

Expand Down Expand Up @@ -73,6 +75,15 @@
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}) }
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 @@ -125,6 +136,8 @@
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)

subject

expect(attachment.filename).to eq file_name
Expand Down Expand Up @@ -225,4 +238,15 @@
end
end
end

context 'an attachment is on an issue' do
describe '#delete' do

it 'removes the attachment' do
expect(client).to receive(:delete).with("/jira/rest/api/2/issue/#{issue_id}/attachments/#{attachment_id}")

attachment.delete
end
end
end
end

0 comments on commit fbab302

Please sign in to comment.