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