Skip to content

Instantly share code, notes, and snippets.

@baoist
Last active June 24, 2016 18:01
Show Gist options
  • Save baoist/b3a4e4c20192b75676786af438254147 to your computer and use it in GitHub Desktop.
Save baoist/b3a4e4c20192b75676786af438254147 to your computer and use it in GitHub Desktop.
shared_examples_for "non-working versions" do
let!(:export) { create(:export, clinical_protocol: clinical_protocol) }
before(:each) do
post endpoint, params, auth_headers
end
it 'should return 422 status code' do
expect(response).to have_http_status 422
end
it 'should not increase the model count' do
count = clinical_protocol.try(association)&.count
expect(count).to eq 0
end
it 'should have errors' do
json = JSON.parse(response.body)
fail!("does not have errors") unless json['errors']
expect(json['errors']).to eq([{
"reason" => "base",
"message" => "Cannot change values for old versions"
}])
end
end
## USAGE
it_behaves_like "non-working versions" do
let(:endpoint) { "/api/clinical_protocols/#{clinical_protocol.cpid}/exports/latest/assessments" }
let(:params) { { assessment: { order_float: 12, comment_str: 'foo', icd: 'B10.1' } } }
let(:association) { :assessments }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment