diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 5040b85be0e990806e06086817887965093df56c..f235697911c1a2494754cc918a4a2f3bc9f86f29 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -4,6 +4,7 @@ class Reshare < Post validate :root_must_be_public attr_accessible :root_guid, :public validates_presence_of :root, :on => :create + validates_uniqueness_of :root_guid, :scope => :author_id xml_attr :root_diaspora_id xml_attr :root_guid @@ -40,12 +41,11 @@ class Reshare < Post fetched_post = self.class.fetch_post(root_author, self.root_guid) + #Why are we checking for this? if root_author.diaspora_handle != fetched_post.diaspora_handle raise "Diaspora ID (#{fetched_post.diaspora_handle}) in the root does not match the Diaspora ID (#{root_author.diaspora_handle}) specified in the reshare!" end - #Todo, this is a bug if it is necessary. The marshalling process should set the author. - fetched_post.author_id = root_author.id fetched_post.save! end diff --git a/app/views/reshares/_reshare.haml b/app/views/reshares/_reshare.haml index 2a71f683a42bbf93c97328c8c2f02a03ffb86764..1c773cdca7401db96e105a83cd65271fba257b7e 100644 --- a/app/views/reshares/_reshare.haml +++ b/app/views/reshares/_reshare.haml @@ -8,7 +8,7 @@ = person_image_link(post.author, :size => :thumb_small) .content - .right + .right = link_to "Show Original", post_path(post) %span.from = person_link(post.author, :class => "hovercardable") @@ -19,7 +19,7 @@ = render 'status_messages/status_message', :post => post, :photos => post.photos - if defined?(current_user) && current_user && (post.author_id != current_user.person.id) && (post.public?) && !reshare?(post) %span.reshare_action - = link_to "Reshare", reshares_path(:root_id => post.id), :method => :post, :remote => true, :confirm => "Reshare: #{post.author.name} - #{post.text}?" + = link_to "Reshare", reshares_path(:root_guid => post.guid), :method => :post, :remote => true, :confirm => "Reshare: #{post.author.name} - #{post.text}?" - else Original post deleted by author diff --git a/app/views/reshares/create.js.erb b/app/views/reshares/create.js.erb index 3c179af453d74dc62cb3372607f503d2e0826ba8..ec6f7e5157cfcc86c3da573f114709f84d6d1b56 100644 --- a/app/views/reshares/create.js.erb +++ b/app/views/reshares/create.js.erb @@ -1 +1,4 @@ -$('.stream_element[data-guid=<%=params[:root_guid]%>]').addClass('reshared'); +$('.stream_element#<%=params[:root_guid]%>').addClass('reshared'); +ContentUpdater.addPostToStream( + "<%= escape_javascript(render(:partial => 'shared/stream_element', :locals => {:post => @reshare }))=%>" +); diff --git a/spec/factories.rb b/spec/factories.rb index b637cc97deff2414166699872652f719bae5305f..ab39142e60711f23e11ab811d90d149a4d49c267 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -41,6 +41,7 @@ Factory.define :like do |x| end Factory.define :user do |u| + u.getting_started false u.sequence(:username) { |n| "bob#{n}#{r_str}" } u.sequence(:email) { |n| "bob#{n}#{r_str}@pivotallabs.com" } u.password "bluepin7"