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();
reshare.save()
.done(function(){
.done(function(reshare) {
flash.render({
success: true,
notice: Diaspora.I18n.t("reshares.successful")

View file

@ -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

View file

@ -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",