diff --git a/app/models/post.rb b/app/models/post.rb index 82b952e5c..387ce465e 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -62,13 +62,8 @@ class Post < ActiveRecord::Base self.class.name end - def raw_message - "" - end - - def mentioned_people - [] - end + def raw_message; ""; end + def mentioned_people; []; end # gives the last three comments on the post def last_three_comments diff --git a/app/models/reshare.rb b/app/models/reshare.rb index e7a0815d8..b4559b8fc 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -30,7 +30,11 @@ class Reshare < Post end def raw_message - self.root ? root.raw_message : "" + self.root ? root.raw_message : super + end + + def mentioned_people + self.root ? root.mentioned_people : super end def receive(recipient, sender) diff --git a/app/views/templates/reshare.jst b/app/views/templates/reshare.jst index 899964248..853c604f6 100644 --- a/app/views/templates/reshare.jst +++ b/app/views/templates/reshare.jst @@ -37,7 +37,7 @@ <% } %> <% } %> - <%= root.text %> + <%= text %> <% if(o_embed_cache) { %> <%= root.o_embed_cache.posts.data.html %> diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index ddff1c413..0f2689c55 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -16,7 +16,6 @@ describe PublicsController do get :host_meta response.should be_success response.body.should =~ /webfinger/ - puts "Saving host-meta fixture to #{fixture_path}" save_fixture(response.body, "host-meta", fixture_path) end end diff --git a/spec/javascripts/app/views/post_view_spec.js b/spec/javascripts/app/views/post_view_spec.js index db065d54a..d36581de9 100644 --- a/spec/javascripts/app/views/post_view_spec.js +++ b/spec/javascripts/app/views/post_view_spec.js @@ -15,6 +15,7 @@ describe("app.views.Post", function(){ this.collection = new app.collections.Stream(posts); this.statusMessage = this.collection.models[0]; + this.reshare = this.collection.models[1]; }) it("displays a reshare count", function(){ @@ -72,6 +73,17 @@ describe("app.views.Post", function(){ expect(view.$("h1:contains(parties)")).not.toExist(); expect(view.$("a:contains('#parties')")).toExist(); }) + + it("works on reshares", function(){ + this.statusMessage.set({text: "I love #parties"}) + var reshare = new app.models.Reshare(factory.post({ + text : this.statusMessage.get("text"), + root : this.statusMessage + })) + + var view = new app.views.Post({model : reshare}).render(); + expect(view.$("a:contains('#parties')").attr('href')).toBe('/tags/parties') + }) }) context("changes mention markup to links", function(){ @@ -87,23 +99,31 @@ describe("app.views.Post", function(){ diaspora_id : "bob@example.com", id : "666" }) + + this.statusMessage.set({mentioned_people : [this.alice, this.bob]}) + this.statusMessage.set({text: "hey there @{Alice Smith; alice@example.com} and @{Bob Grimm; bob@example.com}"}) }) it("links to the mentioned person's page", function(){ - this.statusMessage.set({mentioned_people : [this.alice]}) - this.statusMessage.set({text: "sup, @{Alice Smith; alice@example.com}?"}) - var view = new app.views.Post({model : this.statusMessage}).render(); expect(view.$("a:contains('Alice Smith')").attr('href')).toBe('/people/555') }) it("matches all mentions", function(){ - this.statusMessage.set({mentioned_people : [this.alice, this.bob]}) - this.statusMessage.set({text: "hey there @{Alice Smith; alice@example.com} and @{Bob Grimm; bob@example.com}"}) - var view = new app.views.Post({model : this.statusMessage}).render(); expect(view.$("a.mention").length).toBe(2) }) + + it("works on reshares", function(){ + var reshare = new app.models.Reshare(factory.post({ + text : this.statusMessage.get("text"), + mentioned_people : this.statusMessage.get("mentioned_people"), + root : this.statusMessage + })) + + var view = new app.views.Post({model : reshare}).render(); + expect(view.$("a.mention").length).toBe(2) + }) }) context("user not signed in", function(){