Fixed admin login spects

This commit is contained in:
Priit Tark 2015-05-20 17:58:07 +03:00
parent 9a20c73a40
commit 77d6ab93ce
13 changed files with 30 additions and 15 deletions

View file

@ -953,7 +953,7 @@ ActiveRecord::Schema.define(version: 20150519144118) do
t.text "crt" t.text "crt"
t.string "type" t.string "type"
t.string "registrant_ident" t.string "registrant_ident"
t.string "encrypted_password", default: "" t.string "encrypted_password", default: "", null: false
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.integer "failed_attempts", default: 0, null: false t.integer "failed_attempts", default: 0, null: false
t.datetime "locked_at" t.datetime "locked_at"

View file

@ -3,6 +3,7 @@
Fabricator(:admin_user) do Fabricator(:admin_user) do
username 'gitlab' username 'gitlab'
password 'ghyt9e4fu' password 'ghyt9e4fu'
password_confirmation 'ghyt9e4fu'
email 'info@gitlab.eu' email 'info@gitlab.eu'
country_code 'FI' country_code 'FI'
roles ['admin'] roles ['admin']
@ -11,6 +12,9 @@ end
Fabricator(:ee_user, from: :admin_user) do Fabricator(:ee_user, from: :admin_user) do
identity_code "45002036517" identity_code "45002036517"
country_code 'EE' country_code 'EE'
username 'user1'
password 'testtest'
password_confirmation 'testtest'
roles ['admin'] roles ['admin']
end end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Admin users', type: :feature do feature 'Admin users', type: :feature do
before :all do before :all do
@admin_user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @admin_user = Fabricate(:admin_user)
end end
context 'as unknown user' do context 'as unknown user' do

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Api users', type: :feature do feature 'Api users', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
@api_user = Fabricate(:api_user) @api_user = Fabricate(:api_user)
end end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Admin contact', type: :feature do feature 'Admin contact', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
@contact = Fabricate(:contact, name: 'Mr John') @contact = Fabricate(:contact, name: 'Mr John')
end end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'EPP log', type: :feature do feature 'EPP log', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
@contact = Fabricate(:contact, name: 'Mr John') @contact = Fabricate(:contact, name: 'Mr John')
end end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Invoice', type: :feature do feature 'Invoice', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
Fabricate(:invoice) Fabricate(:invoice)
end end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Repp log', type: :feature do feature 'Repp log', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
end end
context 'as unknown user' do context 'as unknown user' do

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Api users', type: :feature do feature 'Api users', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
@registrar = Fabricate(:registrar) @registrar = Fabricate(:registrar)
end end

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Zonefile settings', type: :feature do feature 'Zonefile settings', type: :feature do
before :all do before :all do
@user = Fabricate(:admin_user, username: 'user1', identity_code: '37810013087') @user = Fabricate(:admin_user)
end end
context 'as unknown user' do context 'as unknown user' do

View file

@ -2,7 +2,7 @@ require 'rails_helper'
feature 'Sessions', type: :feature do feature 'Sessions', type: :feature do
before :all do before :all do
Fabricate(:ee_user) @user = Fabricate(:ee_user)
@registrar1 = Fabricate(:registrar1) @registrar1 = Fabricate(:registrar1)
@registrar2 = Fabricate(:registrar2) @registrar2 = Fabricate(:registrar2)
Fabricate.times(2, :domain, registrar: @registrar1) Fabricate.times(2, :domain, registrar: @registrar1)
@ -11,9 +11,8 @@ feature 'Sessions', type: :feature do
scenario 'Admin logs in' do scenario 'Admin logs in' do
visit root_path visit root_path
page.should have_button('ID card (user1)')
click_on 'ID card (user1)' sign_in @user
page.should have_text('Welcome!') page.should have_text('Welcome!')
uri = URI.parse(current_url) uri = URI.parse(current_url)

View file

@ -12,9 +12,11 @@ describe AdminUser do
@user.errors.full_messages.should match_array([ @user.errors.full_messages.should match_array([
"Country code is missing", "Country code is missing",
"Email Email is missing", "Email Email is missing",
"Email Email is missing",
"Password Password is missing", "Password Password is missing",
"Username Username is missing", "Password Password is missing",
"Roles is missing" "Roles is missing",
"Username Username is missing"
]) ])
end end

View file

@ -1,7 +1,17 @@
module Feature module Feature
def sign_in(user) def sign_in(user)
visit '/admin/logout' visit '/admin/logout'
click_on 'ID card (user1)' if user.username == 'user1'
if user.username == 'user1'
fill_in 'admin_user_username', with: 'user1'
fill_in 'admin_user_password', with: 'testtest'
end
if user.username == 'gitlab'
fill_in 'admin_user_username', with: 'gitlab'
fill_in 'admin_user_password', with: 'ghyt9e4fu'
end
click_on 'Log in'
end end
end end