Skip to content

Commit

Permalink
Users' feeds display
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Mar 15, 2011
1 parent 618f34f commit 690aa0c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
4 changes: 3 additions & 1 deletion models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class User
many :authorizations, :dependant => :destroy

key :name, String
key :username, String
key :username, String, :required => true
key :email, String
key :website, String
key :bio, String
Expand All @@ -102,6 +102,8 @@ class User
key :perishable_token, String

after_create :reset_perishible_token

has_one :feed

def reset_perishible_token
self.perishable_token = Digest::MD5.hexdigest(Time.now.to_s)
Expand Down
6 changes: 4 additions & 2 deletions rstatus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,12 @@ class Rstatus < Sinatra::Base
end

get "/feeds/:id.atom" do

feed = Feed.first :id => params[:id]
body feed.atom(uri("/"))
end

# Respond with the feed and success
get "/users/:name/feed" do
feed = User.first(:username => params[:name]).feed
body feed.atom(uri("/"))
end

Expand Down
8 changes: 8 additions & 0 deletions test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@
Factory.define :update do |u|
u.text Factory.next(:update_text)
end

Factory.sequence :usernames do |i|
"user_#{i}"
end

Factory.define :user do |u|
u.username Factory.next(:usernames)
end
7 changes: 7 additions & 0 deletions test/rstatus_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,12 @@ def test_feed_render

end

def test_user_feed_render
u = Factory(:user)
get "/users/#{u.username}/feed"
assert last_response.ok?

end

end

0 comments on commit 690aa0c

Please sign in to comment.