Sha256: 9c219ffbb661b92896fd02861b0459b8f60c0a6c802676a725aa6728aa6bf349
Contents?: true
Size: 1.49 KB
Versions: 1
Compression:
Stored size: 1.49 KB
Contents
require 'spec_helper' describe Zertico::PermittedParams do let(:user) { User.new } let(:params) { ActionController::Parameters.new(:id => 1, :user => { :first_name => "first_name", :last_name => "last_name" }) } let(:user_permitted_params) { UsersPermittedParams.new(params) } let(:zertico_permitted_params) { Zertico::PermittedParams.new(:zertico => { :id => 1, :name => "name" }) } describe '#create' do context 'on a custom PermittedParams' do it "should ignore the id" do expect(user_permitted_params.create).to eq({ 'first_name' => 'first_name' }) end end context 'on Zertico::PermittedParams' do it "should accept all attributes of the hash" do expect(zertico_permitted_params.create).to eq({ :id => 1, :name => 'name' }) end end end describe '#update' do context 'on a custom PermittedParams' do it "should accept id and a hash of attributes" do expect(user_permitted_params.update).to eq({ "last_name" => "last_name" }) end end context 'on Zertico::PermittedParams' do it "should accept all attributes of the hash" do expect(zertico_permitted_params.update).to eq({ :id => 1, :name => 'name' }) end end end describe '.interface_class' do it 'should return the interface singular name ' do expect(UsersPermittedParams.interface_class).to eq(User) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zertico-2.0.0.beta.1 | spec/zertico/permitted_params_spec.rb |