diff --git a/app/helpers/statistics_helper.rb b/app/helpers/statistics_helper.rb index 6c75e9e5e..1cbe5aff3 100644 --- a/app/helpers/statistics_helper.rb +++ b/app/helpers/statistics_helper.rb @@ -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') diff --git a/app/presenters/statistics_presenter.rb b/app/presenters/statistics_presenter.rb index f522b911f..dd766f02c 100644 --- a/app/presenters/statistics_presenter.rb +++ b/app/presenters/statistics_presenter.rb @@ -31,7 +31,7 @@ class StatisticsPresenter end def open_registrations? - AppConfig.settings.enable_registrations + AppConfig.settings.enable_registrations? end def user_counts @@ -122,4 +122,4 @@ class StatisticsPresenter } end -end +end \ No newline at end of file diff --git a/app/views/statistics/_statistics.haml b/app/views/statistics/_statistics.haml index 108646fb0..28626eed3 100644 --- a/app/views/statistics/_statistics.haml +++ b/app/views/statistics/_statistics.haml @@ -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" diff --git a/spec/presenters/statistics_presenter_spec.rb b/spec/presenters/statistics_presenter_spec.rb index 22a1233f1..1dd94dff1 100644 --- a/spec/presenters/statistics_presenter_spec.rb +++ b/spec/presenters/statistics_presenter_spec.rb @@ -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