@@ -1,7 +1,7 | |||
|
1 | 1 | class FilesController < ApplicationController |
|
2 | 2 | menu_item :files |
|
3 | 3 | |
|
4 | before_filter :find_project | |
|
4 | before_filter :find_project_by_project_id | |
|
5 | 5 | before_filter :authorize |
|
6 | 6 | |
|
7 | 7 | helper :sort |
@@ -31,6 +31,6 class FilesController < ApplicationController | |||
|
31 | 31 | if !attachments.empty? && Setting.notified_events.include?('file_added') |
|
32 | 32 | Mailer.deliver_attachments_added(attachments[:files]) |
|
33 | 33 | end |
|
34 | redirect_to :controller => 'files', :action => 'index', :id => @project | |
|
34 | redirect_to project_files_path(@project) | |
|
35 | 35 | end |
|
36 | 36 | end |
@@ -1,5 +1,5 | |||
|
1 | 1 | <div class="contextual"> |
|
2 |
<%= link_to_if_authorized l(:label_attachment_new), |
|
|
2 | <%= link_to_if_authorized l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add' %> | |
|
3 | 3 | </div> |
|
4 | 4 | |
|
5 | 5 | <h2><%=l(:label_attachment_plural)%></h2> |
@@ -2,7 +2,7 | |||
|
2 | 2 | |
|
3 | 3 | <%= error_messages_for 'attachment' %> |
|
4 | 4 | <div class="box"> |
|
5 |
<% form_tag( |
|
|
5 | <% form_tag(project_files_path(@project), :multipart => true, :class => "tabular") do %> | |
|
6 | 6 | |
|
7 | 7 | <% if @versions.any? %> |
|
8 | 8 | <p><label for="version_id"><%=l(:field_version)%></label> |
@@ -181,6 +181,7 ActionController::Routing::Routes.draw do |map| | |||
|
181 | 181 | :unarchive => :post |
|
182 | 182 | } do |project| |
|
183 | 183 | project.resource :project_enumerations, :as => 'enumerations', :only => [:update, :destroy] |
|
184 | project.resources :files, :only => [:index, :new, :create] | |
|
184 | 185 | end |
|
185 | 186 | |
|
186 | 187 | # Destroy uses a get request to prompt the user before the actual DELETE request |
@@ -189,15 +190,9 ActionController::Routing::Routes.draw do |map| | |||
|
189 | 190 | # TODO: port to be part of the resources route(s) |
|
190 | 191 | map.with_options :controller => 'projects' do |project_mapper| |
|
191 | 192 | project_mapper.with_options :conditions => {:method => :get} do |project_views| |
|
192 | project_views.connect 'projects/:id/files', :controller => 'files', :action => 'index' | |
|
193 | project_views.connect 'projects/:id/files/new', :controller => 'files', :action => 'new' | |
|
194 | 193 | project_views.connect 'projects/:id/settings/:tab', :controller => 'projects', :action => 'settings' |
|
195 | 194 | project_views.connect 'projects/:project_id/issues/:copy_from/copy', :controller => 'issues', :action => 'new' |
|
196 | 195 | end |
|
197 | ||
|
198 | project_mapper.with_options :conditions => {:method => :post} do |project_actions| | |
|
199 | project_actions.connect 'projects/:id/files/new', :controller => 'files', :action => 'create' | |
|
200 | end | |
|
201 | 196 | end |
|
202 | 197 | |
|
203 | 198 | map.with_options :controller => 'activities', :action => 'index', :conditions => {:method => :get} do |activity| |
@@ -198,7 +198,7 Redmine::MenuManager.map :project_menu do |menu| | |||
|
198 | 198 | :if => Proc.new { |p| p.wiki && !p.wiki.new_record? } |
|
199 | 199 | menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id, |
|
200 | 200 | :if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural |
|
201 | menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural | |
|
201 | menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id | |
|
202 | 202 | menu.push :repository, { :controller => 'repositories', :action => 'show' }, |
|
203 | 203 | :if => Proc.new { |p| p.repository && !p.repository.new_record? } |
|
204 | 204 | menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true |
@@ -12,7 +12,7 class FilesControllerTest < ActionController::TestCase | |||
|
12 | 12 | end |
|
13 | 13 | |
|
14 | 14 | def test_index |
|
15 | get :index, :id => 1 | |
|
15 | get :index, :project_id => 1 | |
|
16 | 16 | assert_response :success |
|
17 | 17 | assert_template 'index' |
|
18 | 18 | assert_not_nil assigns(:containers) |
@@ -33,7 +33,7 class FilesControllerTest < ActionController::TestCase | |||
|
33 | 33 | ActionMailer::Base.deliveries.clear |
|
34 | 34 | |
|
35 | 35 | assert_difference 'Attachment.count' do |
|
36 | post :create, :id => 1, :version_id => '', | |
|
36 | post :create, :project_id => 1, :version_id => '', | |
|
37 | 37 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
38 | 38 | assert_response :redirect |
|
39 | 39 | end |
@@ -54,7 +54,7 class FilesControllerTest < ActionController::TestCase | |||
|
54 | 54 | Setting.notified_events = ['file_added'] |
|
55 | 55 | |
|
56 | 56 | assert_difference 'Attachment.count' do |
|
57 | post :create, :id => 1, :version_id => '2', | |
|
57 | post :create, :project_id => 1, :version_id => '2', | |
|
58 | 58 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
59 | 59 | assert_response :redirect |
|
60 | 60 | end |
@@ -171,15 +171,15 class RoutingTest < ActionController::IntegrationTest | |||
|
171 | 171 | should_route :get, "/projects/1.xml", :controller => 'projects', :action => 'show', :id => '1', :format => 'xml' |
|
172 | 172 | should_route :get, "/projects/4223/settings", :controller => 'projects', :action => 'settings', :id => '4223' |
|
173 | 173 | should_route :get, "/projects/4223/settings/members", :controller => 'projects', :action => 'settings', :id => '4223', :tab => 'members' |
|
174 | should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :id => '33' | |
|
175 | should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :id => '33' | |
|
174 | should_route :get, "/projects/33/files", :controller => 'files', :action => 'index', :project_id => '33' | |
|
175 | should_route :get, "/projects/33/files/new", :controller => 'files', :action => 'new', :project_id => '33' | |
|
176 | 176 | should_route :get, "/projects/33/roadmap", :controller => 'versions', :action => 'index', :project_id => '33' |
|
177 | 177 | should_route :get, "/projects/33/activity", :controller => 'activities', :action => 'index', :id => '33' |
|
178 | 178 | should_route :get, "/projects/33/activity.atom", :controller => 'activities', :action => 'index', :id => '33', :format => 'atom' |
|
179 | 179 | |
|
180 | 180 | should_route :post, "/projects", :controller => 'projects', :action => 'create' |
|
181 | 181 | should_route :post, "/projects.xml", :controller => 'projects', :action => 'create', :format => 'xml' |
|
182 |
should_route :post, "/projects/33/files |
|
|
182 | should_route :post, "/projects/33/files", :controller => 'files', :action => 'create', :project_id => '33' | |
|
183 | 183 | should_route :post, "/projects/64/archive", :controller => 'projects', :action => 'archive', :id => '64' |
|
184 | 184 | should_route :post, "/projects/64/unarchive", :controller => 'projects', :action => 'unarchive', :id => '64' |
|
185 | 185 |
General Comments 0
You need to be logged in to leave comments.
Login now