summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-10 17:08:10 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-06-16 12:52:04 -0400
commit8dfe01cbb0dd5c0c271176150193293ecdf57cd3 (patch)
treea3e161fd5b21f3dff8ddc0d743c2606ba2f03d84
parent878732b4264eeba0214964da096b6f8c139f6900 (diff)
downloadgitlab-ce-8dfe01cbb0dd5c0c271176150193293ecdf57cd3.tar.gz
Add feature specs for default dashboard preference
cherry-picked
-rw-r--r--app/views/profiles/preferences/show.html.haml2
-rw-r--r--app/views/profiles/preferences/update.js.erb5
-rw-r--r--spec/features/profiles/preferences_spec.rb57
3 files changed, 54 insertions, 10 deletions
diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml
index 773a324e1a0..db4d1dbe2ae 100644
--- a/app/views/profiles/preferences/show.html.haml
+++ b/app/views/profiles/preferences/show.html.haml
@@ -60,7 +60,7 @@
Behavior
.panel-body
.form-group
- = f.label :dashboard, class: 'control-label'
+ = f.label :dashboard, 'Default Dashboard', class: 'control-label'
.col-sm-10
= f.select :dashboard, dashboard_choices, {}, class: 'form-control'
%p.help-block.hint
diff --git a/app/views/profiles/preferences/update.js.erb b/app/views/profiles/preferences/update.js.erb
index ad4118eabc1..5b7b92aac41 100644
--- a/app/views/profiles/preferences/update.js.erb
+++ b/app/views/profiles/preferences/update.js.erb
@@ -1,4 +1,9 @@
// Remove body class for any previous theme, re-add current one
$('body').removeClass('<%= Gitlab::Theme.body_classes %>')
$('body').addClass('<%= app_theme %> <%= theme_type %>')
+
+// Re-enable the "Save" button
+$('input[type=submit]').enable()
+
+// Show the notice flash message
new Flash('<%= flash.discard(:notice) %>', 'notice')
diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/preferences_spec.rb
index 04aa64343d5..dcef436c573 100644
--- a/spec/features/profiles/preferences_spec.rb
+++ b/spec/features/profiles/preferences_spec.rb
@@ -5,22 +5,25 @@ describe 'Profile > Preferences' do
before do
login_as(user)
+ visit profile_preferences_path
end
describe 'User changes their application theme', js: true do
let(:default_class) { Gitlab::Theme.css_class_by_id(nil) }
let(:theme_5_class) { Gitlab::Theme.css_class_by_id(5) }
- before do
- visit profile_preferences_path
+ it 'creates a flash message' do
+ choose "user_theme_id_#{theme.id}"
+
+ expect_preferences_saved_message
end
- it 'creates a flash message' do
+ it 'updates their preference' do
choose "user_theme_id_#{theme.id}"
- within('.flash-container') do
- expect(page).to have_content('Preferences saved.')
- end
+ visit page.current_path
+
+ expect(page).to have_checked_field("user_theme_id_#{theme.id}")
end
it 'reflects the changes immediately' do
@@ -33,9 +36,45 @@ describe 'Profile > Preferences' do
end
end
- describe 'User changes their syntax highlighting theme' do
- before do
- visit profile_preferences_path
+ describe 'User changes their syntax highlighting theme', js: true do
+ it 'creates a flash message' do
+ choose 'user_color_scheme_id_5'
+
+ expect_preferences_saved_message
+ end
+
+ it 'updates their preference' do
+ choose 'user_color_scheme_id_5'
+
+ visit page.current_path
+
+ expect(page).to have_checked_field('user_color_scheme_id_5')
+ end
+ end
+
+ describe 'User changes their default dashboard' do
+ it 'creates a flash message' do
+ select 'Starred Projects', from: 'user_dashboard'
+ click_button 'Save'
+
+ expect_preferences_saved_message
+ end
+
+ it 'updates their preference' do
+ select 'Starred Projects', from: 'user_dashboard'
+ click_button 'Save'
+
+ click_link 'Dashboard'
+ expect(page.current_path).to eq starred_dashboard_projects_path
+
+ click_link 'Your Projects'
+ expect(page.current_path).to eq dashboard_path
+ end
+ end
+
+ def expect_preferences_saved_message
+ within('.flash-container') do
+ expect(page).to have_content('Preferences saved.')
end
end
end