Reused tag stream query for tag pages.
This commit is contained in:
parent
e712e4c92f
commit
1d793fcc49
2 changed files with 11 additions and 11 deletions
|
|
@ -29,7 +29,16 @@ class Stream::Tag < Stream::Base
|
|||
end
|
||||
|
||||
def posts
|
||||
@posts ||= construct_post_query
|
||||
@posts ||= if user
|
||||
StatusMessage.user_tag_stream(user, tag.id)
|
||||
else
|
||||
StatusMessage.public_tag_stream(tag.id)
|
||||
end
|
||||
end
|
||||
|
||||
def stream_posts
|
||||
return [] unless tag
|
||||
super
|
||||
end
|
||||
|
||||
def tag_name=(tag_name)
|
||||
|
|
@ -42,13 +51,4 @@ class Stream::Tag < Stream::Base
|
|||
def publisher_opts
|
||||
{:open => true}
|
||||
end
|
||||
|
||||
def construct_post_query
|
||||
posts = if user.present?
|
||||
StatusMessage.owned_or_visible_by_user(user)
|
||||
else
|
||||
StatusMessage.all_public
|
||||
end
|
||||
posts.tagged_with(tag_name, :any => true)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ describe Stream::Tag do
|
|||
|
||||
describe 'shared behaviors' do
|
||||
before do
|
||||
@stream = Stream::Tag.new(FactoryGirl.create(:user), "test")
|
||||
@stream = Stream::Tag.new(FactoryGirl.create(:user), FactoryGirl.create(:tag).name)
|
||||
end
|
||||
it_should_behave_like 'it is a stream'
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue