Add optional signup.
This commit is contained in:
parent
b07e1b3aed
commit
296cdd591f
14 changed files with 125 additions and 25 deletions
|
@ -32,6 +32,7 @@ describe Notify do
|
|||
end
|
||||
|
||||
it 'contains the new user\'s password' do
|
||||
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
|
||||
should have_body_text /#{new_user.password}/
|
||||
end
|
||||
|
||||
|
@ -40,6 +41,35 @@ describe Notify do
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
describe 'for users that signed up, the email' do
|
||||
let(:example_site_path) { root_path }
|
||||
let(:new_user) { create(:user, email: 'newguy@example.com', password: "securePassword") }
|
||||
|
||||
subject { Notify.new_user_email(new_user.id, new_user.password) }
|
||||
|
||||
it 'is sent to the new user' do
|
||||
should deliver_to new_user.email
|
||||
end
|
||||
|
||||
it 'has the correct subject' do
|
||||
should have_subject /^gitlab \| Account was created for you$/i
|
||||
end
|
||||
|
||||
it 'contains the new user\'s login name' do
|
||||
should have_body_text /#{new_user.email}/
|
||||
end
|
||||
|
||||
it 'should not contain the new user\'s password' do
|
||||
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
|
||||
should_not have_body_text /#{new_user.password}/
|
||||
end
|
||||
|
||||
it 'includes a link to the site' do
|
||||
should have_body_text /#{example_site_path}/
|
||||
end
|
||||
end
|
||||
|
||||
context 'for a project' do
|
||||
describe 'items that are assignable, the email' do
|
||||
let(:assignee) { create(:user, email: 'assignee@example.com') }
|
||||
|
|
|
@ -49,6 +49,7 @@ describe "Admin::Users" do
|
|||
end
|
||||
|
||||
it "should send valid email to user with email & password" do
|
||||
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
|
||||
User.observers.enable :user_observer do
|
||||
click_button "Save"
|
||||
user = User.last
|
||||
|
@ -58,6 +59,18 @@ describe "Admin::Users" do
|
|||
email.body.should have_content(@password)
|
||||
end
|
||||
end
|
||||
|
||||
it "should send valid email to user with email without password when signup is enabled" do
|
||||
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
|
||||
User.observers.enable :user_observer do
|
||||
click_button "Save"
|
||||
user = User.last
|
||||
email = ActionMailer::Base.deliveries.last
|
||||
email.subject.should have_content("Account was created")
|
||||
email.body.should have_content(user.email)
|
||||
email.body.should_not have_content(@password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /admin/users/:id" do
|
||||
|
|
|
@ -53,6 +53,36 @@ describe Gitlab::API do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /users/sign_up" do
|
||||
before do
|
||||
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
|
||||
end
|
||||
it "should redirect to sign in page if signup is disabled" do
|
||||
get "/users/sign_up"
|
||||
response.status.should == 302
|
||||
response.should redirect_to(new_user_session_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /users/sign_up" do
|
||||
before do
|
||||
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
|
||||
end
|
||||
it "should return sign up page if signup is enabled" do
|
||||
get "/users/sign_up"
|
||||
response.status.should == 200
|
||||
end
|
||||
it "should create a new user account" do
|
||||
visit new_user_registration_path
|
||||
fill_in "user_name", with: "Name Surname"
|
||||
fill_in "user_username", with: "Great"
|
||||
fill_in "user_email", with: "name@mail.com"
|
||||
fill_in "user_password", with: "password1234"
|
||||
fill_in "user_password_confirmation", with: "password1234"
|
||||
expect { click_button "Sign up" }.to change {User.count}.by(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /user" do
|
||||
it "should return current user" do
|
||||
get api("/user", user)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue