summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNihad Abbasov <narkoz.2008@gmail.com>2011-11-15 11:25:26 +0400
committerNihad Abbasov <narkoz.2008@gmail.com>2011-11-15 11:25:26 +0400
commit7b36b8d130561aa3f953962614e1774fa2603a11 (patch)
tree29f6b16d54be127659f88b9891ff91afb3ee64cd
parent003bf61258ea20128315076936f09ea198e56bcb (diff)
downloadgitlab-ce-7b36b8d130561aa3f953962614e1774fa2603a11.tar.gz
access project feeds via private token
-rw-r--r--app/models/user.rb1
-rw-r--r--app/views/layouts/project.html.haml4
-rw-r--r--spec/requests/commits_spec.rb10
-rw-r--r--spec/requests/issues_spec.rb10
4 files changed, 23 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 0320a6208eb..f6c271467dd 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -26,6 +26,7 @@ class User < ActiveRecord::Base
:dependent => :destroy
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) ) }
def identifier
diff --git a/app/views/layouts/project.html.haml b/app/views/layouts/project.html.haml
index b2d023d4a72..7c5a162f22f 100644
--- a/app/views/layouts/project.html.haml
+++ b/app/views/layouts/project.html.haml
@@ -6,9 +6,9 @@
= stylesheet_link_tag "application"
= javascript_include_tag "application"
- 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)
- = 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
= javascript_tag do
REQ_URI = "#{request.env["REQUEST_URI"]}";
diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb
index 2bbd6b9f104..e0897632c03 100644
--- a/spec/requests/commits_spec.rb
+++ b/spec/requests/commits_spec.rb
@@ -34,6 +34,16 @@ describe "Commits" do
page.body.should have_selector("author email", :text => commit.author_email)
page.body.should have_selector("entry summary", :text => commit.message)
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
describe "GET /commits/:id" do
diff --git a/spec/requests/issues_spec.rb b/spec/requests/issues_spec.rb
index c77316d6452..85cee062ded 100644
--- a/spec/requests/issues_spec.rb
+++ b/spec/requests/issues_spec.rb
@@ -36,6 +36,16 @@ describe "Issues" do
page.body.should have_selector("entry summary", :text => @issue.title)
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
before do
# admin access to remove issue