Skip to content
Browse files

*_news filters by a user.

  • Loading branch information...
1 parent 06fa895 commit 5c31ce7fe1f48a9539a53333b2bfe8c56246331d @steveklabnik committed Sep 2, 2010
Showing with 14 additions and 6 deletions.
  1. +11 −1 spec/extraextra_spec.rb
  2. +3 −5 spec/factories/user.rb
View
12 spec/extraextra_spec.rb
@@ -78,14 +78,24 @@
describe "#*_news" do
- it "should filter some news" do
+ it "should filter some breaking news" do
user = Factory(:user)
Extra::Extra.source
extra = Extra::Extra::! :breaking, user, "hit a home run"
extra = Extra::Extra::! :boooring, user, "just ran a test"
Extra::Extra.breaking_news.length.should == 1
+ end
+
+ it "should filter some breaking news with a user" do
+ steve = Factory(:user)
+ nobody = Factory(:user, :id => "2", :username => "nobody")
+ Extra::Extra.source
+ extra = Extra::Extra::! :breaking, steve, "hit a home run"
+ extra = Extra::Extra::! :breaking, nobody, "hit a home run"
+ Extra::Extra.breaking_news(steve).length.should == 1
end
+
end
end
View
8 spec/factories/user.rb
@@ -1,12 +1,10 @@
# we just want a dummy user
class User
+ attr_accessor :id
+ attr_accessor :username
def save!; end
- def id=(id); end
- def id; 1 end
- def username=(username); end
- def username; "steve" end
- def self.find(id); User.new end
+ def self.find(id); User.new(:id => id, :username => "somebody") end
end

0 comments on commit 5c31ce7

Please sign in to comment.
Something went wrong with that request. Please try again.