only load photos for a post if photos_count > 0; display 'limited' or 'public' in stream elements; fix small like bug in stream
This commit is contained in:
parent
71bae10317
commit
64a90a30ef
4 changed files with 69 additions and 46 deletions
|
|
@ -31,7 +31,13 @@ class Post < ActiveRecord::Base
|
||||||
t.add :root
|
t.add :root
|
||||||
t.add :o_embed_cache
|
t.add :o_embed_cache
|
||||||
t.add :user_like
|
t.add :user_like
|
||||||
t.add :photos
|
t.add lambda { |post|
|
||||||
|
if post.photos_count > 0
|
||||||
|
post.photos
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
}, :as => :photos
|
||||||
end
|
end
|
||||||
|
|
||||||
xml_attr :provider_display_name
|
xml_attr :provider_display_name
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
<div class="info">
|
<div class="info">
|
||||||
|
<span class="post_scope">
|
||||||
|
<%= public ? "Public" : "Limited" %>
|
||||||
|
</span>
|
||||||
|
–
|
||||||
|
|
||||||
<a href="#" class="like_action" rel='nofollow'>
|
<a href="#" class="like_action" rel='nofollow'>
|
||||||
<%= user_like ? "Unlike" : "Like" %>
|
<%= user_like ? "Unlike" : "Like" %>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,9 @@ class Stream::Base
|
||||||
protected
|
protected
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def like_posts_for_stream!(posts)
|
def like_posts_for_stream!(posts)
|
||||||
likes = Like.where(:target_id => posts.map(&:id), :target_type => "Post")
|
return posts unless @user
|
||||||
|
|
||||||
|
likes = Like.where(:author_id => @user.person.id, :target_id => posts.map(&:id), :target_type => "Post")
|
||||||
|
|
||||||
like_hash = likes.inject({}) do |hash, like|
|
like_hash = likes.inject({}) do |hash, like|
|
||||||
hash[like.target_id] = like
|
hash[like.target_id] = like
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ describe("app.views.Feedback", function(){
|
||||||
this.link = function(){ return this.view.$(".like_action"); }
|
this.link = function(){ return this.view.$(".like_action"); }
|
||||||
})
|
})
|
||||||
|
|
||||||
|
context("likes", function(){
|
||||||
context("when the user likes the post", function(){
|
context("when the user likes the post", function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.view.render();
|
this.view.render();
|
||||||
|
|
@ -70,6 +71,7 @@ describe("app.views.Feedback", function(){
|
||||||
expect(this.link().text()).toContain('Like');
|
expect(this.link().text()).toContain('Like');
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
context("when the post is public", function(){
|
context("when the post is public", function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
|
|
@ -77,6 +79,10 @@ describe("app.views.Feedback", function(){
|
||||||
this.view.render();
|
this.view.render();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("shows 'Public'", function(){
|
||||||
|
expect($(this.view.el).html()).toContain('Public')
|
||||||
|
})
|
||||||
|
|
||||||
it("shows a reshare_action link", function(){
|
it("shows a reshare_action link", function(){
|
||||||
expect($(this.view.el).html()).toContain('reshare_action')
|
expect($(this.view.el).html()).toContain('reshare_action')
|
||||||
});
|
});
|
||||||
|
|
@ -96,6 +102,10 @@ describe("app.views.Feedback", function(){
|
||||||
this.view.render();
|
this.view.render();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("shows 'Limited'", function(){
|
||||||
|
expect($(this.view.el).html()).toContain('Limited')
|
||||||
|
})
|
||||||
|
|
||||||
it("does not show a reshare_action link", function(){
|
it("does not show a reshare_action link", function(){
|
||||||
expect($(this.view.el).html()).not.toContain('reshare_action');
|
expect($(this.view.el).html()).not.toContain('reshare_action');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue