From 8b1f0453a105ed923582a28b7ff0345aeadd9c51 Mon Sep 17 00:00:00 2001 From: Sakshi Jain Date: Fri, 16 Jan 2015 15:04:11 +0530 Subject: [PATCH] 5560 Hide community spotlight setting if not enabled --- app/views/aspects/_no_contacts_message.haml | 3 ++- app/views/users/edit.html.haml | 7 ++++--- spec/controllers/users_controller_spec.rb | 12 ++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/views/aspects/_no_contacts_message.haml b/app/views/aspects/_no_contacts_message.haml index 30aa0d3bd..a3977ddc1 100644 --- a/app/views/aspects/_no_contacts_message.haml +++ b/app/views/aspects/_no_contacts_message.haml @@ -7,5 +7,6 @@ %br %br = t('.try_adding_some_more_contacts') - != t('.or_spotlight', :link => link_to(t(".community_spotlight") , community_spotlight_path)) + - if AppConfig.settings.community_spotlight.enable? + != t('.or_spotlight', :link => link_to(t(".community_spotlight") , community_spotlight_path)) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 38645adcf..39b992f82 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -85,9 +85,10 @@ = f.fields_for :stream_preferences do |type| #stream_prefs - = f.label :show_community_spotlight_in_stream, :class => "checkbox" do - = f.check_box :show_community_spotlight_in_stream - = t('.show_community_spotlight') + - if AppConfig.settings.community_spotlight.enable? + = f.label :show_community_spotlight_in_stream, :class => "checkbox" do + = f.check_box :show_community_spotlight_in_stream + = t('.show_community_spotlight') .small-horizontal-spacer = f.label :getting_started, :class => "checkbox" do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 82a3561a8..daf46e1e1 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -215,6 +215,18 @@ describe UsersController, :type => :controller do expect(response.status).to eq(200) end + it 'displays community spotlight checkbox' do + AppConfig.settings.community_spotlight.enable = true + get 'edit', :id => @user.id + expect(response.body).to include('input name="user[show_community_spotlight_in_stream]"') + end + + it 'hides community spotlight checkbox' do + AppConfig.settings.community_spotlight = false + get 'edit', :id => @user.id + expect(response.body).not_to include('input name="user[show_community_spotlight_in_stream]"') + end + it 'set @email_pref to false when there is a user pref' do @user.user_preferences.create(:email_type => 'mentioned') get 'edit', :id => @user.id