diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-08-17 17:21:18 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-08-17 17:21:18 -0500 |
commit | 2f86860a6ded54bb48f03bae1de9a88113c75173 (patch) | |
tree | 0b20da27dc4fadc81d47b5b03d715a21aef8a179 /spec/requests/git_http_spec.rb | |
parent | 5f5d8a8e09bbd2fcdfd02c68145a8c1086fe5e7c (diff) | |
download | gitlab-ce-2f86860a6ded54bb48f03bae1de9a88113c75173.tar.gz |
Refactor `find_for_git_client` method to not use assignment in conditionals and syntax fixes.
Diffstat (limited to 'spec/requests/git_http_spec.rb')
-rw-r--r-- | spec/requests/git_http_spec.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index 37c2586bbe2..afaf4b7cefb 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -199,21 +199,23 @@ describe 'Git HTTP requests', lib: true do end context 'when user has 2FA enabled' do + let(:user) { create(:user, :two_factor) } + let(:access_token) { create(:personal_access_token, user: user) } + before do - @user = create(:user, :two_factor) - project.team << [@user, :master] + project.team << [user, :master] end context 'when username and password are provided' do it 'rejects the clone attempt' do - download("#{project.path_with_namespace}.git", user: @user.username, password: @user.password) do |response| + download("#{project.path_with_namespace}.git", user: user.username, password: user.password) do |response| expect(response).to have_http_status(401) expect(response.body).to include('You have 2FA enabled, please use a personal access token for Git over HTTP') end end it 'rejects the push attempt' do - upload("#{project.path_with_namespace}.git", user: @user.username, password: @user.password) do |response| + upload("#{project.path_with_namespace}.git", user: user.username, password: user.password) do |response| expect(response).to have_http_status(401) expect(response.body).to include('You have 2FA enabled, please use a personal access token for Git over HTTP') end @@ -221,18 +223,14 @@ describe 'Git HTTP requests', lib: true do end context 'when username and personal access token are provided' do - before do - @token = create(:personal_access_token, user: @user) - end - it 'allows clones' do - download("#{project.path_with_namespace}.git", user: @user.username, password: @token.token) do |response| + download("#{project.path_with_namespace}.git", user: user.username, password: access_token.token) do |response| expect(response).to have_http_status(200) end end it 'allows pushes' do - upload("#{project.path_with_namespace}.git", user: @user.username, password: @token.token) do |response| + upload("#{project.path_with_namespace}.git", user: user.username, password: access_token.token) do |response| expect(response).to have_http_status(200) end end |