Fix registrations displaying

This commit is contained in:
Augier 2015-01-27 11:17:32 +00:00 committed by Augier
parent aaadf2926f
commit 55d258c5ac
4 changed files with 22 additions and 5 deletions

View file

@ -11,6 +11,14 @@ module StatisticsHelper
end
end
def registrations_status_class statistics
if statistics.open_registrations?
"serv-enabled"
else
"serv-disabled"
end
end
def service_status service, available_services
if available_services.include? service.to_s
I18n.t('statistics.enabled')

View file

@ -31,7 +31,7 @@ class StatisticsPresenter
end
def open_registrations?
AppConfig.settings.enable_registrations
AppConfig.settings.enable_registrations?
end
def user_counts

View file

@ -7,7 +7,7 @@
= t('_statistics')
= render 'statistics/statistic', name: t('statistics.name'), value: @statistics.name, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.version'), value: @statistics.version, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.registrations'), value: registrations_status(@statistics), activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.registrations'), value: registrations_status(@statistics), activated: registrations_status_class(@statistics)
- if @statistics.expose_user_counts?
= render 'statistics/statistic', name: t('statistics.total_users'), value: @statistics.total_users, activated: "serv-enabled"
= render 'statistics/statistic', name: t('statistics.active_users_halfyear'), value: @statistics.halfyear_users, activated: "serv-enabled"

View file

@ -24,7 +24,7 @@ describe StatisticsPresenter do
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
"registrations_open" => AppConfig.settings.enable_registrations,
"registrations_open" => AppConfig.settings.enable_registrations?,
"services"=> ["facebook",],
"facebook" => true,
"tumblr" => false,
@ -51,7 +51,7 @@ describe StatisticsPresenter do
"name" => AppConfig.settings.pod_name,
"network" => "Diaspora",
"version" => AppConfig.version_string,
"registrations_open" => AppConfig.settings.enable_registrations,
"registrations_open" => AppConfig.settings.enable_registrations?,
"total_users" => User.count,
"active_users_halfyear" => User.halfyear_actives.count,
"active_users_monthly" => User.monthly_actives.count,
@ -65,5 +65,14 @@ describe StatisticsPresenter do
})
end
end
context 'when registrations are closed' do
before do
AppConfig.settings.enable_registrations = false
end
it 'should mark open_registrations to be false' do
expect(@presenter.open_registrations?).to be false
end
end
end
end