From 73b6c7527881de2d8631a1aa34017bfc63fe0769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Mon, 23 Mar 2015 23:02:23 +0100 Subject: [PATCH] On reshare insert the reshare built from the response Also make sure comments_count and the like is always set in the response. --- .../javascripts/app/models/post/interactions.js | 2 +- app/presenters/post_presenter.rb | 11 +++++++---- spec/locale_spec.rb | 12 ++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/app/models/post/interactions.js b/app/assets/javascripts/app/models/post/interactions.js index dcbc3b4e3..f7457a521 100644 --- a/app/assets/javascripts/app/models/post/interactions.js +++ b/app/assets/javascripts/app/models/post/interactions.js @@ -104,7 +104,7 @@ app.models.Post.Interactions = Backbone.Model.extend({ , flash = new Diaspora.Widgets.FlashMessages(); reshare.save() - .done(function(){ + .done(function(reshare) { flash.render({ success: true, notice: Diaspora.I18n.t("reshares.successful") diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index 766961e96..90e074a6f 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -101,10 +101,13 @@ class PostInteractionPresenter def as_json(options={}) { - :likes => as_api(@post.likes), - :reshares => PostPresenter.collection_json(@post.reshares, @current_user), - :comments => CommentPresenter.as_collection(@post.comments.order('created_at ASC')), - :participations => as_api(@post.participations) + likes: as_api(@post.likes), + reshares: PostPresenter.collection_json(@post.reshares, @current_user), + comments: CommentPresenter.as_collection(@post.comments.order("created_at ASC")), + participations: as_api(@post.participations), + comments_count: @post.comments_count, + likes_count: @post.likes_count, + reshares_count: @post.reshares_count } end diff --git a/spec/locale_spec.rb b/spec/locale_spec.rb index ca36e8f68..18ee1864c 100644 --- a/spec/locale_spec.rb +++ b/spec/locale_spec.rb @@ -4,15 +4,15 @@ describe 'locale files' do describe "cldr/plurals.rb" do AVAILABLE_LANGUAGE_CODES.each do |locale| describe "#{locale} plural rules" do - it "defines the keys" do + it "defines the keys for #{locale}" do I18n.with_locale locale do expect { I18n.t 'i18n.plural.keys' }.to_not raise_error end end - - it "defines a valid pluralization function" do + + it "defines a valid pluralization function for #{locale}" do I18n.with_locale locale do expect { rule = I18n.t 'i18n.plural.rule', resolve: false @@ -20,8 +20,8 @@ describe 'locale files' do }.to_not raise_error end end - - it "defines a valid javascript pluralization function" do + + it "defines a valid javascript pluralization function for #{locale}" do I18n.with_locale locale do expect { ExecJS.eval I18n.t('i18n.plural.js_rule') @@ -31,7 +31,7 @@ describe 'locale files' do end end end - + AVAILABLE_LANGUAGE_CODES.each do |locale| ["diaspora/#{locale}.yml", "devise/devise.#{locale}.yml",