Skip to content

Commit

Permalink
On reshare insert the reshare built from the response
Browse files Browse the repository at this point in the history
Also make sure comments_count and the like is always set in the
response.
  • Loading branch information
jhass committed Mar 23, 2015
1 parent 4297733 commit 73b6c75
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/app/models/post/interactions.js
Expand Up @@ -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")
Expand Down
11 changes: 7 additions & 4 deletions app/presenters/post_presenter.rb
Expand Up @@ -101,10 +101,13 @@ def initialize(post, current_user)

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

Expand Down
12 changes: 6 additions & 6 deletions spec/locale_spec.rb
Expand Up @@ -4,24 +4,24 @@
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
rule.call(1)
}.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')
Expand All @@ -31,7 +31,7 @@
end
end
end

AVAILABLE_LANGUAGE_CODES.each do |locale|
["diaspora/#{locale}.yml",
"devise/devise.#{locale}.yml",
Expand Down

0 comments on commit 73b6c75

Please sign in to comment.