access project feeds via private token

This commit is contained in:
Nihad Abbasov 2011-11-15 11:25:26 +04:00
parent 003bf61258
commit 7b36b8d130
4 changed files with 23 additions and 2 deletions

View file

@ -26,6 +26,7 @@ class User < ActiveRecord::Base
:dependent => :destroy :dependent => :destroy
before_create :ensure_authentication_token before_create :ensure_authentication_token
alias_attribute :private_token, :authentication_token
scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) } scope :not_in_project, lambda { |project| where("id not in (:ids)", :ids => project.users.map(&:id) ) }
def identifier def identifier

View file

@ -6,9 +6,9 @@
= stylesheet_link_tag "application" = stylesheet_link_tag "application"
= javascript_include_tag "application" = javascript_include_tag "application"
- if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project)) - if current_page?(tree_project_path(@project)) || current_page?(project_commits_path(@project))
= auto_discovery_link_tag(:atom, project_commits_url(@project, :atom, :ref => @ref), :title => "Recent commits to #{@project.name}:#{@ref}") = 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}")
- if request.path == project_issues_path(@project) - if request.path == project_issues_path(@project)
= auto_discovery_link_tag(:atom, project_issues_url(@project, :atom), :title => "#{@project.name} issues") = auto_discovery_link_tag(:atom, project_issues_url(@project, :atom, :private_token => current_user.private_token), :title => "#{@project.name} issues")
= csrf_meta_tags = csrf_meta_tags
= javascript_tag do = javascript_tag do
REQ_URI = "#{request.env["REQUEST_URI"]}"; REQ_URI = "#{request.env["REQUEST_URI"]}";

View file

@ -34,6 +34,16 @@ describe "Commits" do
page.body.should have_selector("author email", :text => commit.author_email) page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.message) page.body.should have_selector("entry summary", :text => commit.message)
end end
it "should render atom feed via private token" do
logout
visit project_commits_path(project, :atom, :private_token => @user.private_token)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "Recent commits to #{project.name}")
page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.message)
end
end end
describe "GET /commits/:id" do describe "GET /commits/:id" do

View file

@ -36,6 +36,16 @@ describe "Issues" do
page.body.should have_selector("entry summary", :text => @issue.title) page.body.should have_selector("entry summary", :text => @issue.title)
end end
it "should render atom feed via private token" do
logout
visit project_issues_path(project, :atom, :private_token => @user.private_token)
page.response_headers['Content-Type'].should have_content("application/atom+xml")
page.body.should have_selector("title", :text => "#{project.name} issues")
page.body.should have_selector("author email", :text => @issue.author_email)
page.body.should have_selector("entry summary", :text => @issue.title)
end
describe "Destroy" do describe "Destroy" do
before do before do
# admin access to remove issue # admin access to remove issue