+ This post has been flagged as NSFW by its author.
+
+ <% } %>
+
@@ -46,13 +53,13 @@
<% } %>
- <%= public === true ? "Public" : "Limited" %>
+ <%= public ? "Public" : "Limited" %>
-
- <% if(user_like !== null) { %>
-
+ <% if(user_like) { %>
+
Unlike
<% } else { %>
@@ -63,6 +70,23 @@
·
+ <% if(public) { %>
+
+ <% if(root) {
+ var rootGuid = root.guid;
+ }
+ else {
+ var rootGuid = guid;
+ } %>
+
+ Reshare
+
+ ·
+
+ <% } %>
+
+
+
Comment
diff --git a/public/javascripts/app/views/reshare_view.js b/public/javascripts/app/views/reshare_view.js
deleted file mode 100644
index 5fc31672a..000000000
--- a/public/javascripts/app/views/reshare_view.js
+++ /dev/null
@@ -1,15 +0,0 @@
-App.Views.Reshare = Backbone.View.extend({
- initialize: function(options) {
- this.model = options.model;
- this.template = _.template($("#reshare-template").html());
- },
-
- render: function() {
- this.el = $(this.template($.extend(
- this.model.toJSON(),
- App.user()
- )));
-
- return this;
- }
-});
diff --git a/spec/javascripts/app/views/post_view_spec.js b/spec/javascripts/app/views/post_view_spec.js
index 160e4b114..c56cbf212 100644
--- a/spec/javascripts/app/views/post_view_spec.js
+++ b/spec/javascripts/app/views/post_view_spec.js
@@ -10,17 +10,66 @@ describe("App.views.Post", function(){
this.collection = new App.Collections.Stream(posts);
this.statusMessage = this.collection.models[0];
-
- this.view = new App.Views.Post({model : this.statusMessage}).render();
- this.statusElement = $(this.view.el)
})
- context("comment clicking", function(){
- it("shows the status message in the content area", function(){
- console.log(this.statusElement);
- //expect(this.statusElement).toBe("hella infos yo!")
+ context("NSFW", function(){
+ it("contains a shield element", function(){
+ this.statusMessage.set({text : "this is safe for work. #sfw"});
+
+ var view = new App.Views.Post({model : this.statusMessage}).render();
+ var statusElement = $(view.el)
+
+ expect(statusElement.find(".shield").html()).toBeNull();
+ })
+
+ it("does not contain a shield element", function(){
+ this.statusMessage.set({text : "nudie magazine day! #nsfw"});
+
+ var view = new App.Views.Post({model : this.statusMessage}).render();
+ var statusElement = $(view.el)
+
+ expect(statusElement.find(".shield").html()).toNotBe(null);
})
})
+ context("Reshare link", function(){
+ it("is present if the post is public", function(){
+ this.statusMessage.set({"public" : true});
+
+ var view = new App.Views.Post({model : this.statusMessage}).render();
+ var statusElement = $(view.el)
+
+ expect(statusElement.find(".reshare_action")).toNotBe(null);
+ })
+
+ it("is not present if the post is not public", function(){
+ this.statusMessage.set({"public" : false});
+
+ var view = new App.Views.Post({model : this.statusMessage}).render();
+ var statusElement = $(view.el)
+
+ expect(statusElement.find(".reshare_action").html()).toBeNull();
+ })
+ })
+
+ context("Like link", function(){
+ it("displays 'Unlike' if the current user has already liked the post", function(){
+ this.statusMessage.set({user_like : null});
+
+ var view = new App.Views.Post({model : this.statusMessage}).render();
+ var statusElement = $(view.el)
+
+ expect(statusElement.find(".like_action a").text()).toContain('Like');
+ })
+
+ it("displays 'Like' if the current user has not already liked the post", function(){
+ this.statusMessage.set({user_like : { id : 1 }});
+
+ var view = new App.Views.Post({model : this.statusMessage}).render();
+ var statusElement = $(view.el)
+
+ expect(statusElement.find(".like_action a").text()).toContain('Unlike');
+ })
+ })
})
})
diff --git a/spec/javascripts/app/views/stream_view_spec.js b/spec/javascripts/app/views/stream_view_spec.js
index 7715a7aa7..f25a7dd4b 100644
--- a/spec/javascripts/app/views/stream_view_spec.js
+++ b/spec/javascripts/app/views/stream_view_spec.js
@@ -20,13 +20,7 @@ describe("App.views.Stream", function(){
context("when rendering a Status Mesasage", function(){
it("shows the status message in the content area", function(){
- expect($.trim(this.statusElement.find(".post-content p").text())).toBe("hella infos yo!")
- })
- })
-
- context("when rendering a Reshare", function(){
- it("shows the reshare in the content area", function(){
- expect($.trim(this.reshareElement.find(".content h2").text())).toBe("this is a reshare");
+ expect(this.statusElement.find(".post-content p").text()).toContain("jimmy's 2 whales")
})
})
})