spec/models/widget_spec.rb in paper_trail-3.0.8 vs spec/models/widget_spec.rb in paper_trail-3.0.9

- old
+ new

@@ -70,25 +70,25 @@ end end describe "Methods" do describe "Instance", :versioning => true do - describe :originator do - it { should respond_to(:originator) } + describe '#paper_trail_originator' do + it { should respond_to(:paper_trail_originator) } describe "return value" do let(:orig_name) { Faker::Name.name } let(:new_name) { Faker::Name.name } before { PaperTrail.whodunnit = orig_name } context "accessed from live model instance" do specify { widget.should be_live } it "should return the originator for the model at a given state" do - widget.originator.should == orig_name + widget.paper_trail_originator.should == orig_name widget.whodunnit(new_name) { |w| w.update_attributes(:name => 'Elizabeth') } - widget.originator.should == new_name + widget.paper_trail_originator.should == new_name end end context "accessed from a reified model instance" do before do @@ -97,17 +97,38 @@ widget.update_attributes(:name => 'Elizabeth') end let(:reified_widget) { widget.versions[1].reify } it "should return the appropriate originator" do - reified_widget.originator.should == orig_name + reified_widget.paper_trail_originator.should == orig_name end end end end - describe :version_at do + describe "#originator" do + subject { widget } + + it { is_expected.to respond_to(:originator) } + let(:warning_msg) do + "DEPRECATED: use `paper_trail_originator` instead of `originator`." + + " Support for `originator` will be removed in PaperTrail 4.0" + end + + it 'should set the invoke `paper_trail_originator`' do + is_expected.to receive(:warn) + is_expected.to receive(:paper_trail_originator) + subject.originator + end + + it 'should display a deprecation warning' do + is_expected.to receive(:warn).with(warning_msg) + subject.originator + end + end + + describe '#version_at' do it { should respond_to(:version_at) } context "Timestamp argument is AFTER object has been destroyed" do before do widget.update_attribute(:name, 'foobar') @@ -198,11 +219,11 @@ subject.should_receive(:paper_trail_off!) subject.paper_trail_off end it 'should display a deprecation warning' do - subject.should_receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 3.1") + subject.should_receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 4.0") subject.paper_trail_on end end describe :paper_trail_on! do @@ -227,10 +248,10 @@ subject.should_receive(:paper_trail_on!) subject.paper_trail_on end it 'should display a deprecation warning' do - subject.should_receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 3.1") + subject.should_receive(:warn).with("DEPRECATED: use `paper_trail_on!` instead of `paper_trail_on`. Support for `paper_trail_on` will be removed in PaperTrail 4.0") subject.paper_trail_on end end end end