Commit 08adbbc9 authored by edavis10's avatar edavis10
Browse files

Refactor: move IssuesController#changes to JournalsController#index.

Since #changes is only an Atom feed of journals of a query, it makes
more sense to have it on the JournalsController resource.

git-svn-id: https://svn.redmine.org/redmine/trunk@4034 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent e5e79b00
......@@ -22,11 +22,11 @@ class IssuesController < ApplicationController
before_filter :find_issue, :only => [:show, :edit, :update]
before_filter :find_issues, :only => [:bulk_edit, :move, :perform_move, :destroy]
before_filter :find_project, :only => [:new, :create]
before_filter :authorize, :except => [:index, :changes]
before_filter :find_optional_project, :only => [:index, :changes]
before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => [:index]
before_filter :check_for_default_issue_status, :only => [:new, :create]
before_filter :build_new_issue_from_params, :only => [:new, :create]
accept_key_auth :index, :show, :changes
accept_key_auth :index, :show
rescue_from Query::StatementInvalid, :with => :query_statement_invalid
......@@ -95,21 +95,6 @@ class IssuesController < ApplicationController
render_404
end
def changes
retrieve_query
sort_init 'id', 'desc'
sort_update(@query.sortable_columns)
if @query.valid?
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
:limit => 25)
end
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
render :layout => false, :content_type => 'application/atom+xml'
rescue ActiveRecord::RecordNotFound
render_404
end
def show
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
@journals.each_with_index {|j,i| j.indice = i+1}
......@@ -124,7 +109,7 @@ class IssuesController < ApplicationController
format.html { render :template => 'issues/show.rhtml' }
format.xml { render :layout => false }
format.json { render :text => @issue.to_json, :layout => false }
format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
end
end
......
......@@ -18,6 +18,29 @@
class JournalsController < ApplicationController
before_filter :find_journal, :only => [:edit]
before_filter :find_issue, :only => [:new]
before_filter :find_optional_project, :only => [:index]
accept_key_auth :index
helper :issues
helper :queries
include QueriesHelper
helper :sort
include SortHelper
def index
retrieve_query
sort_init 'id', 'desc'
sort_update(@query.sortable_columns)
if @query.valid?
@journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
:limit => 25)
end
@title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
render :layout => false, :content_type => 'application/atom+xml'
rescue ActiveRecord::RecordNotFound
render_404
end
def new
journal = Journal.find(params[:journal_id]) if params[:journal_id]
......
......@@ -78,7 +78,7 @@
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural)) %>
<%= auto_discovery_link_tag(:atom, {:action => 'changes', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details)) %>
<%= auto_discovery_link_tag(:atom, {:controller => 'journals', :action => 'index', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details)) %>
<% end %>
<%= context_menu issues_context_menu_path %>
......@@ -108,6 +108,7 @@ ActionController::Routing::Routes.draw do |map|
# TODO: would look nicer as /issues/:id/preview
map.preview_issue '/issues/preview/:id', :controller => 'previews', :action => 'issue'
map.issues_context_menu '/issues/context_menu', :controller => 'context_menus', :action => 'issues'
map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
map.with_options :controller => 'issues' do |issues_routes|
issues_routes.with_options :conditions => {:method => :get} do |issues_views|
......
......@@ -231,13 +231,6 @@ class IssuesControllerTest < ActionController::TestCase
assert_equal columns, session[:query][:column_names].map(&:to_s)
end
def test_changes
get :changes, :project_id => 1
assert_response :success
assert_not_nil assigns(:journals)
assert_equal 'application/atom+xml', @response.content_type
end
def test_show_by_anonymous
get :show, :id => 1
assert_response :success
......@@ -307,7 +300,7 @@ class IssuesControllerTest < ActionController::TestCase
def test_show_atom
get :show, :id => 2, :format => 'atom'
assert_response :success
assert_template 'changes.rxml'
assert_template 'journals/index.rxml'
# Inline image
assert_select 'content', :text => Regexp.new(Regexp.quote('http://test.host/attachments/download/10'))
end
......
......@@ -31,6 +31,13 @@ class JournalsControllerTest < ActionController::TestCase
User.current = nil
end
def test_index
get :index, :project_id => 1
assert_response :success
assert_not_nil assigns(:journals)
assert_equal 'application/atom+xml', @response.content_type
end
def test_reply_to_issue
@request.session[:user_id] = 2
get :new, :id => 1
......
......@@ -106,6 +106,8 @@ class RoutingTest < ActionController::IntegrationTest
should_route :post, "/issues/preview/123", :controller => 'previews', :action => 'issue', :id => '123'
should_route :get, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
should_route :post, "/issues/context_menu", :controller => 'context_menus', :action => 'issues'
should_route :get, "/issues/changes", :controller => 'journals', :action => 'index'
end
context "issue categories" do
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment