removes explicit id from spec

pull/2412/head
Jens Ulferts 10 years ago
parent 523b4f2b9f
commit 9893070368
  1. 11
      spec/requests/api/v3/support/response_examples.rb
  2. 15
      spec/requests/api/v3/work_package_resource_spec.rb

@ -156,9 +156,14 @@ shared_examples_for 'multiple errors of the same type with details' do |expected
end
end
shared_examples_for 'multiple errors of the same type with messages' do |expected_messages|
shared_examples_for 'multiple errors of the same type with messages' do
let(:errors) { JSON.parse(last_response.body)['_embedded']['errors'] }
let(:messages) { errors.each_with_object([]) { |error, l| l << error['message'] }.compact }
let(:actual_messages) { errors.each_with_object([]) { |error, l| l << error['message'] }.compact }
it { expect(messages).to match_array(Array(expected_messages)) }
before do
raise "Need to have 'message' defined to state\
which message is expected".squish unless defined?(message)
end
it { expect(actual_messages).to match_array(Array(message)) }
end

@ -676,7 +676,9 @@ h4. things we like
it_behaves_like 'multiple errors of the same type', 2, 'PropertyConstraintViolation'
it_behaves_like 'multiple errors of the same type with messages', ['Subject can\'t be blank.', 'Parent does not exist.']
it_behaves_like 'multiple errors of the same type with messages' do
let(:message) { ['Subject can\'t be blank.', 'Parent does not exist.'] }
end
end
context 'missing lock version' do
@ -706,8 +708,8 @@ h4. things we like
context 'invalid work package children' do
let(:params) { valid_params.merge(lockVersion: work_package.reload.lock_version) }
let!(:child_1) { FactoryGirl.create(:work_package, id: 98) }
let!(:child_2) { FactoryGirl.create(:work_package, id: 99) }
let!(:child_1) { FactoryGirl.create(:work_package) }
let!(:child_2) { FactoryGirl.create(:work_package) }
before do
[child_1, child_2].each do |c|
@ -722,8 +724,11 @@ h4. things we like
it_behaves_like 'multiple errors of the same type', 2, 'PropertyConstraintViolation'
it_behaves_like 'multiple errors of the same type with messages',
[98, 99].map { |id| "##{id} cannot be in another project." }
it_behaves_like 'multiple errors of the same type with messages' do
let(:message) {
[child_1.id, child_2.id].map { |id| "##{id} cannot be in another project." }
}
end
end
end
end

Loading…
Cancel
Save