Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarin Jankovski <maxlazio@gmail.com>2012-11-06 17:30:48 +0400
committerMarin Jankovski <maxlazio@gmail.com>2013-01-18 14:57:31 +0400
commit296cdd591f7f01ffdbe18cd6a839bbd0e624dfba (patch)
treefd910106cf092da00a7fbddfe4d6e19b1f9a00eb /spec
parentb07e1b3aedf87fdf3ec7a6855cec8194b0a30a59 (diff)
Add optional signup.
Diffstat (limited to 'spec')
-rw-r--r--spec/mailers/notify_spec.rb30
-rw-r--r--spec/requests/admin/admin_users_spec.rb13
-rw-r--r--spec/requests/api/users_spec.rb30
3 files changed, 73 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 01e3c3f14c4..d947f0e2882 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -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') }
diff --git a/spec/requests/admin/admin_users_spec.rb b/spec/requests/admin/admin_users_spec.rb
index a66e85a34f9..455caf4a376 100644
--- a/spec/requests/admin/admin_users_spec.rb
+++ b/spec/requests/admin/admin_users_spec.rb
@@ -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
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 4cfb4884e7c..ee5f510aac5 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -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)