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
|
end
|
||||||
|
|
||||||
def posts
|
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
|
end
|
||||||
|
|
||||||
def tag_name=(tag_name)
|
def tag_name=(tag_name)
|
||||||
|
|
@ -42,13 +51,4 @@ class Stream::Tag < Stream::Base
|
||||||
def publisher_opts
|
def publisher_opts
|
||||||
{:open => true}
|
{:open => true}
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ describe Stream::Tag do
|
||||||
|
|
||||||
describe 'shared behaviors' do
|
describe 'shared behaviors' do
|
||||||
before do
|
before do
|
||||||
@stream = Stream::Tag.new(FactoryGirl.create(:user), "test")
|
@stream = Stream::Tag.new(FactoryGirl.create(:user), FactoryGirl.create(:tag).name)
|
||||||
end
|
end
|
||||||
it_should_behave_like 'it is a stream'
|
it_should_behave_like 'it is a stream'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue