Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
fix raw yaml upload in rspec tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroPointEnergy committed Jan 30, 2019
1 parent 673d1ba commit fc16d75
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions spec/controllers/reports_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def model; Report end
describe "with a POST from Puppet 2.6.x" do
subject do
lambda {
post_with_body :upload, @yaml, as: :yaml
post :upload, body: @yaml, as: :yaml
Delayed::Worker.new.work_off
}
end
Expand Down Expand Up @@ -78,13 +78,13 @@ def model; Report end
describe "#create" do
it "should fail with a 403 error when disable_legacy_report_upload_url is true" do
SETTINGS.stubs(:disable_legacy_report_upload_url).returns(true)
response = post_with_body :create, @yaml, as: :yaml
post :create, body: @yaml, as: :yaml
response.should be_forbidden
end

it "should succeed when disable_legacy_report_upload_url is false" do
SETTINGS.stubs(:disable_legacy_report_upload_url).returns(false)
response = post_with_body :create, @yaml, as: :yaml
post :create, body: @yaml, as: :yaml
response.should be_successful
end
end
Expand Down Expand Up @@ -151,11 +151,4 @@ def model; Report end
assigns[:reports].should include @unchanged
end
end

def post_with_body(action, body, args)
@request.env['RAW_POST_DATA'] = body
response = post(action, args)
@request.env.delete('RAW_POST_DATA')
response
end
end

0 comments on commit fc16d75

Please sign in to comment.