summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-06-05 13:57:01 -0400
committerRobert Speicher <rspeicher@gmail.com>2015-06-16 12:51:23 -0400
commit3cae81a5975bf3cc6941a3d8e9cb0900d154446f (patch)
treef0b9cf9a74572d3087901b0619578d38a0e399ed
parent471ea73a56fcac4118e7161eeeec845ba831b104 (diff)
downloadgitlab-ce-3cae81a5975bf3cc6941a3d8e9cb0900d154446f.tar.gz
Move the "Design" templates and logic to Preferences
cherry-picked
-rw-r--r--app/assets/javascripts/profile.js.coffee2
-rw-r--r--app/controllers/profiles/preferences_controller.rb5
-rw-r--r--app/controllers/profiles_controller.rb22
-rw-r--r--app/views/profiles/design.html.haml56
-rw-r--r--app/views/profiles/preferences/show.html.haml57
-rw-r--r--app/views/profiles/preferences/update.js.erb4
-rw-r--r--app/views/profiles/update.js.erb3
-rw-r--r--config/routes.rb1
-rw-r--r--features/profile/profile.feature13
-rw-r--r--features/steps/profile/profile.rb21
-rw-r--r--spec/features/profiles/preferences_spec.rb33
11 files changed, 112 insertions, 105 deletions
diff --git a/app/assets/javascripts/profile.js.coffee b/app/assets/javascripts/profile.js.coffee
index 40459a9a155..a402973a543 100644
--- a/app/assets/javascripts/profile.js.coffee
+++ b/app/assets/javascripts/profile.js.coffee
@@ -4,7 +4,7 @@ class @Profile
# Submit the form
$('.edit_user').submit()
- new Flash("Appearance settings saved", "notice")
+ new Flash('Preferences saved.', 'notice')
$('.update-username form').on 'ajax:before', ->
$('.loading-gif').show()
diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb
index 897e6fe074d..8b2630d1648 100644
--- a/app/controllers/profiles/preferences_controller.rb
+++ b/app/controllers/profiles/preferences_controller.rb
@@ -24,6 +24,9 @@ class Profiles::PreferencesController < Profiles::ApplicationController
end
def preferences_params
- params.require(:user).permit(:color_scheme_id, :theme_id)
+ params.require(:user).permit(
+ :color_scheme_id,
+ :theme_id
+ )
end
end
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index f4366c18e7b..88e87996277 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -8,9 +8,6 @@ class ProfilesController < Profiles::ApplicationController
def show
end
- def design
- end
-
def applications
@applications = current_user.oauth_applications
@authorized_tokens = current_user.oauth_authorized_tokens
@@ -65,10 +62,21 @@ class ProfilesController < Profiles::ApplicationController
def user_params
params.require(:user).permit(
- :email, :password, :password_confirmation, :bio, :name,
- :username, :skype, :linkedin, :twitter, :website_url,
- :color_scheme_id, :theme_id, :avatar, :hide_no_ssh_key,
- :hide_no_password, :location, :public_email
+ :avatar,
+ :bio,
+ :email,
+ :hide_no_password,
+ :hide_no_ssh_key,
+ :linkedin,
+ :location,
+ :name,
+ :password,
+ :password_confirmation,
+ :public_email,
+ :skype,
+ :twitter,
+ :username,
+ :website_url
)
end
end
diff --git a/app/views/profiles/design.html.haml b/app/views/profiles/design.html.haml
deleted file mode 100644
index f450ec1c018..00000000000
--- a/app/views/profiles/design.html.haml
+++ /dev/null
@@ -1,56 +0,0 @@
-- page_title "Design"
-%h3.page-title
- = page_title
-%p.light
- Appearance settings will be saved to your profile and made available across all devices.
-%hr
-
-= form_for @user, url: profile_path, remote: true, method: :put do |f|
- .panel.panel-default.application-theme
- .panel-heading
- Application theme
- .panel-body
- .themes_opts
- = label_tag do
- .prev.default
- = f.radio_button :theme_id, 1
- Graphite
-
- = label_tag do
- .prev.classic
- = f.radio_button :theme_id, 2
- Charcoal
-
- = label_tag do
- .prev.modern
- = f.radio_button :theme_id, 3
- Green
-
- = label_tag do
- .prev.gray
- = f.radio_button :theme_id, 4
- Gray
-
- = label_tag do
- .prev.violet
- = f.radio_button :theme_id, 5
- Violet
-
- = label_tag do
- .prev.blue
- = f.radio_button :theme_id, 6
- Blue
- %br
- .clearfix
-
- .panel.panel-default.code-preview-theme
- .panel-heading
- Code preview theme
- .panel-body
- .code_highlight_opts
- - color_schemes.each do |color_scheme_id, color_scheme|
- = label_tag do
- .prev
- = image_tag "#{color_scheme}-scheme-preview.png"
- = f.radio_button :color_scheme_id, color_scheme_id
- = color_scheme.gsub(/[-_]+/, ' ').humanize
diff --git a/app/views/profiles/preferences/show.html.haml b/app/views/profiles/preferences/show.html.haml
index 1333ed77b7e..2fc47227c38 100644
--- a/app/views/profiles/preferences/show.html.haml
+++ b/app/views/profiles/preferences/show.html.haml
@@ -1 +1,56 @@
-TODO
+- page_title "Design"
+%h3.page-title
+ = page_title
+%p.light
+ Appearance settings will be saved to your profile and made available across all devices.
+%hr
+
+= form_for @user, url: profile_preferences_path, remote: true, method: :put do |f|
+ .panel.panel-default.application-theme
+ .panel-heading
+ Application theme
+ .panel-body
+ .themes_opts
+ = label_tag do
+ .prev.default
+ = f.radio_button :theme_id, 1
+ Graphite
+
+ = label_tag do
+ .prev.classic
+ = f.radio_button :theme_id, 2
+ Charcoal
+
+ = label_tag do
+ .prev.modern
+ = f.radio_button :theme_id, 3
+ Green
+
+ = label_tag do
+ .prev.gray
+ = f.radio_button :theme_id, 4
+ Gray
+
+ = label_tag do
+ .prev.violet
+ = f.radio_button :theme_id, 5
+ Violet
+
+ = label_tag do
+ .prev.blue
+ = f.radio_button :theme_id, 6
+ Blue
+ %br
+ .clearfix
+
+ .panel.panel-default.code-preview-theme
+ .panel-heading
+ Code preview theme
+ .panel-body
+ .code_highlight_opts
+ - color_schemes.each do |color_scheme_id, color_scheme|
+ = label_tag do
+ .prev
+ = image_tag "#{color_scheme}-scheme-preview.png"
+ = f.radio_button :color_scheme_id, color_scheme_id
+ = color_scheme.gsub(/[-_]+/, ' ').humanize
diff --git a/app/views/profiles/preferences/update.js.erb b/app/views/profiles/preferences/update.js.erb
index 70b786d12ed..db37619136d 100644
--- a/app/views/profiles/preferences/update.js.erb
+++ b/app/views/profiles/preferences/update.js.erb
@@ -1 +1,3 @@
-// TODO
+// Remove body class for any previous theme, re-add current one
+$('body').removeClass('<%= Gitlab::Theme.body_classes %>')
+$('body').addClass('<%= app_theme %> <%= theme_type %>')
diff --git a/app/views/profiles/update.js.erb b/app/views/profiles/update.js.erb
deleted file mode 100644
index db37619136d..00000000000
--- a/app/views/profiles/update.js.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-// Remove body class for any previous theme, re-add current one
-$('body').removeClass('<%= Gitlab::Theme.body_classes %>')
-$('body').addClass('<%= app_theme %> <%= theme_type %>')
diff --git a/config/routes.rb b/config/routes.rb
index 9b1a746f548..52c98541daf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -203,7 +203,6 @@ Gitlab::Application.routes.draw do
resource :profile, only: [:show, :update] do
member do
get :history
- get :design
get :applications
put :reset_private_token
diff --git a/features/profile/profile.feature b/features/profile/profile.feature
index d586167cdf5..0dd0afde8b1 100644
--- a/features/profile/profile.feature
+++ b/features/profile/profile.feature
@@ -84,16 +84,3 @@ Feature: Profile
Then I visit profile applications page
And I click to remove application
Then I see that application is removed
-
- @javascript
- Scenario: I change my application theme
- Given I visit profile design page
- When I change my application theme
- Then I should see the theme change immediately
- And I should receive feedback that the changes were saved
-
- @javascript
- Scenario: I change my code preview theme
- Given I visit profile design page
- When I change my code preview theme
- Then I should receive feedback that the changes were saved
diff --git a/features/steps/profile/profile.rb b/features/steps/profile/profile.rb
index 32e6859eff7..649aea8e3f4 100644
--- a/features/steps/profile/profile.rb
+++ b/features/steps/profile/profile.rb
@@ -114,27 +114,6 @@ class Spinach::Features::Profile < Spinach::FeatureSteps
expect(page).to have_content "#{current_user.name} closed issue"
end
- step "I change my application theme" do
- page.within '.application-theme' do
- choose "Violet"
- end
- end
-
- step "I change my code preview theme" do
- page.within '.code-preview-theme' do
- choose "Solarized dark"
- end
- end
-
- step "I should see the theme change immediately" do
- expect(page).to have_selector('body.ui_color')
- expect(page).not_to have_selector('body.ui_basic')
- end
-
- step "I should receive feedback that the changes were saved" do
- expect(page).to have_content("saved")
- end
-
step 'my password is expired' do
current_user.update_attributes(password_expires_at: Time.now - 1.hour)
end
diff --git a/spec/features/profiles/preferences_spec.rb b/spec/features/profiles/preferences_spec.rb
new file mode 100644
index 00000000000..0e033652a9c
--- /dev/null
+++ b/spec/features/profiles/preferences_spec.rb
@@ -0,0 +1,33 @@
+require 'spec_helper'
+
+describe 'Profile > Preferences' do
+ let(:user) { create(:user) }
+
+ before do
+ login_as(user)
+ 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
+ end
+
+ it 'changes immediately' do
+ expect(page).to have_selector("body.#{default.css_class}")
+
+ choose "user_theme_id_#{theme.id}"
+
+ expect(page).not_to have_selector("body.#{default.css_class}")
+ expect(page).to have_selector("body.#{theme.css_class}")
+ end
+ end
+
+ describe 'User changes their syntax highlighting theme' do
+ before do
+ visit profile_preferences_path
+ end
+ end
+end