Commit f339af858b25cc32ac1bc0c46add29a6a3f43b51

Authored by Marin Jankovski
1 parent 1b4ba3eb

Test the delete acount option.

Showing 1 changed file with 48 additions and 0 deletions   Show diff stats
spec/requests/profile_spec.rb 0 → 100644
... ... @@ -0,0 +1,48 @@
  1 +require 'spec_helper'
  2 +
  3 +describe "Profile account page" do
  4 + let(:user) { create(:user) }
  5 +
  6 + before do
  7 + login_as :user
  8 + end
  9 +
  10 + describe "when signup is enabled" do
  11 + before do
  12 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
  13 + visit account_profile_path
  14 + end
  15 + it { page.should have_content("Remove account") }
  16 +
  17 + it "should delete the account", js: true do
  18 + expect { click_link "Delete account" }.to change {User.count}.by(-1)
  19 + current_path.should == new_user_session_path
  20 + end
  21 + end
  22 +
  23 + describe "when signup is enabled and user has a project" do
  24 + before do
  25 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(true)
  26 + @project = create(:project, namespace: @user.namespace)
  27 + @project.team << [@user, :master]
  28 + visit account_profile_path
  29 + end
  30 + it { page.should have_content("Remove account") }
  31 +
  32 + it "should not allow user to delete the account" do
  33 + expect { click_link "Delete account" }.not_to change {User.count}.by(-1)
  34 + end
  35 + end
  36 +
  37 + describe "when signup is disabled" do
  38 + before do
  39 + Gitlab.config.gitlab.stub(:signup_enabled).and_return(false)
  40 + visit account_profile_path
  41 + end
  42 +
  43 + it "should not have option to remove account" do
  44 + page.should_not have_content("Remove account")
  45 + current_path.should == account_profile_path
  46 + end
  47 + end
  48 +end
0 49 \ No newline at end of file
... ...