On reshare insert the reshare built from the response

Also make sure comments_count and the like is always set in the
response.
This commit is contained in:
Jonne Haß 2015-03-23 23:02:23 +01:00
parent 42977333c4
commit 73b6c75278
3 changed files with 14 additions and 11 deletions

View file

@ -104,7 +104,7 @@ app.models.Post.Interactions = Backbone.Model.extend({
, flash = new Diaspora.Widgets.FlashMessages(); , flash = new Diaspora.Widgets.FlashMessages();
reshare.save() reshare.save()
.done(function(){ .done(function(reshare) {
flash.render({ flash.render({
success: true, success: true,
notice: Diaspora.I18n.t("reshares.successful") notice: Diaspora.I18n.t("reshares.successful")

View file

@ -101,10 +101,13 @@ class PostInteractionPresenter
def as_json(options={}) def as_json(options={})
{ {
:likes => as_api(@post.likes), likes: as_api(@post.likes),
:reshares => PostPresenter.collection_json(@post.reshares, @current_user), reshares: PostPresenter.collection_json(@post.reshares, @current_user),
:comments => CommentPresenter.as_collection(@post.comments.order('created_at ASC')), comments: CommentPresenter.as_collection(@post.comments.order("created_at ASC")),
:participations => as_api(@post.participations) participations: as_api(@post.participations),
comments_count: @post.comments_count,
likes_count: @post.likes_count,
reshares_count: @post.reshares_count
} }
end end

View file

@ -4,7 +4,7 @@ describe 'locale files' do
describe "cldr/plurals.rb" do describe "cldr/plurals.rb" do
AVAILABLE_LANGUAGE_CODES.each do |locale| AVAILABLE_LANGUAGE_CODES.each do |locale|
describe "#{locale} plural rules" do describe "#{locale} plural rules" do
it "defines the keys" do it "defines the keys for #{locale}" do
I18n.with_locale locale do I18n.with_locale locale do
expect { expect {
I18n.t 'i18n.plural.keys' I18n.t 'i18n.plural.keys'
@ -12,7 +12,7 @@ describe 'locale files' do
end end
end end
it "defines a valid pluralization function" do it "defines a valid pluralization function for #{locale}" do
I18n.with_locale locale do I18n.with_locale locale do
expect { expect {
rule = I18n.t 'i18n.plural.rule', resolve: false rule = I18n.t 'i18n.plural.rule', resolve: false
@ -21,7 +21,7 @@ describe 'locale files' do
end end
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 I18n.with_locale locale do
expect { expect {
ExecJS.eval I18n.t('i18n.plural.js_rule') ExecJS.eval I18n.t('i18n.plural.js_rule')