Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Change scope to :unreaded
  • Loading branch information
LTe committed Aug 24, 2012
1 parent f449d08 commit 6999d16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/acts-as-messageable/message.rb
Expand Up @@ -50,7 +50,7 @@ class Message < ::ActiveRecord::Base
:s_perm_delete => false)
}
scope :readed, lambda { where(:opened => true) }
scope :unread, lambda { where(:opened => false) }
scope :unreaded, lambda { where(:opened => false) }
scope :deleted, lambda { where(:recipient_delete => true, :sender_delete => true) }

def open?
Expand Down
10 changes: 8 additions & 2 deletions spec/acts-as-messageable_spec.rb
Expand Up @@ -131,13 +131,19 @@

describe "read/unread feature" do
it "alice should have one unread message from bob" do
@alice.messages.are_from(@bob).unread.count.should == 1
@alice.messages.are_from(@bob).unreaded.count.should == 1
@alice.messages.are_from(@bob).readed.count.should == 0
end

it "alice should able to read message from bob" do
@alice.messages.are_from(@bob).first.read
@alice.messages.are_from(@bob).unread.count.should == 0
@alice.messages.are_from(@bob).unreaded.count.should == 0
end

it "alice should able to unread message from bob" do
@alice.messages.are_from(@bob).first.read
@alice.messages.are_from(@bob).first.unread
@alice.messages.are_from(@bob).unreaded.count.should == 1
end
end

Expand Down

0 comments on commit 6999d16

Please sign in to comment.