Merge pull request #5121 from wegotcoders/4943-add-services-to-statistics-json
Service have been added to /statistics.json
This commit is contained in:
commit
fa9c079955
3 changed files with 41 additions and 18 deletions
|
|
@ -32,6 +32,7 @@
|
|||
* Automatically add poll answers as needed [#5109](https://github.com/diaspora/diaspora/pull/5109)
|
||||
* Add Terms of Service as an option for podmins, includes base template [#5104](https://github.com/diaspora/diaspora/pull/5104)
|
||||
* Add rake task to send a mail to all users [#5111](https://github.com/diaspora/diaspora/pull/5111)
|
||||
* Expose which services are configured in /statistics.json [#5121](https://github.com/diaspora/diaspora/pull/5121)
|
||||
|
||||
# 0.4.0.1
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,12 @@ class StatisticsPresenter
|
|||
if AppConfig.privacy.statistics.comment_counts?
|
||||
result['local_comments'] = self.local_comments
|
||||
end
|
||||
|
||||
AppConfig.services.each do |service, options|
|
||||
result[service] = options ? !!options["enable"] : false
|
||||
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,18 +18,29 @@ describe StatisticsPresenter do
|
|||
AppConfig.privacy.statistics.user_counts = false
|
||||
AppConfig.privacy.statistics.post_counts = false
|
||||
AppConfig.privacy.statistics.comment_counts = false
|
||||
AppConfig.services = {"facebook" => nil}
|
||||
@presenter.as_json.should == {
|
||||
"name" => AppConfig.settings.pod_name,
|
||||
"version" => AppConfig.version_string,
|
||||
"registrations_open" => AppConfig.settings.enable_registrations
|
||||
"registrations_open" => AppConfig.settings.enable_registrations,
|
||||
"facebook" => false
|
||||
}
|
||||
end
|
||||
|
||||
context 'when services are enabled' do
|
||||
before do
|
||||
AppConfig.privacy.statistics.user_counts = true
|
||||
AppConfig.privacy.statistics.post_counts = true
|
||||
AppConfig.privacy.statistics.comment_counts = true
|
||||
AppConfig.services = {
|
||||
"facebook" => {"enable" => true},
|
||||
"twitter" => {"enable" => true},
|
||||
"wordpress" => {"enable" => false},
|
||||
"tumblr" => {"enable" => false}
|
||||
}
|
||||
end
|
||||
|
||||
it 'provides generic pod data and counts in json' do
|
||||
AppConfig.privacy.statistics.user_counts = true
|
||||
AppConfig.privacy.statistics.post_counts = true
|
||||
AppConfig.privacy.statistics.comment_counts = true
|
||||
|
||||
@presenter.as_json.should == {
|
||||
"name" => AppConfig.settings.pod_name,
|
||||
"version" => AppConfig.version_string,
|
||||
|
|
@ -38,9 +49,14 @@ describe StatisticsPresenter do
|
|||
"active_users_halfyear" => User.halfyear_actives.count,
|
||||
"active_users_monthly" => User.monthly_actives.count,
|
||||
"local_posts" => @presenter.local_posts,
|
||||
"local_comments" => @presenter.local_comments
|
||||
"local_comments" => @presenter.local_comments,
|
||||
"facebook" => true,
|
||||
"twitter" => true,
|
||||
"tumblr" => false,
|
||||
"wordpress" => false
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue