Remove model_ prefix

pull/3125/head
Alexander Bach 10 years ago committed by Jens Ulferts
parent 4656b94a6d
commit 5d7a1d2cb4
  1. 36
      spec/lib/api/contracts/model_contract_spec.rb

@ -30,16 +30,16 @@ require 'spec_helper'
describe ::API::Contracts::ModelContract do describe ::API::Contracts::ModelContract do
let(:work_package) { FactoryGirl.create(:work_package) } let(:work_package) { FactoryGirl.create(:work_package) }
let(:model_child_contract) { ModelChild.new(work_package) } let(:child_contract) { ChildContract.new(work_package) }
let(:model_grand_child_contract) { ModelGrandChild.new(work_package) } let(:grand_child_contract) { GrandChildContract.new(work_package) }
before do before do
model_child_contract.child_value = 0 child_contract.child_value = 0
model_grand_child_contract.child_value = 0 grand_child_contract.child_value = 0
end end
describe 'child' do describe 'child' do
class ModelChild < ::API::Contracts::ModelContract class ChildContract < ::API::Contracts::ModelContract
attr_accessor :child_value attr_accessor :child_value
attribute :child_attribute attribute :child_attribute
@ -49,18 +49,18 @@ describe ::API::Contracts::ModelContract do
end end
it 'should collect its own writable attributes' do it 'should collect its own writable attributes' do
expect(model_child_contract.writable_attributes).to include('child_attribute', expect(child_contract.writable_attributes).to include('child_attribute',
'overwritten_attribute') 'overwritten_attribute')
end end
it 'should collect its own attribute validations' do it 'should collect its own attribute validations' do
model_child_contract.validate child_contract.validate
expect(model_child_contract.child_value).to eq(1) expect(child_contract.child_value).to eq(1)
end end
end end
describe 'grand_child' do describe 'grand_child' do
class ModelGrandChild < ModelChild class GrandChildContract < ChildContract
attr_accessor :grand_child_value attr_accessor :grand_child_value
attribute :grand_child_attribute attribute :grand_child_attribute
@ -70,20 +70,20 @@ describe ::API::Contracts::ModelContract do
end end
it 'should consider its ancestor writable attributes' do it 'should consider its ancestor writable attributes' do
expect(model_grand_child_contract.writable_attributes).to include('child_attribute', expect(grand_child_contract.writable_attributes).to include('child_attribute',
'overwritten_attribute', 'overwritten_attribute',
'grand_child_attribute') 'grand_child_attribute')
expect(model_grand_child_contract.writable_attributes.count).to eq(3) expect(grand_child_contract.writable_attributes.count).to eq(3)
end end
it 'should obey common inheritance rules' do it 'should obey common inheritance rules' do
expect(model_grand_child_contract.writable_attributes.count).to eq(3) expect(grand_child_contract.writable_attributes.count).to eq(3)
end end
it 'should execute all the validations' do it 'should execute all the validations' do
model_grand_child_contract.validate grand_child_contract.validate
expect(model_grand_child_contract.child_value).to eq(1) expect(grand_child_contract.child_value).to eq(1)
expect(model_grand_child_contract.grand_child_value).to eq(2) expect(grand_child_contract.grand_child_value).to eq(2)
end end
end end
end end

Loading…
Cancel
Save