Sha256: 52c8dd5422ebffd15cd011f923f938a104e77ceefb5d4945d30151eed7161e91
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
require 'rails_helper' module Approvable describe ChangeRequest, :type => :model do before(:each) {@request = create(:change_request)} it 'creates a change request as pending' do expect(@request.state).to eq 'pending' end it 'wont create new request unless all others are approved' do approvable = @request.approvable expect{create(:change_request, approvable: approvable)}.to raise_error ActiveRecord::RecordInvalid @request.submit! expect{create(:change_request, approvable: approvable)}.to raise_error ActiveRecord::RecordInvalid @request.reject! expect{create(:change_request, approvable: approvable)}.to raise_error ActiveRecord::RecordInvalid @request.submit! @request.approve! expect{create(:change_request, approvable: approvable)}.not_to raise_error end it 'cannot update requested_changes once submitted' do @request.submit! expect{ @request.update!(requested_changes: {title: 'a brand new title'}) }.to raise_error ActiveRecord::RecordInvalid end it 'cannot update requested_changes once approved' do @request.submit! @request.approve! expect{ @request.update!(requested_changes: {title: 'a brand new title'}) }.to raise_error ActiveRecord::RecordInvalid end it 'cannot transition out of approved' do @request.submit! @request.approve! expect{@request.reject!}.to raise_error AASM::InvalidTransition expect{@request.submit!}.to raise_error AASM::InvalidTransition expect{@request.unreject!}.to raise_error AASM::InvalidTransition end it 'rejected reverts to pending after changed_attributes change' do @request.submit! @request.reject! @request.update(requested_changes: {title: 'a brand new title'}) expect(@request.state).to eq 'pending' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
approvable-0.0.2 | spec/models/approvable/change_request_spec.rb |