spec/models/card/trash_spec.rb in wagn-1.13.0 vs spec/models/card/trash_spec.rb in wagn-1.14.0.pre1
- old
+ new
@@ -1,16 +1,17 @@
# -*- encoding : utf-8 -*-
+require 'card/action'
describe Card, "deleting card" do
it "should require permission" do
a = Card['a']
Card::Auth.as :anonymous do
- a.ok?(:delete).should == false
- a.delete.should == false
- a.errors[:permission_denied].should_not be_empty
- Card['a'].trash.should == false
+ expect(a.ok?(:delete)).to eq(false)
+ expect(a.delete).to eq(false)
+ expect(a.errors[:permission_denied]).not_to be_empty
+ expect(Card['a'].trash).to eq(false)
end
end
end
@@ -20,27 +21,27 @@
@c = Card['A']
@c.delete!
end
end
it "should be in the trash" do
- @c.trash.should be_true
+ expect(@c.trash).to be_truthy
end
it "should come out of the trash when a plus card is created" do
Card::Auth.as_bot do
Card.create(:name=>'A+*acct')
c = Card[ 'A' ]
- c.trash.should be_false
+ expect(c.trash).to be_falsey
end
end
end
describe Card, "in trash" do
it "should be retrieved by fetch with new" do
Card.create(:name=>"Betty").delete
c=Card.fetch "Betty", :new=>{}
c.save
- Card["Betty"].should be_instance_of(Card)
+ expect(Card["Betty"]).to be_instance_of(Card)
end
end
describe Card, "plus cards" do
@@ -48,33 +49,33 @@
Card::Auth.as :joe_admin do
c = Card.create! :name=>'zz+top'
root = Card['zz']
root.delete
# Rails.logger.info "ERRORS = #{root.errors.full_messages*''}"
- Card.find(c.id).trash.should be_true
- Card['zz'].should be_nil
+ expect(Card.find(c.id).trash).to be_truthy
+ expect(Card['zz']).to be_nil
end
end
end
# FIXME: these user tests should probably be in a set of cardtype specific tests somewhere..
describe Card do
context "with revisions" do
before do Card::Auth.as_bot { @c = Card["Wagn Bot"] } end
it "should not be removable" do
- @c.delete.should_not be_true
+ expect(@c.delete).not_to be_truthy
end
end
context "without revisions" do
before do
Card::Auth.as_bot do
@c = Card.create! :name=>'User Must Die', :type=>'User'
end
end
it "should be removable" do
- @c.delete!.should be_true
+ expect(@c.delete!).to be_truthy
end
end
end
@@ -99,15 +100,15 @@
@a.delete!
@c = Card.find_by_key "A+B+C".to_name.key
end
it "should be trash" do
- @c.trash.should be_true
+ expect(@c.trash).to be_truthy
end
it "should not be findable by name" do
- Card["A+B+C"].should == nil
+ expect(Card["A+B+C"]).to eq(nil)
end
end
describe Card, "rename to trashed name" do
before do
@@ -120,17 +121,17 @@
@b.update_attributes! :name=>"A", :update_referencers=>true
end
end
it "should rename b to a" do
- @b.name.should == 'A'
+ expect(@b.name).to eq('A')
end
it "should rename a to a*trash" do
- (c = Card.find(@a.id)).cardname.to_s.should == 'A*trash'
- c.name.should == 'A*trash'
- c.key.should == 'a*trash'
+ expect((c = Card.find(@a.id)).cardname.to_s).to eq('A*trash')
+ expect(c.name).to eq('A*trash')
+ expect(c.key).to eq('a*trash')
end
end
describe Card, "sent to trash" do
@@ -140,20 +141,20 @@
@c.delete!
end
end
it "should be trash" do
- @c.trash.should == true
+ expect(@c.trash).to eq(true)
end
it "should not be findable by name" do
- Card["basicname"].should == nil
+ expect(Card["basicname"]).to eq(nil)
end
- it "should still have revision" do
- @c.revisions.length.should == 1
- @c.current_revision.content.should == 'basiccontent'
+ it "should still have actions" do
+ expect(@c.actions.count).to eq(2)
+ expect(@c.last_change_on(:db_content).value).to eq('basiccontent')
end
end
describe Card, "revived from trash" do
before do
@@ -163,23 +164,23 @@
@c = Card.create! :name=>'basicname', :content=>'revived content'
end
end
it "should not be trash" do
- @c.trash.should == false
+ expect(@c.trash).to eq(false)
end
- it "should have 2 revisions" do
- @c.revisions.length.should == 2
+ it "should have 3 actions" do
+ expect(@c.actions.count).to eq(3)
end
- it "should still have old revisions" do
- @c.revisions[0].content.should == 'basiccontent'
+ it "should still have old content" do
+ expect(@c.nth_action(1).change_for(2).first.value).to eq('basiccontent')
end
- it "should have a new revision" do
- @c.content.should == 'revived content'
+ it "should have the same content" do
+ expect(@c.content).to eq('revived content')
# Card.fetch(@c.name).content.should == 'revived content'
end
end
describe Card, "recreate trashed card via new" do
@@ -205,22 +206,22 @@
@c = Card.create! :name=>"basicname+woot", :content=>"revived content"
end
end
it "should not be trash" do
- @c.trash.should == false
+ expect(@c.trash).to eq(false)
end
- it "should have 2 revisions" do
- @c.revisions.length.should == 2
+ it "should have 3 actions" do
+ expect(@c.actions.count).to eq(3)
end
- it "should still have old revisions" do
- @c.revisions[0].content.should == 'basiccontent'
+ it "should still have old action" do
+ expect(@c.nth_action(1).change_for(2).first.value).to eq('basiccontent')
end
- it "should have a new revision" do
- @c.content.should == 'revived content'
+ it "should have old content" do
+ expect(@c.db_content).to eq('revived content')
end
end
describe "remove tests" do