Merge pull request #5256 from jaywink/fix-services-statistics
Fix services in statistics.json.
This commit is contained in:
commit
7d656d32de
4 changed files with 27 additions and 13 deletions
|
|
@ -51,6 +51,7 @@ The default for including jQuery from a CDN has changed. If you want to continue
|
||||||
* Fix deformed getting started popover [#5227](https://github.com/diaspora/diaspora/pull/5227)
|
* Fix deformed getting started popover [#5227](https://github.com/diaspora/diaspora/pull/5227)
|
||||||
* Use correct locale for invitation subject [#5232](https://github.com/diaspora/diaspora/pull/5232)
|
* Use correct locale for invitation subject [#5232](https://github.com/diaspora/diaspora/pull/5232)
|
||||||
* Initial support for IDN emails
|
* Initial support for IDN emails
|
||||||
|
* Fix services settings reported by statistics.json [#5256](https://github.com/diaspora/diaspora/pull/5256)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)
|
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,8 @@ class StatisticsPresenter
|
||||||
if AppConfig.privacy.statistics.comment_counts?
|
if AppConfig.privacy.statistics.comment_counts?
|
||||||
result['local_comments'] = self.local_comments
|
result['local_comments'] = self.local_comments
|
||||||
end
|
end
|
||||||
|
Configuration::KNOWN_SERVICES.each do |service, options|
|
||||||
AppConfig.services.each do |service, options|
|
result[service.to_s] = AppConfig["services.#{service}.enable"]
|
||||||
result[service] = options ? !!options["enable"] : false
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
@ -33,5 +31,5 @@ class StatisticsPresenter
|
||||||
def local_comments
|
def local_comments
|
||||||
Comment.joins(:author).where("owner_id IS NOT null").count
|
Comment.joins(:author).where("owner_id IS NOT null").count
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
module Configuration
|
module Configuration
|
||||||
|
KNOWN_SERVICES = [:twitter, :tumblr, :facebook, :wordpress].freeze
|
||||||
|
|
||||||
module Methods
|
module Methods
|
||||||
def pod_uri
|
def pod_uri
|
||||||
return @pod_uri unless @pod_uri.nil?
|
return @pod_uri unless @pod_uri.nil?
|
||||||
|
|
@ -24,7 +26,7 @@ module Configuration
|
||||||
return @configured_services unless @configured_services.nil?
|
return @configured_services unless @configured_services.nil?
|
||||||
|
|
||||||
@configured_services = []
|
@configured_services = []
|
||||||
[:twitter, :tumblr, :facebook, :wordpress].each do |service|
|
KNOWN_SERVICES.each do |service|
|
||||||
@configured_services << service if services.send(service).enable?
|
@configured_services << service if services.send(service).enable?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,33 +13,46 @@ describe StatisticsPresenter do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#statistics contents' do
|
describe '#statistics contents' do
|
||||||
|
before do
|
||||||
it 'provides generic pod data in json' do
|
|
||||||
AppConfig.privacy.statistics.user_counts = false
|
AppConfig.privacy.statistics.user_counts = false
|
||||||
AppConfig.privacy.statistics.post_counts = false
|
AppConfig.privacy.statistics.post_counts = false
|
||||||
AppConfig.privacy.statistics.comment_counts = false
|
AppConfig.privacy.statistics.comment_counts = false
|
||||||
AppConfig.services = {"facebook" => nil}
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
AppConfig.privacy = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'provides generic pod data in json' do
|
||||||
expect(@presenter.as_json).to eq({
|
expect(@presenter.as_json).to eq({
|
||||||
"name" => AppConfig.settings.pod_name,
|
"name" => AppConfig.settings.pod_name,
|
||||||
"version" => AppConfig.version_string,
|
"version" => AppConfig.version_string,
|
||||||
"registrations_open" => AppConfig.settings.enable_registrations,
|
"registrations_open" => AppConfig.settings.enable_registrations,
|
||||||
"facebook" => false
|
"facebook" => true,
|
||||||
|
"twitter" => false,
|
||||||
|
"tumblr" => false,
|
||||||
|
"wordpress" => false,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when services are enabled' do
|
context 'when services are enabled' do
|
||||||
before do
|
before do
|
||||||
AppConfig.privacy.statistics.user_counts = true
|
AppConfig.privacy.statistics.user_counts = true
|
||||||
AppConfig.privacy.statistics.post_counts = true
|
AppConfig.privacy.statistics.post_counts = true
|
||||||
AppConfig.privacy.statistics.comment_counts = true
|
AppConfig.privacy.statistics.comment_counts = true
|
||||||
AppConfig.services = {
|
AppConfig.services = {
|
||||||
"facebook" => {"enable" => true},
|
"facebook" => {"enable" => true},
|
||||||
"twitter" => {"enable" => true},
|
"twitter" => {"enable" => true},
|
||||||
"wordpress" => {"enable" => false},
|
"wordpress" => {"enable" => false},
|
||||||
"tumblr" => {"enable" => false}
|
"tumblr" => {"enable" => false}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
AppConfig.services = nil
|
||||||
|
AppConfig.privacy = nil
|
||||||
|
end
|
||||||
|
|
||||||
it 'provides generic pod data and counts in json' do
|
it 'provides generic pod data and counts in json' do
|
||||||
expect(@presenter.as_json).to eq({
|
expect(@presenter.as_json).to eq({
|
||||||
"name" => AppConfig.settings.pod_name,
|
"name" => AppConfig.settings.pod_name,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue