135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/intermodal/rspec/requests/linked_resources.rb', line 135
def expects_list_remove(&blk)
_metadata = metadata
request :delete, metadata[:collection_url] do
instance_eval(&blk) if blk
let(:request_url) { collection_url }
let(:deleted_target_ids) { model_collection[0..1] }
let(:remaining_target_ids) { model_collection - deleted_target_ids }
let(:request_payload) { { collection_element_name => deleted_target_ids } }
let(:updated_target_ids) { model.by_parent(model_parent).to_target_ids }
expects_status(200)
expects_content_type(metadata[:mime_type], metadata[:encoding])
it 'should delete linked targets' do
deleted_target_ids.should_not be_empty
response.should_not be_empty
deleted_target_ids.each do |deleted_target_id|
updated_target_ids.should_not include(deleted_target_id)
end
end
it 'should keep remaining targets' do
deleted_target_ids.should_not be_empty
response.should_not be_empty
remaining_target_ids.each do |remaining_target_id|
updated_target_ids.should include(remaining_target_id)
end
end
with_malformed_data_should_respond_with_400
with_nil_target_ids_should_respond_with_422
expects_unauthorized_access_to_respond_with_401
end
end
|