diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 5f08224cc..dc1cef492 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -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 diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 10450970c..a3b1abde4 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -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] diff --git a/app/views/issues/index.rhtml b/app/views/issues/index.rhtml index 04298b5ca..ee6514d0b 100644 --- a/app/views/issues/index.rhtml +++ b/app/views/issues/index.rhtml @@ -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 %> diff --git a/app/views/issues/changes.rxml b/app/views/journals/index.rxml similarity index 100% rename from app/views/issues/changes.rxml rename to app/views/journals/index.rxml diff --git a/config/routes.rb b/config/routes.rb index 7b22328bf..b480a4900 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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| diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index dfdb74c42..7c00db708 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -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 diff --git a/test/functional/journals_controller_test.rb b/test/functional/journals_controller_test.rb index 7d8345b28..83e015af6 100644 --- a/test/functional/journals_controller_test.rb +++ b/test/functional/journals_controller_test.rb @@ -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 diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index 63293d594..b05a1285d 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -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