summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrett Walker <brett@digitalmoksha.com>2017-09-24 19:52:49 +0200
committerBrett Walker <brett@digitalmoksha.com>2017-09-24 19:52:49 +0200
commitd97b577a1bee80bd79209d2e6d501d1cd93debcc (patch)
tree660edfe661e2e8c3e14aa3a1986dfecc70eb7d46
parentd7d335c05b9ae359b72f59c31bbe5ed059df7f52 (diff)
downloadgitlab-ce-d97b577a1bee80bd79209d2e6d501d1cd93debcc.tar.gz
must now set the devise default scope (since we now have an :email scope)
and rubocop fixes
-rw-r--r--app/models/email.rb2
-rw-r--r--app/models/user.rb2
-rw-r--r--config/initializers/devise.rb2
-rw-r--r--spec/controllers/profiles_controller_spec.rb2
-rw-r--r--spec/models/email_spec.rb2
-rw-r--r--spec/models/user_spec.rb6
6 files changed, 8 insertions, 8 deletions
diff --git a/app/models/email.rb b/app/models/email.rb
index 041fbbfbe44..384f38f2db7 100644
--- a/app/models/email.rb
+++ b/app/models/email.rb
@@ -21,7 +21,7 @@ class Email < ActiveRecord::Base
def unique_email
self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end
-
+
# once email is confirmed, update the gpg signatures
def update_invalid_gpg_signatures
user.update_invalid_gpg_signatures if confirmed?
diff --git a/app/models/user.rb b/app/models/user.rb
index 0f6144f9250..c6b2baea8e8 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -223,7 +223,7 @@ class User < ActiveRecord::Base
end
end
- # see if the new email is already a verified secondary email
+ # see if the new email is already a verified secondary email
def check_for_verified_email
skip_reconfirmation! if emails.find_by(email: self.email).try(:confirmed?)
end
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 3aed2136f1b..2ca02c16497 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -175,7 +175,7 @@ Devise.setup do |config|
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user).
- # config.default_scope = :user
+ config.default_scope = :user # now have an :email scope as well, so set the default
# Configure sign_out behavior.
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 3fb631a6fac..ce5040ff02b 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -17,7 +17,7 @@ describe ProfilesController do
it "allows an email update without confirmation if existing verified email" do
user = create(:user)
- email = create(:email, :confirmed, user: user, email: 'john@gmail.com')
+ create(:email, :confirmed, user: user, email: 'john@gmail.com')
sign_in(user)
put :update,
diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb
index 7c88b544d3c..3fd3fe03be5 100644
--- a/spec/models/email_spec.rb
+++ b/spec/models/email_spec.rb
@@ -26,7 +26,7 @@ describe Email do
email.confirm
end
end
-
+
describe 'scopes' do
let(:user) { create(:user) }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 839b1f5da79..9ed155b0fa0 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -359,11 +359,11 @@ describe User do
expect(external_user.projects_limit).to be 0
end
end
-
+
describe '#check_for_verified_email' do
let(:user) { create(:user) }
- let(:secondary) { create(:email, :confirmed, email: 'secondary@example.com', user: user, ) }
-
+ let(:secondary) { create(:email, :confirmed, email: 'secondary@example.com', user: user) }
+
it 'allows a verfied secondary email to be used as the primary without needing reconfirmation' do
user.update_attributes!(email: secondary.email)
user.reload