Commit 7b36b8d130561aa3f953962614e1774fa2603a11

Authored by Nihad Abbasov
1 parent 003bf612

access project feeds via private token

app/models/user.rb
@@ -26,6 +26,7 @@ class User < ActiveRecord::Base @@ -26,6 +26,7 @@ class User < ActiveRecord::Base
26 :dependent => :destroy 26 :dependent => :destroy
27 27
28 before_create :ensure_authentication_token 28 before_create :ensure_authentication_token
  29 + alias_attribute :private_token, :authentication_token
29 scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) } 30 scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) }
30 31
31 def identifier 32 def identifier
app/views/layouts/project.html.haml
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 = stylesheet_link_tag "application" 6 = stylesheet_link_tag "application"
7 = javascript_include_tag "application" 7 = javascript_include_tag "application"
8 - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) 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 - if request.path == project_issues_path(@project) 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 = csrf_meta_tags 12 = csrf_meta_tags
13 = javascript_tag do 13 = javascript_tag do
14 REQ_URI = "#{request.env["REQUEST_URI"]}"; 14 REQ_URI = "#{request.env["REQUEST_URI"]}";
spec/requests/commits_spec.rb
@@ -34,6 +34,16 @@ describe "Commits" do @@ -34,6 +34,16 @@ describe "Commits" do
34 page.body.should have_selector("author email", :text => commit.author_email) 34 page.body.should have_selector("author email", :text => commit.author_email)
35 page.body.should have_selector("entry summary", :text => commit.message) 35 page.body.should have_selector("entry summary", :text => commit.message)
36 end 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 end 47 end
38 48
39 describe "GET /commits/:id" do 49 describe "GET /commits/:id" do
spec/requests/issues_spec.rb
@@ -36,6 +36,16 @@ describe "Issues" do @@ -36,6 +36,16 @@ describe "Issues" do
36 page.body.should have_selector("entry summary", :text => @issue.title) 36 page.body.should have_selector("entry summary", :text => @issue.title)
37 end 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 describe "Destroy" do 49 describe "Destroy" do
40 before do 50 before do
41 # admin access to remove issue 51 # admin access to remove issue