Sha256: f2a9e943a65a2ddb5677e8872ed5b1cb960b22f810f41c05596d32b70c34c5cf
Contents?: true
Size: 673 Bytes
Versions: 17
Compression:
Stored size: 673 Bytes
Contents
shared_examples_for 'ActiveRecord-like mass assignment' do |attributes| it 'assigns all given attributes' do subject.attributes = attributes attributes.each do |key, value| subject.send(key).should == value end end if ActiveRecord::VERSION::MAJOR >= 4 it 'raises on unpermitted parameters' do params = ProtectedParams.new(attributes) expect { subject.attributes = params }.to raise_error(ActiveModel::ForbiddenAttributesError) end it 'accepts permitted parameters' do params = ProtectedParams.new(attributes) params.permit! expect { subject.attributes = params }.to_not raise_error end end end
Version data entries
17 entries across 17 versions & 1 rubygems