diff --git a/lib/jira/base.rb b/lib/jira/base.rb index 52c6dbf3..8a8520cc 100644 --- a/lib/jira/base.rb +++ b/lib/jira/base.rb @@ -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 diff --git a/spec/jira/base_spec.rb b/spec/jira/base_spec.rb index 0833a940..73b12783 100644 --- a/spec/jira/base_spec.rb +++ b/spec/jira/base_spec.rb @@ -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 @@ -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