fixes for rubocop

This commit is contained in:
Brett Walker 2017-09-14 16:18:32 +02:00
parent a000c2a144
commit a32f1dddf2
5 changed files with 12 additions and 15 deletions

View File

@ -1,5 +1,4 @@
class Profiles::EmailsController < Profiles::ApplicationController
before_action :find_email, only: [:destroy, :resend_confirmation_instructions]
def index
@ -39,7 +38,7 @@ class Profiles::EmailsController < Profiles::ApplicationController
def email_params
params.require(:email).permit(:email)
end
def find_email
@email = current_user.emails.find(params[:id])
end

View File

@ -1,7 +1,7 @@
module Emails
class CreateService < ::Emails::BaseService
def execute(options = {})
@user.emails.create({email: @email}.merge(options))
@user.emails.create({ email: @email }.merge(options))
end
end
end

View File

@ -8,7 +8,7 @@ describe Profiles::EmailsController do
end
describe '#create' do
let(:email_params) { {email: "add_email@example.com"} }
let(:email_params) { { email: "add_email@example.com" } }
it 'sends an email confirmation' do
expect {post(:create, { email: email_params })}.to change { ActionMailer::Base.deliveries.size }
@ -18,7 +18,7 @@ describe Profiles::EmailsController do
end
describe '#resend_confirmation_instructions' do
let(:email_params) { {email: "add_email@example.com"} }
let(:email_params) { { email: "add_email@example.com" } }
it 'resends an email confirmation' do
email = user.emails.create(email: 'add_email@example.com')

View File

@ -88,17 +88,17 @@ describe GpgKey do
describe '#emails_with_verified_status' do
it 'email is verified if the user has the matching email' do
user = create :user, email: 'bette.cartwright@example.com'
user = create :user, email: 'bette.cartwright@example.com'
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
email_unconfirmed = create :email, user: user
create :email, user: user
user.reload
expect(gpg_key.emails_with_verified_status).to eq(
'bette.cartwright@example.com' => true,
'bette.cartwright@example.net' => false
'bette.cartwright@example.net' => false
)
email_confirmed = create :email, :confirmed, user: user, email: 'bette.cartwright@example.net'
create :email, :confirmed, user: user, email: 'bette.cartwright@example.net'
user.reload
expect(gpg_key.emails_with_verified_status).to eq(
'bette.cartwright@example.com' => true,

View File

@ -409,14 +409,12 @@ describe User do
end
it 'transfers old confirmation values into new secondary' do
org_user = @user
@user.update_attributes!(email: @secondary.email)
@user.reload
expect(@user.emails.count).to eq 1
expect(@user.emails.first.confirmed_at).not_to eq nil
end
end
end
describe '#update_tracked_fields!', :clean_gitlab_redis_shared_state do
@ -1146,8 +1144,8 @@ describe User do
let(:user) { create(:user) }
it 'returns only confirmed emails' do
email_confirmed = create :email, user: user, confirmed_at: Time.now
email_unconfirmed = create :email, user: user
email_confirmed = create :email, user: user, confirmed_at: Time.now
create :email, user: user
user.reload
expect(user.verified_emails).to match_array([user.email, email_confirmed.email])
end
@ -1157,8 +1155,8 @@ describe User do
let(:user) { create(:user) }
it 'returns true when the email is verified/confirmed' do
email_confirmed = create :email, user: user, confirmed_at: Time.now
email_unconfirmed = create :email, user: user
email_confirmed = create :email, user: user, confirmed_at: Time.now
create :email, user: user
user.reload
expect(user.verified_email?(user.email)).to be_truthy