diff --git a/app/models/post.rb b/app/models/post.rb
index 5699ac19e..8cfee8d0b 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -31,7 +31,13 @@ class Post < ActiveRecord::Base
t.add :root
t.add :o_embed_cache
t.add :user_like
- t.add :photos
+ t.add lambda { |post|
+ if post.photos_count > 0
+ post.photos
+ else
+ []
+ end
+ }, :as => :photos
end
xml_attr :provider_display_name
diff --git a/app/views/templates/feedback.jst b/app/views/templates/feedback.jst
index fca230265..d2a7d84d7 100644
--- a/app/views/templates/feedback.jst
+++ b/app/views/templates/feedback.jst
@@ -1,4 +1,9 @@
+
+ <%= public ? "Public" : "Limited" %>
+
+ –
+
<%= user_like ? "Unlike" : "Like" %>
diff --git a/lib/stream/base.rb b/lib/stream/base.rb
index 6332915b2..869c0dab6 100644
--- a/lib/stream/base.rb
+++ b/lib/stream/base.rb
@@ -114,7 +114,9 @@ class Stream::Base
protected
# @return [void]
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|
hash[like.target_id] = like
diff --git a/spec/javascripts/app/views/feedback_view_spec.js b/spec/javascripts/app/views/feedback_view_spec.js
index d22e547c4..9d70722e8 100644
--- a/spec/javascripts/app/views/feedback_view_spec.js
+++ b/spec/javascripts/app/views/feedback_view_spec.js
@@ -13,61 +13,63 @@ describe("app.views.Feedback", function(){
this.link = function(){ return this.view.$(".like_action"); }
})
- context("when the user likes the post", function(){
- beforeEach(function(){
- this.view.render();
+ context("likes", function(){
+ context("when the user likes the post", function(){
+ beforeEach(function(){
+ this.view.render();
+ })
+
+ it("the like action should be 'Unlike'", function(){
+ expect(this.link().text()).toContain('Unlike');
+ })
+
+ it("removes like when Unlike is clicked", function() {
+ var likeModel = new app.models.Like(this.view.model.get("user_like"));
+ spyOn(this.view.model.likes, "get").andReturn(likeModel);
+ spyOn(likeModel, "destroy");
+
+ this.link().click();
+ expect(likeModel.destroy).toHaveBeenCalled();
+ })
})
- it("the like action should be 'Unlike'", function(){
- expect(this.link().text()).toContain('Unlike');
- })
+ context("when the user doesn't yet like the post", function(){
+ beforeEach(function(){
+ this.view.model.set({user_like : null});
+ this.view.render();
+ })
- it("removes like when Unlike is clicked", function() {
- var likeModel = new app.models.Like(this.view.model.get("user_like"));
- spyOn(this.view.model.likes, "get").andReturn(likeModel);
- spyOn(likeModel, "destroy");
+ it("contains a .like_action", function(){
+ expect($(this.view.el).html()).toContain("like_action");
+ })
- this.link().click();
- expect(likeModel.destroy).toHaveBeenCalled();
- })
- })
+ it("the like action should be 'Like'", function(){
+ expect(this.link().text()).toContain('Like');
+ })
- context("when the user doesn't yet like the post", function(){
- beforeEach(function(){
- this.view.model.set({user_like : null});
- this.view.render();
- })
+ it("allows for unliking a just-liked post", function(){
+ var like = new app.models.Like({id : 2});
- it("contains a .like_action", function(){
- expect($(this.view.el).html()).toContain("like_action");
- })
+ spyOn(this.post.likes, "create").andReturn(like);
- it("the like action should be 'Like'", function(){
- expect(this.link().text()).toContain('Like');
- })
+ expect(this.link().text()).toContain('Like');
+ this.link().click();
- it("allows for unliking a just-liked post", function(){
- var like = new app.models.Like({id : 2});
+ this.view.render();
+ expect(this.link().text()).toContain('Unlike');
- spyOn(this.post.likes, "create").andReturn(like);
+ // spying + stubbing for destroy
+ var likeModel = new app.models.Like(this.view.model.get("user_like"));
+ spyOn(this.view.model.likes, "get").andReturn(likeModel);
+ spyOn(likeModel, "destroy").andReturn(function(){
+ this.view.model.set({user_like : null})
+ });
- expect(this.link().text()).toContain('Like');
- this.link().click();
+ this.link().click();
- this.view.render();
- expect(this.link().text()).toContain('Unlike');
-
- // spying + stubbing for destroy
- var likeModel = new app.models.Like(this.view.model.get("user_like"));
- spyOn(this.view.model.likes, "get").andReturn(likeModel);
- spyOn(likeModel, "destroy").andReturn(function(){
- this.view.model.set({user_like : null})
- });
-
- this.link().click();
-
- this.view.render();
- expect(this.link().text()).toContain('Like');
+ this.view.render();
+ expect(this.link().text()).toContain('Like');
+ })
})
})
@@ -77,6 +79,10 @@ describe("app.views.Feedback", function(){
this.view.render();
})
+ it("shows 'Public'", function(){
+ expect($(this.view.el).html()).toContain('Public')
+ })
+
it("shows a reshare_action link", function(){
expect($(this.view.el).html()).toContain('reshare_action')
});
@@ -96,6 +102,10 @@ describe("app.views.Feedback", function(){
this.view.render();
})
+ it("shows 'Limited'", function(){
+ expect($(this.view.el).html()).toContain('Limited')
+ })
+
it("does not show a reshare_action link", function(){
expect($(this.view.el).html()).not.toContain('reshare_action');
});