2011-10-08 21:36:38 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-04-12 08:56:37 +00:00
|
|
|
describe "Admin::Users", feature: true do
|
2011-10-08 21:36:38 +00:00
|
|
|
before { login_as :admin }
|
|
|
|
|
|
|
|
describe "GET /admin/users" do
|
2011-10-26 13:46:25 +00:00
|
|
|
before do
|
2011-10-08 21:36:38 +00:00
|
|
|
visit admin_users_path
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be ok" do
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(current_path).to eq(admin_users_path)
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should have users list" do
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(page).to have_content(@user.email)
|
|
|
|
expect(page).to have_content(@user.name)
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
describe "GET /admin/users/new" do
|
|
|
|
before do
|
2011-10-08 21:36:38 +00:00
|
|
|
visit new_admin_user_path
|
2012-08-10 22:07:50 +00:00
|
|
|
fill_in "user_name", with: "Big Bang"
|
2012-11-23 20:25:28 +00:00
|
|
|
fill_in "user_username", with: "bang"
|
2012-08-10 22:07:50 +00:00
|
|
|
fill_in "user_email", with: "bigbang@mail.com"
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should create new user" do
|
2013-04-18 14:28:09 +00:00
|
|
|
expect { click_button "Create user" }.to change {User.count}.by(1)
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2013-03-11 06:44:45 +00:00
|
|
|
it "should apply defaults to user" do
|
|
|
|
click_button "Create user"
|
2015-02-06 06:40:35 +00:00
|
|
|
user = User.find_by(username: 'bang')
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(user.projects_limit).
|
|
|
|
to eq(Gitlab.config.gitlab.default_projects_limit)
|
|
|
|
expect(user.can_create_group).
|
|
|
|
to eq(Gitlab.config.gitlab.default_can_create_group)
|
2013-03-11 06:44:45 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should create user with valid data" do
|
2013-04-18 14:28:09 +00:00
|
|
|
click_button "Create user"
|
2015-02-06 06:40:35 +00:00
|
|
|
user = User.find_by(username: 'bang')
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(user.name).to eq('Big Bang')
|
|
|
|
expect(user.email).to eq('bigbang@mail.com')
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should call send mail" do
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(Notify).to receive(:new_user_email)
|
2012-06-20 16:29:10 +00:00
|
|
|
|
2014-06-17 19:51:43 +00:00
|
|
|
click_button "Create user"
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should send valid email to user with email & password" do
|
2014-06-17 19:51:43 +00:00
|
|
|
click_button "Create user"
|
2015-02-06 06:40:35 +00:00
|
|
|
user = User.find_by(username: 'bang')
|
2014-06-17 19:51:43 +00:00
|
|
|
email = ActionMailer::Base.deliveries.last
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(email.subject).to have_content('Account was created')
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(email.text_part.body).to have_content(user.email)
|
|
|
|
expect(email.text_part.body).to have_content('password')
|
2012-11-06 13:30:48 +00:00
|
|
|
end
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
describe "GET /admin/users/:id" do
|
|
|
|
before do
|
2011-10-08 21:36:38 +00:00
|
|
|
visit admin_users_path
|
2011-11-22 07:55:01 +00:00
|
|
|
click_link "#{@user.name}"
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should have user info" do
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(page).to have_content(@user.email)
|
|
|
|
expect(page).to have_content(@user.name)
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
describe "GET /admin/users/:id/edit" do
|
|
|
|
before do
|
2012-11-06 03:31:55 +00:00
|
|
|
@simple_user = create(:user)
|
2011-10-08 21:36:38 +00:00
|
|
|
visit admin_users_path
|
|
|
|
click_link "edit_user_#{@simple_user.id}"
|
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should have user edit page" do
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(page).to have_content('Name')
|
|
|
|
expect(page).to have_content('Password')
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "Update user" do
|
2011-10-26 13:46:25 +00:00
|
|
|
before do
|
2012-08-10 22:07:50 +00:00
|
|
|
fill_in "user_name", with: "Big Bang"
|
|
|
|
fill_in "user_email", with: "bigbang@mail.com"
|
2011-10-08 21:36:38 +00:00
|
|
|
check "user_admin"
|
2013-04-18 14:28:09 +00:00
|
|
|
click_button "Save changes"
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should show page with new data" do
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(page).to have_content('bigbang@mail.com')
|
|
|
|
expect(page).to have_content('Big Bang')
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
|
2011-10-26 13:46:25 +00:00
|
|
|
it "should change user entry" do
|
2011-10-08 21:36:38 +00:00
|
|
|
@simple_user.reload
|
2015-02-12 18:53:23 +00:00
|
|
|
expect(@simple_user.name).to eq('Big Bang')
|
2015-02-12 18:17:35 +00:00
|
|
|
expect(@simple_user.is_admin?).to be_truthy
|
2011-10-08 21:36:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|