Commit 7b36b8d130561aa3f953962614e1774fa2603a11
1 parent
003bf612
Exists in
master
and in
4 other branches
access project feeds via private token
Showing
4 changed files
with
23 additions
and
2 deletions
Show diff stats
app/models/user.rb
| ... | ... | @@ -26,6 +26,7 @@ class User < ActiveRecord::Base |
| 26 | 26 | :dependent => :destroy |
| 27 | 27 | |
| 28 | 28 | before_create :ensure_authentication_token |
| 29 | + alias_attribute :private_token, :authentication_token | |
| 29 | 30 | scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) } |
| 30 | 31 | |
| 31 | 32 | def identifier | ... | ... |
app/views/layouts/project.html.haml
| ... | ... | @@ -6,9 +6,9 @@ |
| 6 | 6 | = stylesheet_link_tag "application" |
| 7 | 7 | = javascript_include_tag "application" |
| 8 | 8 | - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) |
| 9 | - = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}") | |
| 9 | + = auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref, :private_token => current_user.private_token), :title => "Recent commits to #{@project.name}:#{@ref}") | |
| 10 | 10 | - if request.path == project_issues_path(@project) |
| 11 | - = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom), :title => "#{@project.name} issues") | |
| 11 | + = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, :private_token => current_user.private_token), :title => "#{@project.name} issues") | |
| 12 | 12 | = csrf_meta_tags |
| 13 | 13 | = javascript_tag do |
| 14 | 14 | REQ_URI = "#{request.env["REQUEST_URI"]}"; | ... | ... |
spec/requests/commits_spec.rb
| ... | ... | @@ -34,6 +34,16 @@ describe "Commits" do |
| 34 | 34 | page.body.should have_selector("author email", :text => commit.author_email) |
| 35 | 35 | page.body.should have_selector("entry summary", :text => commit.message) |
| 36 | 36 | end |
| 37 | + | |
| 38 | + it "should render atom feed via private token" do | |
| 39 | + logout | |
| 40 | + visit project_commits_path(project, :atom, :private_token => @user.private_token) | |
| 41 | + | |
| 42 | + page.response_headers['Content-Type'].should have_content("application/atom+xml") | |
| 43 | + page.body.should have_selector("title", :text => "Recent commits to #{project.name}") | |
| 44 | + page.body.should have_selector("author email", :text => commit.author_email) | |
| 45 | + page.body.should have_selector("entry summary", :text => commit.message) | |
| 46 | + end | |
| 37 | 47 | end |
| 38 | 48 | |
| 39 | 49 | describe "GET /commits/:id" do | ... | ... |
spec/requests/issues_spec.rb
| ... | ... | @@ -36,6 +36,16 @@ describe "Issues" do |
| 36 | 36 | page.body.should have_selector("entry summary", :text => @issue.title) |
| 37 | 37 | end |
| 38 | 38 | |
| 39 | + it "should render atom feed via private token" do | |
| 40 | + logout | |
| 41 | + visit project_issues_path(project, :atom, :private_token => @user.private_token) | |
| 42 | + | |
| 43 | + page.response_headers['Content-Type'].should have_content("application/atom+xml") | |
| 44 | + page.body.should have_selector("title", :text => "#{project.name} issues") | |
| 45 | + page.body.should have_selector("author email", :text => @issue.author_email) | |
| 46 | + page.body.should have_selector("entry summary", :text => @issue.title) | |
| 47 | + end | |
| 48 | + | |
| 39 | 49 | describe "Destroy" do |
| 40 | 50 | before do |
| 41 | 51 | # admin access to remove issue | ... | ... |