Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use patched path in Jira::Base#save #319

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/jira/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def save!(attrs, path = nil)
#
# Accepts an attributes hash of the values to be saved. Will return false
# if the request fails.
def save(attrs, path = url)
def save(attrs, path = nil)
begin
save_status = save!(attrs, path)
rescue JIRA::HTTPError => exception
Expand Down
14 changes: 12 additions & 2 deletions spec/jira/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,10 @@ class JIRA::Resource::HasManyExample < JIRA::Base # :nodoc:

subject { JIRA::Resource::Deadbeef.new(client) }

before(:each) do
expect(subject).to receive(:url).and_return('/foo/bar')
before(:each) do |example|
unless example.metadata[:skip_before]
expect(subject).to receive(:url).and_return('/foo/bar')
end
end

it 'POSTs a new record' do
Expand Down Expand Up @@ -269,6 +271,14 @@ class JIRA::Resource::HasManyExample < JIRA::Base # :nodoc:
expect(subject.attrs['exception']['code']).to eq(401)
expect(subject.attrs['exception']['message']).to eq('Unauthorized')
end

it 'creates request with patched path', :skip_before do
expect(subject).to receive(:url).and_return('foo/bar')
response = instance_double('Response', body: nil)
allow(subject).to receive(:new_record?) { false }
expect(client).to receive(:put).with('/foo/bar', '{"foo":"bar"}').and_return(response)
expect(subject.save('foo' => 'bar')).to be_truthy
end
end

describe 'save!' do
Expand Down