Commit 8e238f42732e5968dc46e3f08d853d0f3c9b2760

Authored by Dmitriy Zaporozhets
1 parent 7b8bd93e

Fix user remove tests. Remove user even if he has projects

app/controllers/registrations_controller.rb
@@ -2,9 +2,6 @@ class RegistrationsController < Devise::RegistrationsController @@ -2,9 +2,6 @@ class RegistrationsController < Devise::RegistrationsController
2 before_filter :signup_enabled? 2 before_filter :signup_enabled?
3 3
4 def destroy 4 def destroy
5 - if current_user.owned_projects.count > 0  
6 - redirect_to account_profile_path, alert: "Remove projects and groups before removing account." and return  
7 - end  
8 current_user.destroy 5 current_user.destroy
9 6
10 respond_to do |format| 7 respond_to do |format|
spec/features/profile_spec.rb
@@ -17,26 +17,12 @@ describe "Profile account page" do @@ -17,26 +17,12 @@ describe "Profile account page" do
17 17
18 it { page.should have_content("Remove account") } 18 it { page.should have_content("Remove account") }
19 19
20 - it "should delete the account", js: true do 20 + it "should delete the account" do
21 expect { click_link "Delete account" }.to change {User.count}.by(-1) 21 expect { click_link "Delete account" }.to change {User.count}.by(-1)
22 current_path.should == new_user_session_path 22 current_path.should == new_user_session_path
23 end 23 end
24 end 24 end
25 25
26 - describe "when signup is enabled and user has a project" do  
27 - before do  
28 - Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)  
29 - @project = create(:project, namespace: @user.namespace)  
30 - @project.team << [@user, :master]  
31 - visit account_profile_path  
32 - end  
33 - it { page.should have_content("Remove account") }  
34 -  
35 - it "should not allow user to delete the account" do  
36 - expect { click_link "Delete account" }.not_to change {User.count}.by(-1)  
37 - end  
38 - end  
39 -  
40 describe "when signup is disabled" do 26 describe "when signup is disabled" do
41 before do 27 before do
42 Gitlab.config.gitlab.stub(:signup_enabled).and_return(false) 28 Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)