Commit e9de569458b55b43a0d09dceef07c3c5d583af24
1 parent
72b29525
Exists in
spb-stable
and in
2 other branches
Fix tests for user page
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
4 changed files
with
22 additions
and
18 deletions
Show diff stats
app/controllers/users_controller.rb
@@ -6,7 +6,7 @@ class UsersController < ApplicationController | @@ -6,7 +6,7 @@ class UsersController < ApplicationController | ||
6 | @user = User.find_by_username!(params[:username]) | 6 | @user = User.find_by_username!(params[:username]) |
7 | @projects = Project.personal(@user).accessible_to(current_user) | 7 | @projects = Project.personal(@user).accessible_to(current_user) |
8 | 8 | ||
9 | - if !current_user && @projects.empty? | 9 | + unless current_user || @user.public_profile? |
10 | return authenticate_user! | 10 | return authenticate_user! |
11 | end | 11 | end |
12 | 12 |
app/models/user.rb
@@ -478,4 +478,8 @@ class User < ActiveRecord::Base | @@ -478,4 +478,8 @@ class User < ActiveRecord::Base | ||
478 | def generate_tmp_oauth_email | 478 | def generate_tmp_oauth_email |
479 | self.email = "temp-email-for-oauth-#{username}@gitlab.localhost" | 479 | self.email = "temp-email-for-oauth-#{username}@gitlab.localhost" |
480 | end | 480 | end |
481 | + | ||
482 | + def public_profile? | ||
483 | + authorized_projects.public_only.any? | ||
484 | + end | ||
481 | end | 485 | end |
features/steps/shared/project.rb
@@ -102,24 +102,24 @@ module SharedProject | @@ -102,24 +102,24 @@ module SharedProject | ||
102 | page.should_not have_content "Community" | 102 | page.should_not have_content "Community" |
103 | end | 103 | end |
104 | 104 | ||
105 | - step '"John Doe" is authorized to private project "Enterprise"' do | 105 | + step '"John Doe" owns private project "Enterprise"' do |
106 | user = user_exists("John Doe", username: "john_doe") | 106 | user = user_exists("John Doe", username: "john_doe") |
107 | project = Project.find_by(name: "Enterprise") | 107 | project = Project.find_by(name: "Enterprise") |
108 | - project ||= create(:project, name: "Enterprise", namespace: user.namespace) | 108 | + project ||= create(:empty_project, name: "Enterprise", namespace: user.namespace) |
109 | project.team << [user, :master] | 109 | project.team << [user, :master] |
110 | end | 110 | end |
111 | 111 | ||
112 | - step '"John Doe" is authorized to internal project "Internal"' do | 112 | + step '"John Doe" owns internal project "Internal"' do |
113 | user = user_exists("John Doe", username: "john_doe") | 113 | user = user_exists("John Doe", username: "john_doe") |
114 | project = Project.find_by(name: "Internal") | 114 | project = Project.find_by(name: "Internal") |
115 | - project ||= create :project, :internal, name: 'Internal' | 115 | + project ||= create :empty_project, :internal, name: 'Internal', namespace: user.namespace |
116 | project.team << [user, :master] | 116 | project.team << [user, :master] |
117 | end | 117 | end |
118 | 118 | ||
119 | - step '"John Doe" is authorized to public project "Community"' do | 119 | + step '"John Doe" owns public project "Community"' do |
120 | user = user_exists("John Doe", username: "john_doe") | 120 | user = user_exists("John Doe", username: "john_doe") |
121 | project = Project.find_by(name: "Community") | 121 | project = Project.find_by(name: "Community") |
122 | - project ||= create :project, :public, name: 'Community' | 122 | + project ||= create :empty_project, :public, name: 'Community', namespace: user.namespace |
123 | project.team << [user, :master] | 123 | project.team << [user, :master] |
124 | end | 124 | end |
125 | end | 125 | end |
features/user.feature
1 | Feature: User | 1 | Feature: User |
2 | Background: | 2 | Background: |
3 | Given User "John Doe" exists | 3 | Given User "John Doe" exists |
4 | - And "John Doe" is authorized to private project "Enterprise" | 4 | + And "John Doe" owns private project "Enterprise" |
5 | 5 | ||
6 | # Signed out | 6 | # Signed out |
7 | 7 | ||
8 | - Scenario: I visit user "John Doe" page while not signed in when he is authorized to a public project | ||
9 | - Given "John Doe" is authorized to internal project "Internal" | ||
10 | - And "John Doe" is authorized to public project "Community" | 8 | + Scenario: I visit user "John Doe" page while not signed in when he owns a public project |
9 | + Given "John Doe" owns internal project "Internal" | ||
10 | + And "John Doe" owns public project "Community" | ||
11 | When I visit user "John Doe" page | 11 | When I visit user "John Doe" page |
12 | Then I should see user "John Doe" page | 12 | Then I should see user "John Doe" page |
13 | And I should not see project "Enterprise" | 13 | And I should not see project "Enterprise" |
@@ -15,15 +15,15 @@ Feature: User | @@ -15,15 +15,15 @@ Feature: User | ||
15 | And I should see project "Community" | 15 | And I should see project "Community" |
16 | 16 | ||
17 | Scenario: I visit user "John Doe" page while not signed in when he is not authorized to a public project | 17 | Scenario: I visit user "John Doe" page while not signed in when he is not authorized to a public project |
18 | - Given "John Doe" is authorized to internal project "Internal" | 18 | + Given "John Doe" owns internal project "Internal" |
19 | When I visit user "John Doe" page | 19 | When I visit user "John Doe" page |
20 | Then I should be redirected to sign in page | 20 | Then I should be redirected to sign in page |
21 | 21 | ||
22 | # Signed in as someone else | 22 | # Signed in as someone else |
23 | 23 | ||
24 | - Scenario: I visit user "John Doe" page while signed in as someone else when he is authorized to a public project | ||
25 | - Given "John Doe" is authorized to public project "Community" | ||
26 | - And "John Doe" is authorized to internal project "Internal" | 24 | + Scenario: I visit user "John Doe" page while signed in as someone else when he owns a public project |
25 | + Given "John Doe" owns public project "Community" | ||
26 | + And "John Doe" owns internal project "Internal" | ||
27 | And I sign in as a user | 27 | And I sign in as a user |
28 | When I visit user "John Doe" page | 28 | When I visit user "John Doe" page |
29 | Then I should see user "John Doe" page | 29 | Then I should see user "John Doe" page |
@@ -32,7 +32,7 @@ Feature: User | @@ -32,7 +32,7 @@ Feature: User | ||
32 | And I should see project "Community" | 32 | And I should see project "Community" |
33 | 33 | ||
34 | Scenario: I visit user "John Doe" page while signed in as someone else when he is not authorized to a public project | 34 | Scenario: I visit user "John Doe" page while signed in as someone else when he is not authorized to a public project |
35 | - Given "John Doe" is authorized to internal project "Internal" | 35 | + Given "John Doe" owns internal project "Internal" |
36 | And I sign in as a user | 36 | And I sign in as a user |
37 | When I visit user "John Doe" page | 37 | When I visit user "John Doe" page |
38 | Then I should see user "John Doe" page | 38 | Then I should see user "John Doe" page |
@@ -51,8 +51,8 @@ Feature: User | @@ -51,8 +51,8 @@ Feature: User | ||
51 | # Signed in as the user himself | 51 | # Signed in as the user himself |
52 | 52 | ||
53 | Scenario: I visit user "John Doe" page while signed in as "John Doe" when he has a public project | 53 | Scenario: I visit user "John Doe" page while signed in as "John Doe" when he has a public project |
54 | - Given "John Doe" is authorized to internal project "Internal" | ||
55 | - And "John Doe" is authorized to public project "Community" | 54 | + Given "John Doe" owns internal project "Internal" |
55 | + And "John Doe" owns public project "Community" | ||
56 | And I sign in as "John Doe" | 56 | And I sign in as "John Doe" |
57 | When I visit user "John Doe" page | 57 | When I visit user "John Doe" page |
58 | Then I should see user "John Doe" page | 58 | Then I should see user "John Doe" page |