Commit d97b577a authored by Brett Walker's avatar Brett Walker

must now set the devise default scope (since we now have an :email scope)

and rubocop fixes
parent d7d335c0
...@@ -21,7 +21,7 @@ class Email < ActiveRecord::Base ...@@ -21,7 +21,7 @@ class Email < ActiveRecord::Base
def unique_email def unique_email
self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email) self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
end end
# once email is confirmed, update the gpg signatures # once email is confirmed, update the gpg signatures
def update_invalid_gpg_signatures def update_invalid_gpg_signatures
user.update_invalid_gpg_signatures if confirmed? user.update_invalid_gpg_signatures if confirmed?
......
...@@ -223,7 +223,7 @@ class User < ActiveRecord::Base ...@@ -223,7 +223,7 @@ class User < ActiveRecord::Base
end end
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 def check_for_verified_email
skip_reconfirmation! if emails.find_by(email: self.email).try(:confirmed?) skip_reconfirmation! if emails.find_by(email: self.email).try(:confirmed?)
end end
......
...@@ -175,7 +175,7 @@ Devise.setup do |config| ...@@ -175,7 +175,7 @@ Devise.setup do |config|
# Configure the default scope given to Warden. By default it's the first # Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes (usually :user). # 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. # Configure sign_out behavior.
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope). # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
......
...@@ -17,7 +17,7 @@ describe ProfilesController do ...@@ -17,7 +17,7 @@ describe ProfilesController do
it "allows an email update without confirmation if existing verified email" do it "allows an email update without confirmation if existing verified email" do
user = create(:user) 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) sign_in(user)
put :update, put :update,
......
...@@ -26,7 +26,7 @@ describe Email do ...@@ -26,7 +26,7 @@ describe Email do
email.confirm email.confirm
end end
end end
describe 'scopes' do describe 'scopes' do
let(:user) { create(:user) } let(:user) { create(:user) }
......
...@@ -359,11 +359,11 @@ describe User do ...@@ -359,11 +359,11 @@ describe User do
expect(external_user.projects_limit).to be 0 expect(external_user.projects_limit).to be 0
end end
end end
describe '#check_for_verified_email' do describe '#check_for_verified_email' do
let(:user) { create(:user) } 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 it 'allows a verfied secondary email to be used as the primary without needing reconfirmation' do
user.update_attributes!(email: secondary.email) user.update_attributes!(email: secondary.email)
user.reload user.reload
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment