debian-mirror-gitlab/spec/features/admin/admin_users_spec.rb

110 lines
2.9 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require 'spec_helper'
describe "Admin::Users", feature: true do
before { login_as :admin }
describe "GET /admin/users" do
before do
visit admin_users_path
end
it "should be ok" do
2015-04-26 12:48:37 +05:30
expect(current_path).to eq(admin_users_path)
2014-09-02 18:07:02 +05:30
end
it "should have users list" do
2015-04-26 12:48:37 +05:30
expect(page).to have_content(@user.email)
expect(page).to have_content(@user.name)
2014-09-02 18:07:02 +05:30
end
end
describe "GET /admin/users/new" do
before do
visit new_admin_user_path
fill_in "user_name", with: "Big Bang"
fill_in "user_username", with: "bang"
fill_in "user_email", with: "bigbang@mail.com"
end
it "should create new user" do
expect { click_button "Create user" }.to change {User.count}.by(1)
end
it "should apply defaults to user" do
click_button "Create user"
2015-04-26 12:48:37 +05:30
user = User.find_by(username: 'bang')
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)
2014-09-02 18:07:02 +05:30
end
it "should create user with valid data" do
click_button "Create user"
2015-04-26 12:48:37 +05:30
user = User.find_by(username: 'bang')
expect(user.name).to eq('Big Bang')
expect(user.email).to eq('bigbang@mail.com')
2014-09-02 18:07:02 +05:30
end
it "should call send mail" do
2015-04-26 12:48:37 +05:30
expect(Notify).to receive(:new_user_email)
2014-09-02 18:07:02 +05:30
click_button "Create user"
end
it "should send valid email to user with email & password" do
click_button "Create user"
2015-04-26 12:48:37 +05:30
user = User.find_by(username: 'bang')
2014-09-02 18:07:02 +05:30
email = ActionMailer::Base.deliveries.last
2015-04-26 12:48:37 +05:30
expect(email.subject).to have_content('Account was created')
expect(email.text_part.body).to have_content(user.email)
expect(email.text_part.body).to have_content('password')
2014-09-02 18:07:02 +05:30
end
end
describe "GET /admin/users/:id" do
before do
visit admin_users_path
click_link "#{@user.name}"
end
it "should have user info" do
2015-04-26 12:48:37 +05:30
expect(page).to have_content(@user.email)
expect(page).to have_content(@user.name)
2014-09-02 18:07:02 +05:30
end
end
describe "GET /admin/users/:id/edit" do
before do
@simple_user = create(:user)
visit admin_users_path
click_link "edit_user_#{@simple_user.id}"
end
it "should have user edit page" do
2015-04-26 12:48:37 +05:30
expect(page).to have_content('Name')
expect(page).to have_content('Password')
2014-09-02 18:07:02 +05:30
end
describe "Update user" do
before do
fill_in "user_name", with: "Big Bang"
fill_in "user_email", with: "bigbang@mail.com"
check "user_admin"
click_button "Save changes"
end
it "should show page with new data" do
2015-04-26 12:48:37 +05:30
expect(page).to have_content('bigbang@mail.com')
expect(page).to have_content('Big Bang')
2014-09-02 18:07:02 +05:30
end
it "should change user entry" do
@simple_user.reload
2015-04-26 12:48:37 +05:30
expect(@simple_user.name).to eq('Big Bang')
expect(@simple_user.is_admin?).to be_truthy
2014-09-02 18:07:02 +05:30
end
end
end
end