@@ -1,68 +1,68 | |||||
1 | <% if @query.new_record? %> |
|
1 | <% if @query.new_record? %> | |
2 | <h2><%=l(:label_issue_plural)%></h2> |
|
2 | <h2><%=l(:label_issue_plural)%></h2> | |
3 | <% html_title(l(:label_issue_plural)) %> |
|
3 | <% html_title(l(:label_issue_plural)) %> | |
4 |
|
4 | |||
5 | <% form_tag({ :controller => 'queries', :action => 'new' }, :id => 'query_form') do %> |
|
5 | <% form_tag({ :controller => 'queries', :action => 'new' }, :id => 'query_form') do %> | |
6 | <%= hidden_field_tag('project_id', @project.to_param) if @project %> |
|
6 | <%= hidden_field_tag('project_id', @project.to_param) if @project %> | |
7 | <fieldset id="filters"><legend><%= l(:label_filter_plural) %></legend> |
|
7 | <fieldset id="filters"><legend><%= l(:label_filter_plural) %></legend> | |
8 | <%= render :partial => 'queries/filters', :locals => {:query => @query} %> |
|
8 | <%= render :partial => 'queries/filters', :locals => {:query => @query} %> | |
9 | <p class="buttons"> |
|
9 | <p class="buttons"> | |
10 | <%= link_to_remote l(:button_apply), |
|
10 | <%= link_to_remote l(:button_apply), | |
11 | { :url => { :set_filter => 1 }, |
|
11 | { :url => { :set_filter => 1 }, | |
12 | :update => "content", |
|
12 | :update => "content", | |
13 | :with => "Form.serialize('query_form')" |
|
13 | :with => "Form.serialize('query_form')" | |
14 | }, :class => 'icon icon-checked' %> |
|
14 | }, :class => 'icon icon-checked' %> | |
15 |
|
15 | |||
16 | <%= link_to_remote l(:button_clear), |
|
16 | <%= link_to_remote l(:button_clear), | |
17 | { :url => { :set_filter => 1, :project_id => @project }, |
|
17 | { :url => { :set_filter => 1, :project_id => @project }, | |
18 | :method => :get, |
|
18 | :method => :get, | |
19 | :update => "content", |
|
19 | :update => "content", | |
20 | }, :class => 'icon icon-reload' %> |
|
20 | }, :class => 'icon icon-reload' %> | |
21 |
|
21 | |||
22 | <% if User.current.allowed_to?(:save_queries, @project, :global => true) %> |
|
22 | <% if User.current.allowed_to?(:save_queries, @project, :global => true) %> | |
23 | <%= link_to l(:button_save), {}, :onclick => "$('query_form').submit(); return false;", :class => 'icon icon-save' %> |
|
23 | <%= link_to l(:button_save), {}, :onclick => "$('query_form').submit(); return false;", :class => 'icon icon-save' %> | |
24 | <% end %> |
|
24 | <% end %> | |
25 | </p> |
|
25 | </p> | |
26 | </fieldset> |
|
26 | </fieldset> | |
27 | <% end %> |
|
27 | <% end %> | |
28 | <% else %> |
|
28 | <% else %> | |
29 | <div class="contextual"> |
|
29 | <div class="contextual"> | |
30 | <% if @query.editable_by?(User.current) %> |
|
30 | <% if @query.editable_by?(User.current) %> | |
31 | <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %> |
|
31 | <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %> | |
32 | <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> |
|
32 | <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
33 | <% end %> |
|
33 | <% end %> | |
34 | </div> |
|
34 | </div> | |
35 | <h2><%=h @query.name %></h2> |
|
35 | <h2><%=h @query.name %></h2> | |
36 | <div id="query_form"></div> |
|
36 | <div id="query_form"></div> | |
37 | <% html_title @query.name %> |
|
37 | <% html_title @query.name %> | |
38 | <% end %> |
|
38 | <% end %> | |
39 | <%= error_messages_for 'query' %> |
|
39 | <%= error_messages_for 'query' %> | |
40 | <% if @query.valid? %> |
|
40 | <% if @query.valid? %> | |
41 | <% if @issues.empty? %> |
|
41 | <% if @issues.empty? %> | |
42 | <p class="nodata"><%= l(:label_no_data) %></p> |
|
42 | <p class="nodata"><%= l(:label_no_data) %></p> | |
43 | <% else %> |
|
43 | <% else %> | |
44 | <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %> |
|
44 | <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %> | |
45 | <p class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></p> |
|
45 | <p class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></p> | |
46 | <% end %> |
|
46 | <% end %> | |
47 |
|
47 | |||
48 | <% other_formats_links do |f| %> |
|
48 | <% other_formats_links do |f| %> | |
49 | <%= f.link_to 'Atom', :url => {:query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key} %> |
|
49 | <%= f.link_to 'Atom', :url => { :project_id => @project, :query_id => (@query.new_record? ? nil : @query), :key => User.current.rss_key } %> | |
50 | <%= f.link_to 'CSV' %> |
|
50 | <%= f.link_to 'CSV', :url => { :project_id => @project } %> | |
51 | <%= f.link_to 'PDF' %> |
|
51 | <%= f.link_to 'PDF', :url => { :project_id => @project } %> | |
52 | <% end %> |
|
52 | <% end %> | |
53 |
|
53 | |||
54 | <% end %> |
|
54 | <% end %> | |
55 |
|
55 | |||
56 | <% content_for :sidebar do %> |
|
56 | <% content_for :sidebar do %> | |
57 | <%= render :partial => 'issues/sidebar' %> |
|
57 | <%= render :partial => 'issues/sidebar' %> | |
58 | <% end %> |
|
58 | <% end %> | |
59 |
|
59 | |||
60 | <% content_for :header_tags do %> |
|
60 | <% content_for :header_tags do %> | |
61 | <%= auto_discovery_link_tag(:atom, {:query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural)) %> |
|
61 | <%= auto_discovery_link_tag(:atom, {:query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_issue_plural)) %> | |
62 | <%= auto_discovery_link_tag(:atom, {:action => 'changes', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details)) %> |
|
62 | <%= auto_discovery_link_tag(:atom, {:action => 'changes', :query_id => @query, :format => 'atom', :page => nil, :key => User.current.rss_key}, :title => l(:label_changes_details)) %> | |
63 | <%= javascript_include_tag 'context_menu' %> |
|
63 | <%= javascript_include_tag 'context_menu' %> | |
64 | <%= stylesheet_link_tag 'context_menu' %> |
|
64 | <%= stylesheet_link_tag 'context_menu' %> | |
65 | <% end %> |
|
65 | <% end %> | |
66 |
|
66 | |||
67 | <div id="context-menu" style="display: none;"></div> |
|
67 | <div id="context-menu" style="display: none;"></div> | |
68 | <%= javascript_tag "new ContextMenu('#{url_for(:controller => 'issues', :action => 'context_menu')}')" %> |
|
68 | <%= javascript_tag "new ContextMenu('#{url_for(:controller => 'issues', :action => 'context_menu')}')" %> |
@@ -1,92 +1,129 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require "#{File.dirname(__FILE__)}/../test_helper" |
|
18 | require "#{File.dirname(__FILE__)}/../test_helper" | |
19 |
|
19 | |||
20 | class IssuesTest < ActionController::IntegrationTest |
|
20 | class IssuesTest < ActionController::IntegrationTest | |
21 | fixtures :projects, |
|
21 | fixtures :projects, | |
22 | :users, |
|
22 | :users, | |
23 | :roles, |
|
23 | :roles, | |
24 | :members, |
|
24 | :members, | |
25 | :trackers, |
|
25 | :trackers, | |
26 | :projects_trackers, |
|
26 | :projects_trackers, | |
27 | :enabled_modules, |
|
27 | :enabled_modules, | |
28 | :issue_statuses, |
|
28 | :issue_statuses, | |
29 | :issues, |
|
29 | :issues, | |
30 | :enumerations, |
|
30 | :enumerations, | |
31 | :custom_fields, |
|
31 | :custom_fields, | |
32 | :custom_values, |
|
32 | :custom_values, | |
33 | :custom_fields_trackers |
|
33 | :custom_fields_trackers | |
34 |
|
34 | |||
35 | # create an issue |
|
35 | # create an issue | |
36 | def test_add_issue |
|
36 | def test_add_issue | |
37 | log_user('jsmith', 'jsmith') |
|
37 | log_user('jsmith', 'jsmith') | |
38 | get 'projects/1/issues/new', :tracker_id => '1' |
|
38 | get 'projects/1/issues/new', :tracker_id => '1' | |
39 | assert_response :success |
|
39 | assert_response :success | |
40 | assert_template 'issues/new' |
|
40 | assert_template 'issues/new' | |
41 |
|
41 | |||
42 | post 'projects/1/issues', :tracker_id => "1", |
|
42 | post 'projects/1/issues', :tracker_id => "1", | |
43 | :issue => { :start_date => "2006-12-26", |
|
43 | :issue => { :start_date => "2006-12-26", | |
44 | :priority_id => "3", |
|
44 | :priority_id => "3", | |
45 | :subject => "new test issue", |
|
45 | :subject => "new test issue", | |
46 | :category_id => "", |
|
46 | :category_id => "", | |
47 | :description => "new issue", |
|
47 | :description => "new issue", | |
48 | :done_ratio => "0", |
|
48 | :done_ratio => "0", | |
49 | :due_date => "", |
|
49 | :due_date => "", | |
50 | :assigned_to_id => "" }, |
|
50 | :assigned_to_id => "" }, | |
51 | :custom_fields => {'2' => 'Value for field 2'} |
|
51 | :custom_fields => {'2' => 'Value for field 2'} | |
52 | # find created issue |
|
52 | # find created issue | |
53 | issue = Issue.find_by_subject("new test issue") |
|
53 | issue = Issue.find_by_subject("new test issue") | |
54 | assert_kind_of Issue, issue |
|
54 | assert_kind_of Issue, issue | |
55 |
|
55 | |||
56 | # check redirection |
|
56 | # check redirection | |
57 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue |
|
57 | assert_redirected_to :controller => 'issues', :action => 'show', :id => issue | |
58 | follow_redirect! |
|
58 | follow_redirect! | |
59 | assert_equal issue, assigns(:issue) |
|
59 | assert_equal issue, assigns(:issue) | |
60 |
|
60 | |||
61 | # check issue attributes |
|
61 | # check issue attributes | |
62 | assert_equal 'jsmith', issue.author.login |
|
62 | assert_equal 'jsmith', issue.author.login | |
63 | assert_equal 1, issue.project.id |
|
63 | assert_equal 1, issue.project.id | |
64 | assert_equal 1, issue.status.id |
|
64 | assert_equal 1, issue.status.id | |
65 | end |
|
65 | end | |
66 |
|
66 | |||
67 | # add then remove 2 attachments to an issue |
|
67 | # add then remove 2 attachments to an issue | |
68 | def test_issue_attachements |
|
68 | def test_issue_attachements | |
69 | log_user('jsmith', 'jsmith') |
|
69 | log_user('jsmith', 'jsmith') | |
70 | set_tmp_attachments_directory |
|
70 | set_tmp_attachments_directory | |
71 |
|
71 | |||
72 | post 'issues/1/edit', |
|
72 | post 'issues/1/edit', | |
73 | :notes => 'Some notes', |
|
73 | :notes => 'Some notes', | |
74 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}} |
|
74 | :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}} | |
75 | assert_redirected_to "issues/1" |
|
75 | assert_redirected_to "issues/1" | |
76 |
|
76 | |||
77 | # make sure attachment was saved |
|
77 | # make sure attachment was saved | |
78 | attachment = Issue.find(1).attachments.find_by_filename("testfile.txt") |
|
78 | attachment = Issue.find(1).attachments.find_by_filename("testfile.txt") | |
79 | assert_kind_of Attachment, attachment |
|
79 | assert_kind_of Attachment, attachment | |
80 | assert_equal Issue.find(1), attachment.container |
|
80 | assert_equal Issue.find(1), attachment.container | |
81 | assert_equal 'This is an attachment', attachment.description |
|
81 | assert_equal 'This is an attachment', attachment.description | |
82 | # verify the size of the attachment stored in db |
|
82 | # verify the size of the attachment stored in db | |
83 | #assert_equal file_data_1.length, attachment.filesize |
|
83 | #assert_equal file_data_1.length, attachment.filesize | |
84 | # verify that the attachment was written to disk |
|
84 | # verify that the attachment was written to disk | |
85 | assert File.exist?(attachment.diskfile) |
|
85 | assert File.exist?(attachment.diskfile) | |
86 |
|
86 | |||
87 | # remove the attachments |
|
87 | # remove the attachments | |
88 | Issue.find(1).attachments.each(&:destroy) |
|
88 | Issue.find(1).attachments.each(&:destroy) | |
89 | assert_equal 0, Issue.find(1).attachments.length |
|
89 | assert_equal 0, Issue.find(1).attachments.length | |
90 | end |
|
90 | end | |
91 |
|
91 | |||
|
92 | def test_other_formats_links_on_get_index | |||
|
93 | get '/projects/ecookbook/issues' | |||
|
94 | ||||
|
95 | %w(Atom PDF CSV).each do |format| | |||
|
96 | assert_tag :a, :content => format, | |||
|
97 | :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}", | |||
|
98 | :rel => 'nofollow' } | |||
|
99 | end | |||
|
100 | end | |||
|
101 | ||||
|
102 | def test_other_formats_links_on_post_index_without_project_id_in_url | |||
|
103 | post '/issues', :project_id => 'ecookbook' | |||
|
104 | ||||
|
105 | %w(Atom PDF CSV).each do |format| | |||
|
106 | assert_tag :a, :content => format, | |||
|
107 | :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}", | |||
|
108 | :rel => 'nofollow' } | |||
|
109 | end | |||
|
110 | end | |||
|
111 | ||||
|
112 | def test_pagination_links_on_get_index | |||
|
113 | Setting.per_page_options = '2' | |||
|
114 | get '/projects/ecookbook/issues' | |||
|
115 | ||||
|
116 | assert_tag :a, :content => '2', | |||
|
117 | :attributes => { :href => '/projects/ecookbook/issues?page=2' } | |||
|
118 | ||||
|
119 | end | |||
|
120 | ||||
|
121 | def test_pagination_links_on_post_index_without_project_id_in_url | |||
|
122 | Setting.per_page_options = '2' | |||
|
123 | post '/issues', :project_id => 'ecookbook' | |||
|
124 | ||||
|
125 | assert_tag :a, :content => '2', | |||
|
126 | :attributes => { :href => '/projects/ecookbook/issues?page=2' } | |||
|
127 | ||||
|
128 | end | |||
92 | end |
|
129 | end |
General Comments 0
You need to be logged in to leave comments.
Login now