diff --git a/app/controllers/feeds_controller.rb b/app/controllers/feeds_controller.rb
index 7a454d80..46e8ae05 100644
--- a/app/controllers/feeds_controller.rb
+++ b/app/controllers/feeds_controller.rb
@@ -1,5 +1,5 @@
# redMine - project management software
-# Copyright (C) 2006 Jean-Philippe Lang
+# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -16,10 +16,85 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class FeedsController < ApplicationController
+ before_filter :find_scope
session :off
-
+
+ helper :issues
+ include IssuesHelper
+ helper :custom_fields
+ include CustomFieldsHelper
+
+ # news feeds
def news
- @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :limit => 10, :include => [ :author, :project ]
+ News.with_scope(:find => @find_options) do
+ @news = News.find :all, :order => "#{News.table_name}.created_on DESC", :limit => 10, :include => [ :author, :project ]
+ end
headers["Content-Type"] = "application/rss+xml"
+ render :action => 'news_atom' if 'atom' == params[:format]
+ end
+
+ # issue feeds
+ def issues
+ conditions = nil
+
+ if params[:query_id]
+ query = Query.find(params[:query_id])
+ # ignore query if it's not valid
+ query = nil unless query.valid?
+ conditions = query.statement if query
+ end
+
+ Issue.with_scope(:find => @find_options) do
+ @issues = Issue.find :all, :include => [:project, :author, :tracker, :status],
+ :order => "#{Issue.table_name}.created_on DESC",
+ :conditions => conditions
+ end
+ @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
+ headers["Content-Type"] = "application/rss+xml"
+ render :action => 'issues_atom' if 'atom' == params[:format]
+ end
+
+ # issue changes feeds
+ def history
+ conditions = nil
+
+ if params[:query_id]
+ query = Query.find(params[:query_id])
+ # ignore query if it's not valid
+ query = nil unless query.valid?
+ conditions = query.statement if query
+ end
+
+ Journal.with_scope(:find => @find_options) do
+ @journals = Journal.find :all, :include => [ :details, :user, {:issue => [:project, :author, :tracker, :status]} ],
+ :order => "#{Journal.table_name}.created_on DESC",
+ :conditions => conditions
+ end
+
+ @title = (@project ? @project.name : Setting.app_title) + ": " + (query ? query.name : l(:label_reported_issues))
+ headers["Content-Type"] = "application/rss+xml"
+ render :action => 'history_atom' if 'atom' == params[:format]
+ end
+
+private
+ # override for feeds specific authentication
+ def check_if_login_required
+ @user = User.find_by_rss_key(params[:key])
+ render(:nothing => true, :status => 403) and return false if !@user && Setting.login_required?
+ end
+
+ def find_scope
+ if params[:project_id]
+ # project feed
+ # check if project is public or if the user is a member
+ @project = Project.find(params[:project_id])
+ render(:nothing => true, :status => 403) and return false unless @project.is_public? || (@user && @user.role_for_project(@project.id))
+ scope = ["#{Project.table_name}.id=?", params[:project_id].to_i]
+ else
+ # global feed
+ scope = ["#{Project.table_name}.is_public=?", true]
+ end
+ @find_options = {:conditions => scope, :limit => 10}
+ return true
end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index fe483681..61b77219 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -575,6 +575,11 @@ class ProjectsController < ApplicationController
end
end
+ def feeds
+ @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
+ @key = logged_in_user.get_or_create_rss_key.value if logged_in_user
+ end
+
private
# Find project of id params[:id]
# if not found, redirect to project list
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 18a6ec08..f70a6986 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -17,6 +17,10 @@
class Journal < ActiveRecord::Base
belongs_to :journalized, :polymorphic => true
+ # added as a quick fix to allow eager loading of the polymorphic association
+ # since always associated to an issue, for now
+ belongs_to :issue, :foreign_key => :journalized_id
+
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
end
diff --git a/app/models/token.rb b/app/models/token.rb
index 98745d29..0e8c2c3e 100644
--- a/app/models/token.rb
+++ b/app/models/token.rb
@@ -31,7 +31,7 @@ class Token < ActiveRecord::Base
# Delete all expired tokens
def self.destroy_expired
- Token.delete_all ["created_on < ?", Time.now - @@validity_time]
+ Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
end
private
diff --git a/app/models/user.rb b/app/models/user.rb
index 3a315239..869be920 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
has_many :projects, :through => :memberships
has_many :custom_values, :dependent => :delete_all, :as => :customized
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
+ has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
belongs_to :auth_source
attr_accessor :password, :password_confirmation
@@ -133,6 +134,15 @@ class User < ActiveRecord::Base
def pref
self.preference ||= UserPreference.new(:user => self)
end
+
+ def get_or_create_rss_key
+ self.rss_key || Token.create(:user => self, :action => 'feeds')
+ end
+
+ def self.find_by_rss_key(key)
+ token = Token.find_by_value(key)
+ token && token.user.active? ? token.user : nil
+ end
private
# Return password digest
diff --git a/app/views/feeds/history.rxml b/app/views/feeds/history.rxml
new file mode 100644
index 00000000..b7e5a350
--- /dev/null
+++ b/app/views/feeds/history.rxml
@@ -0,0 +1,28 @@
+xml.instruct!
+xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
+ xml.channel do
+ xml.title @title
+ xml.link url_for(:controller => 'welcome', :only_path => false)
+ xml.pubDate CGI.rfc1123_date(@journals.first ? @journals.first.created_on : Time.now)
+ xml.description l(:label_reported_issues)
+ @journals.each do |journal|
+ issue = journal.issue
+ xml.item do
+ xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
+ url = url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
+ xml.link url
+ xml.description do
+ xml.text! h(journal.notes)
+ xml.text! "
"
+ journal.details.each do |detail|
+ xml.text! "- " + show_detail(detail, false) + "
"
+ end
+ xml.text! "
"
+ end
+ xml.pubDate CGI.rfc1123_date(journal.created_on)
+ xml.guid url
+ xml.author h(journal.user.name)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/views/feeds/history_atom.rxml b/app/views/feeds/history_atom.rxml
new file mode 100644
index 00000000..9d82ef60
--- /dev/null
+++ b/app/views/feeds/history_atom.rxml
@@ -0,0 +1,28 @@
+xml.instruct!
+xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
+ xml.title @title
+ xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'history', :format => 'atom', :only_path => false)
+ xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
+ xml.id url_for(:controller => 'welcome', :only_path => false)
+ xml.updated CGI.rfc1123_date(@journals.first.created_on) if @journals.any?
+ xml.author { xml.name "#{Setting.app_title}" }
+ @journals.each do |journal|
+ issue = journal.issue
+ xml.entry do
+ xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
+ xml.link "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
+ xml.id url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
+ xml.updated CGI.rfc1123_date(journal.created_on)
+ xml.author { xml.name journal.user.name }
+ xml.summary journal.notes
+ xml.content "type" => "html" do
+ xml.text! journal.notes
+ xml.text! ""
+ journal.details.each do |detail|
+ xml.text! "- " + show_detail(detail, false) + "
"
+ end
+ xml.text! "
"
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/views/feeds/issues.rxml b/app/views/feeds/issues.rxml
new file mode 100644
index 00000000..fb120b7c
--- /dev/null
+++ b/app/views/feeds/issues.rxml
@@ -0,0 +1,20 @@
+xml.instruct!
+xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
+ xml.channel do
+ xml.title @title
+ xml.link url_for(:controller => 'welcome', :only_path => false)
+ xml.pubDate CGI.rfc1123_date(@issues.first ? @issues.first.created_on : Time.now)
+ xml.description l(:label_reported_issues)
+ @issues.each do |issue|
+ xml.item do
+ xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
+ url = url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
+ xml.link url
+ xml.description h(issue.description)
+ xml.pubDate CGI.rfc1123_date(issue.created_on)
+ xml.guid url
+ xml.author h(issue.author.name)
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/views/feeds/issues_atom.rxml b/app/views/feeds/issues_atom.rxml
new file mode 100644
index 00000000..bb15fc49
--- /dev/null
+++ b/app/views/feeds/issues_atom.rxml
@@ -0,0 +1,22 @@
+xml.instruct!
+xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
+ xml.title @title
+ xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'issues', :format => 'atom', :only_path => false)
+ xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
+ xml.id url_for(:controller => 'welcome', :only_path => false)
+ xml.updated CGI.rfc1123_date(@issues.first.updated_on) if @issues.any?
+ xml.author { xml.name "#{Setting.app_title}" }
+ @issues.each do |issue|
+ xml.entry do
+ xml.title "#{issue.project.name} - #{issue.tracker.name} ##{issue.id}: #{issue.subject}"
+ xml.link "rel" => "alternate", "href" => url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
+ xml.id url_for(:controller => 'issues' , :action => 'show', :id => issue, :only_path => false)
+ xml.updated CGI.rfc1123_date(issue.updated_on)
+ xml.author { xml.name issue.author.name }
+ xml.summary issue.description
+ xml.content "type" => "html" do
+ xml.text! issue.description
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/views/feeds/news.rxml b/app/views/feeds/news.rxml
index a85d8671..d7248b6c 100644
--- a/app/views/feeds/news.rxml
+++ b/app/views/feeds/news.rxml
@@ -1,20 +1,20 @@
-xml.instruct!
-xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
- xml.channel do
- xml.title "#{Setting.app_title}: #{l(:label_news_latest)}"
- xml.link url_for(:controller => 'welcome', :only_path => false)
- xml.pubDate CGI.rfc1123_date(@news.first ? @news.first.created_on : Time.now)
- xml.description l(:label_news_latest)
- @news.each do |news|
- xml.item do
- xml.title "#{news.project.name}: #{news.title}"
- news_url = url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
- xml.link news_url
- xml.description h(news.summary)
- xml.pubDate CGI.rfc1123_date(news.created_on)
- xml.guid news_url
- xml.author h(news.author.name)
- end
- end
- end
+xml.instruct!
+xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
+ xml.channel do
+ xml.title "#{Setting.app_title}: #{l(:label_news_latest)}"
+ xml.link url_for(:controller => 'welcome', :only_path => false)
+ xml.pubDate CGI.rfc1123_date(@news.first ? @news.first.created_on : Time.now)
+ xml.description l(:label_news_latest)
+ @news.each do |news|
+ xml.item do
+ xml.title "#{news.project.name}: #{news.title}"
+ news_url = url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
+ xml.link news_url
+ xml.description h(news.summary)
+ xml.pubDate CGI.rfc1123_date(news.created_on)
+ xml.guid news_url
+ xml.author h(news.author.name)
+ end
+ end
+ end
end
\ No newline at end of file
diff --git a/app/views/feeds/news_atom.rxml b/app/views/feeds/news_atom.rxml
new file mode 100644
index 00000000..2550341c
--- /dev/null
+++ b/app/views/feeds/news_atom.rxml
@@ -0,0 +1,22 @@
+xml.instruct!
+xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
+ xml.title "#{Setting.app_title}: #{l(:label_news_latest)}"
+ xml.link "rel" => "self", "href" => url_for(:controller => 'feeds', :action => 'news', :format => 'atom', :only_path => false)
+ xml.link "rel" => "alternate", "href" => url_for(:controller => 'welcome', :only_path => false)
+ xml.id url_for(:controller => 'welcome', :only_path => false)
+ xml.updated CGI.rfc1123_date(@news.first.created_on) if @news.any?
+ xml.author { xml.name "#{Setting.app_title}" }
+ @news.each do |news|
+ xml.entry do
+ xml.title news.title
+ xml.link "rel" => "alternate", "href" => url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
+ xml.id url_for(:controller => 'news' , :action => 'show', :id => news, :only_path => false)
+ xml.updated CGI.rfc1123_date(news.created_on)
+ xml.author { xml.name news.author.name }
+ xml.summary h(news.summary)
+ xml.content "type" => "html" do
+ xml.text! news.description
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/views/projects/feeds.rhtml b/app/views/projects/feeds.rhtml
new file mode 100644
index 00000000..037469a8
--- /dev/null
+++ b/app/views/projects/feeds.rhtml
@@ -0,0 +1,33 @@
+<%= l(:label_feed_plural) %> (<%=h @project.name %>)
+
+
+
+<%= l(:label_issue_plural) %> |
+<%= l(:label_reported_issues) %> |
+<%= link_to 'RSS', {:controller => 'feeds', :action => 'issues', :project_id => @project, :key => @key}, :class => 'icon icon-feed' %> |
+<%= link_to 'Atom', {:controller => 'feeds', :action => 'issues', :project_id => @project, :key => @key, :format => 'atom'}, :class => 'icon icon-feed' %> |
+
+<%= l(:label_changes_details) %> |
+<%= link_to 'RSS', {:controller => 'feeds', :action => 'history', :project_id => @project, :key => @key}, :class => 'icon icon-feed' %> |
+<%= link_to 'Atom', {:controller => 'feeds', :action => 'history', :project_id => @project, :key => @key, :format => 'atom'}, :class => 'icon icon-feed' %> |
+
+
+<% @queries.each do |query| %>
+<%=h query.name %> |
+<%= l(:label_reported_issues) %> |
+<%= link_to 'RSS', {:controller => 'feeds', :action => 'issues', :project_id => @project, :query_id => query, :key => @key}, :class => 'icon icon-feed' %> |
+<%= link_to 'Atom', {:controller => 'feeds', :action => 'issues', :project_id => @project, :query_id => query, :key => @key, :format => 'atom'}, :class => 'icon icon-feed' %> |
+
+<%= l(:label_changes_details) %> |
+<%= link_to 'RSS', {:controller => 'feeds', :action => 'history', :project_id => @project, :query_id => query, :key => @key}, :class => 'icon icon-feed' %> |
+<%= link_to 'Atom', {:controller => 'feeds', :action => 'history', :project_id => @project, :query_id => query, :key => @key, :format => 'atom'}, :class => 'icon icon-feed' %> |
+
+<% end %>
+
+ <%= l(:label_news_plural) %> |
+<%= l(:label_news_latest) %> |
+<%= link_to 'RSS', {:controller => 'feeds', :action => 'news', :project_id => @project, :key => @key}, :class => 'icon icon-feed' %> |
+<%= link_to 'Atom', {:controller => 'feeds', :action => 'news', :project_id => @project, :key => @key, :format => 'atom'}, :class => 'icon icon-feed' %> |
+
+
+
\ No newline at end of file
diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml
index b38eceaa..9ecbbb66 100644
--- a/app/views/projects/show.rhtml
+++ b/app/views/projects/show.rhtml
@@ -1,3 +1,7 @@
+
+<%= link_to l(:label_feed_plural), {:action => 'feeds', :id => @project}, :class => 'icon icon-feed' %>
+
+
<%=l(:label_overview)%>
diff --git a/db/migrate/030_add_projects_feeds_permissions.rb b/db/migrate/030_add_projects_feeds_permissions.rb
new file mode 100644
index 00000000..63131001
--- /dev/null
+++ b/db/migrate/030_add_projects_feeds_permissions.rb
@@ -0,0 +1,9 @@
+class AddProjectsFeedsPermissions < ActiveRecord::Migration
+ def self.up
+ Permission.create :controller => "projects", :action => "feeds", :description => "label_feed_plural", :sort => 132, :is_public => true, :mail_option => 0, :mail_enabled => 0
+ end
+
+ def self.down
+ Permission.find_by_controller_and_action('projects', 'feeds').destroy
+ end
+end
diff --git a/lang/de.yml b/lang/de.yml
index 1e301456..9d4015d3 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -328,6 +328,8 @@ label_wiki: Wiki
label_page_index: Index
label_current_version: Gegenwärtige Version
label_preview: Vorbetrachtung
+label_feed_plural: Feeds
+label_changes_details: Details of all changes
button_login: Einloggen
button_submit: Einreichen
diff --git a/lang/en.yml b/lang/en.yml
index f369afbd..637c36f5 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -328,6 +328,8 @@ label_wiki: Wiki
label_page_index: Index
label_current_version: Current version
label_preview: Preview
+label_feed_plural: Feeds
+label_changes_details: Details of all changes
button_login: Login
button_submit: Submit
diff --git a/lang/es.yml b/lang/es.yml
index 0162b6bd..604a9e1c 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -328,6 +328,8 @@ label_wiki: Wiki
label_page_index: Índice
label_current_version: Versión actual
label_preview: Previo
+label_feed_plural: Feeds
+label_changes_details: Detalles de todos los cambios
button_login: Conexión
button_submit: Someter
diff --git a/lang/fr.yml b/lang/fr.yml
index 8f629f7b..a41f61f3 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -328,6 +328,8 @@ label_wiki: Wiki
label_page_index: Index
label_current_version: Version actuelle
label_preview: Prévisualisation
+label_feed_plural: Flux RSS
+label_changes_details: Détails de tous les changements
button_login: Connexion
button_submit: Soumettre
diff --git a/lang/it.yml b/lang/it.yml
index eae7c882..4380651f 100644
--- a/lang/it.yml
+++ b/lang/it.yml
@@ -328,6 +328,8 @@ label_wiki: Wiki
label_page_index: Indice
label_current_version: Versione corrente
label_preview: Previsione
+label_feed_plural: Feeds
+label_changes_details: Particolari di tutti i cambiamenti
button_login: Login
button_submit: Invia
diff --git a/lang/ja.yml b/lang/ja.yml
index be45f58a..0c7c00ad 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -329,6 +329,8 @@ label_wiki: Wiki
label_page_index: 索引
label_current_version: 最近版
label_preview: 下検分
+label_feed_plural: Feeds
+label_changes_details: Details of all changes
button_login: ログイン
button_submit: 変更
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 3fe0b1d6..7fda16cd 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -154,6 +154,7 @@ vertical-align: middle;
.icon-attachment { background-image: url(../images/attachment.png); }
.icon-index { background-image: url(../images/index.png); }
.icon-history { background-image: url(../images/history.png); }
+.icon-feed { background-image: url(../images/feed.png); }
.icon22-projects { background-image: url(../images/22x22/projects.png); }
.icon22-users { background-image: url(../images/22x22/users.png); }
@@ -247,6 +248,7 @@ legend {color: #505050;}
.even {background-color: #fff;}
hr { border:0; border-top: dotted 1px #fff; border-bottom: dotted 1px #c0c0c0; }
table p {margin:0; padding:0;}
+table td {padding-right: 1em;}
.highlight { background-color: #FCFD8D;}
diff --git a/test/fixtures/members.yml b/test/fixtures/members.yml
index 0626bdb1..392225e5 100644
--- a/test/fixtures/members.yml
+++ b/test/fixtures/members.yml
@@ -11,3 +11,10 @@ members_002:
role_id: 2
id: 2
user_id: 3
+members_003:
+ created_on: 2006-07-19 19:35:36 +02:00
+ project_id: 2
+ role_id: 2
+ id: 3
+ user_id: 2
+
\ No newline at end of file
diff --git a/test/functional/feeds_controller_test.rb b/test/functional/feeds_controller_test.rb
new file mode 100644
index 00000000..279b2c1a
--- /dev/null
+++ b/test/functional/feeds_controller_test.rb
@@ -0,0 +1,66 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require File.dirname(__FILE__) + '/../test_helper'
+require 'feeds_controller'
+
+# Re-raise errors caught by the controller.
+class FeedsController; def rescue_action(e) raise e end; end
+
+class FeedsControllerTest < Test::Unit::TestCase
+ fixtures :projects, :users, :members, :roles
+
+ def setup
+ @controller = FeedsController.new
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+ end
+
+ def test_news
+ get :news
+ assert_response :success
+ assert_template 'news'
+ assert_not_nil assigns(:news)
+ end
+
+ def test_issues
+ get :issues
+ assert_response :success
+ assert_template 'issues'
+ assert_not_nil assigns(:issues)
+ end
+
+ def test_history
+ get :history
+ assert_response :success
+ assert_template 'history'
+ assert_not_nil assigns(:journals)
+ end
+
+ def test_project_privacy
+ get :news, :project_id => 2
+ assert_response 403
+ end
+
+ def test_rss_key
+ user = User.find(2)
+ key = user.get_or_create_rss_key.value
+
+ get :news, :project_id => 2, :key => key
+ assert_response :success
+ end
+end
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 211e6554..10aafa58 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -85,4 +85,17 @@ class UserTest < Test::Unit::TestCase
user = User.try_to_login("jsmith", "jsmith")
assert_equal nil, user
end
+
+ def test_rss_key
+ assert_nil @jsmith.rss_key
+ key = @jsmith.get_or_create_rss_key
+ assert_kind_of Token, key
+ assert_equal 40, key.value.length
+
+ @jsmith.reload
+ assert_equal key.value, @jsmith.get_or_create_rss_key.value
+
+ @jsmith.reload
+ assert_equal key.value, @jsmith.rss_key.value
+ end
end