Skip to content
Extraits de code Groupes Projets
Valider 9589cb2e rédigé par Hincu Petru's avatar Hincu Petru Validation de Steffen van Bergerem
Parcourir les fichiers

disable poll voting for reshared post

parent c3bf9dd8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -14,11 +14,14 @@ app.views.Poll = app.views.Base.extend({
presenter: function(){
var defaultPresenter = this.defaultPresenter();
var show_form = defaultPresenter.loggedIn &&
!this.model.attributes.already_participated_in_poll;
var isResharePost = (this.model.get('post_type') == 'Reshare');
var show_form = defaultPresenter.loggedIn &&
!isResharePost &&
!this.model.get('already_participated_in_poll');
return _.extend(defaultPresenter, {
show_form: show_form
show_form: show_form,
is_reshare_post: isResharePost
});
},
......@@ -97,7 +100,7 @@ app.views.Poll = app.views.Base.extend({
var pollParticipation = new app.models.PollParticipation({
poll_answer_id: answer_id,
poll_id: this.poll.poll_id,
post_id: this.poll.post_id,
post_id: this.poll.post_id,
});
var _this = this;
......
......@@ -37,6 +37,13 @@
</div>
{{/poll.poll_answers}}
{{/if}}
{{#if is_reshare_post }}
<div class="poll_footer">
<a class="root_post_link" href="/posts/{{root.id}}">{{t "poll.vote_original_post" }}</a>
</div>
{{/if}}
</div>
</div>
{{/if}}
......@@ -49,6 +49,10 @@ class Reshare < Post
absolute_root.try(:location).try(:address)
end
def poll
absolute_root.try(:poll) || super
end
def receive(recipient, sender)
local_reshare = Reshare.where(:guid => self.guid).first
if local_reshare && local_reshare.root.author_id == recipient.person.id
......
......@@ -227,6 +227,7 @@ en:
poll:
vote: "Vote"
vote_original_post: 'Vote original post'
result: "Result"
count:
one: "1 vote so far"
......
......@@ -44,6 +44,23 @@ describe("app.views.Poll", function(){
});
});
describe('reshared post', function(){
beforeEach(function(){
this.view.model.set('post_type', 'Reshare');
this.view.model.set('root', {id: 1});
this.view.render();
});
it('hide vote form', function(){
expect(this.view.$('form').length).toBe(0);
});
it("show a.root_post_link", function(){
var id = this.view.model.get('root').id;
expect(this.view.$('a.root_post_link').attr('href')).toBe('/posts/'+id);
});
});
describe("vote form", function(){
it('show vote form when user is logged in and not voted before', function(){
expect(this.view.$('form').length).toBe(1);
......
......@@ -63,6 +63,17 @@ describe Reshare, :type => :model do
end
end
describe '#poll' do
before do
@root_post = FactoryGirl.create(:status_message_with_poll, public: true)
@reshare = FactoryGirl.create(:reshare, root: @root_post)
end
it 'contains root poll' do
@reshare.poll == @root_post.poll
end
end
describe '#notification_type' do
before do
sm = FactoryGirl.build(:status_message, :author => alice.person, :public => true)
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter