Commit 1521f467cbf8b1b9b3e9cb4169f3e96a9984bb46
1 parent
26c8b316
Exists in
master
and in
4 other branches
Update default public pull url.
This updates the default pull URL for public projects when the user is not logged in.
Showing
5 changed files
with
45 additions
and
10 deletions
Show diff stats
app/helpers/projects_helper.rb
... | ... | @@ -179,4 +179,12 @@ module ProjectsHelper |
179 | 179 | |
180 | 180 | title |
181 | 181 | end |
182 | + | |
183 | + def default_url_to_repo | |
184 | + current_user ? @project.url_to_repo : @project.http_url_to_repo | |
185 | + end | |
186 | + | |
187 | + def default_clone_protocol | |
188 | + current_user ? "ssh" : "http" | |
189 | + end | |
182 | 190 | end | ... | ... |
app/views/projects/empty.html.haml
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | touch README |
30 | 30 | git add README |
31 | 31 | git commit -m 'first commit' |
32 | - %span.clone= "git remote add origin #{@project.url_to_repo}" | |
32 | + %span.clone= "git remote add origin #{default_url_to_repo}" | |
33 | 33 | :preserve |
34 | 34 | git push -u origin master |
35 | 35 | |
... | ... | @@ -38,7 +38,7 @@ |
38 | 38 | %pre.dark |
39 | 39 | :preserve |
40 | 40 | cd existing_git_repo |
41 | - %span.clone= "git remote add origin #{@project.url_to_repo}" | |
41 | + %span.clone= "git remote add origin #{default_url_to_repo}" | |
42 | 42 | :preserve |
43 | 43 | git push -u origin master |
44 | 44 | ... | ... |
app/views/shared/_clone_panel.html.haml
1 | 1 | .git-clone-holder |
2 | - %button{class: "btn #{ current_user ? 'active' : '' }", :"data-clone" => @project.ssh_url_to_repo} SSH | |
3 | - %button{class: "btn #{ current_user ? '' : 'active' }", :"data-clone" => @project.http_url_to_repo}= gitlab_config.protocol.upcase | |
4 | - = text_field_tag :project_clone, (current_user ? @project.url_to_repo : @project.http_url_to_repo), class: "one_click_select span5", readonly: true | |
2 | + %button{class: "btn #{ 'active' if default_clone_protocol == 'ssh' }", :"data-clone" => @project.ssh_url_to_repo} SSH | |
3 | + %button{class: "btn #{ 'active' if default_clone_protocol == 'http' }", :"data-clone" => @project.http_url_to_repo}= gitlab_config.protocol.upcase | |
4 | + = text_field_tag :project_clone, default_url_to_repo, class: "one_click_select span5", readonly: true | ... | ... |
features/public/public_projects.feature
... | ... | @@ -26,6 +26,14 @@ Feature: Public Projects Feature |
26 | 26 | Given public empty project "Empty Public Project" |
27 | 27 | When I visit empty project page |
28 | 28 | Then I should see empty public project details |
29 | + And I should see empty public project details with http clone info | |
30 | + | |
31 | + Scenario: I visit an empty public project page as user | |
32 | + Given I sign in as a user | |
33 | + And public empty project "Empty Public Project" | |
34 | + When I visit empty project page | |
35 | + Then I should see empty public project details | |
36 | + And I should see empty public project details with ssh clone info | |
29 | 37 | |
30 | 38 | Scenario: I visit public area as user |
31 | 39 | Given I sign in as a user |
... | ... | @@ -42,10 +50,15 @@ Feature: Public Projects Feature |
42 | 50 | Scenario: I visit public project page |
43 | 51 | When I visit project "Community" page |
44 | 52 | Then I should see project "Community" home page |
45 | - And I should see a http link to the repository | |
53 | + And I should see an http link to the repository | |
46 | 54 | |
47 | - Scenario: I visit public area as user | |
55 | + Scenario: I visit public project page as user | |
48 | 56 | Given I sign in as a user |
49 | 57 | When I visit project "Community" page |
50 | 58 | Then I should see project "Community" home page |
51 | - And I should see a ssh link to the repository | |
59 | + And I should see an ssh link to the repository | |
60 | + | |
61 | + Scenario: I visit an empty public project page | |
62 | + Given public empty project "Empty Public Project" | |
63 | + When I visit empty project page | |
64 | + Then I should see empty public project details | ... | ... |
features/steps/public/projects_feature.rb
... | ... | @@ -46,6 +46,20 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps |
46 | 46 | page.should have_content 'Git global setup' |
47 | 47 | end |
48 | 48 | |
49 | + step 'I should see empty public project details with http clone info' do | |
50 | + project = Project.find_by_name('Empty Public Project') | |
51 | + page.all(:css, '.git-empty .clone').each do |element| | |
52 | + element.text.should include(project.http_url_to_repo) | |
53 | + end | |
54 | + end | |
55 | + | |
56 | + step 'I should see empty public project details with ssh clone info' do | |
57 | + project = Project.find_by_name('Empty Public Project') | |
58 | + page.all(:css, '.git-empty .clone').each do |element| | |
59 | + element.text.should include(project.url_to_repo) | |
60 | + end | |
61 | + end | |
62 | + | |
49 | 63 | step 'private project "Enterprise"' do |
50 | 64 | create :project, name: 'Enterprise' |
51 | 65 | end |
... | ... | @@ -84,12 +98,12 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps |
84 | 98 | end |
85 | 99 | end |
86 | 100 | |
87 | - Then 'I should see a http link to the repository' do | |
101 | + step 'I should see an http link to the repository' do | |
88 | 102 | project = Project.find_by_name 'Community' |
89 | 103 | page.should have_field('project_clone', with: project.http_url_to_repo) |
90 | 104 | end |
91 | 105 | |
92 | - Then 'I should see a ssh link to the repository' do | |
106 | + step 'I should see an ssh link to the repository' do | |
93 | 107 | project = Project.find_by_name 'Community' |
94 | 108 | page.should have_field('project_clone', with: project.url_to_repo) |
95 | 109 | end | ... | ... |