Skip to content

Commit

Permalink
Fix user remove tests. Remove user even if he has projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dzaporozhets committed Sep 4, 2013
1 parent 7b8bd93 commit 8e238f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
3 changes: 0 additions & 3 deletions app/controllers/registrations_controller.rb
Expand Up @@ -2,9 +2,6 @@ class RegistrationsController < Devise::RegistrationsController
before_filter :signup_enabled? before_filter :signup_enabled?


def destroy def destroy
if current_user.owned_projects.count > 0
redirect_to account_profile_path, alert: "Remove projects and groups before removing account." and return
end
current_user.destroy current_user.destroy


respond_to do |format| respond_to do |format|
Expand Down
16 changes: 1 addition & 15 deletions spec/features/profile_spec.rb
Expand Up @@ -17,26 +17,12 @@


it { page.should have_content("Remove account") } it { page.should have_content("Remove account") }


it "should delete the account", js: true do it "should delete the account" do
expect { click_link "Delete account" }.to change {User.count}.by(-1) expect { click_link "Delete account" }.to change {User.count}.by(-1)
current_path.should == new_user_session_path current_path.should == new_user_session_path
end end
end end


describe "when signup is enabled and user has a project" do
before do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
@project = create(:project, namespace: @user.namespace)
@project.team << [@user, :master]
visit account_profile_path
end
it { page.should have_content("Remove account") }

it "should not allow user to delete the account" do
expect { click_link "Delete account" }.not_to change {User.count}.by(-1)
end
end

describe "when signup is disabled" do describe "when signup is disabled" do
before do before do
Gitlab.config.gitlab.stub(:signup_enabled).and_return(false) Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
Expand Down

0 comments on commit 8e238f4

Please sign in to comment.