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