@@ -1,95 +1,89 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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 | class ReportsController < ApplicationController |
|
18 | class ReportsController < ApplicationController | |
19 | menu_item :issues |
|
19 | menu_item :issues | |
20 | before_action :find_project, :authorize, :find_issue_statuses |
|
20 | before_action :find_project, :authorize, :find_issue_statuses | |
21 |
|
21 | |||
22 | def issue_report |
|
22 | def issue_report | |
23 | @trackers = @project.rolled_up_trackers(false).visible |
|
23 | @trackers = @project.rolled_up_trackers(false).visible | |
24 | @versions = @project.shared_versions.sort |
|
24 | @versions = @project.shared_versions.sort | |
25 | @priorities = IssuePriority.all.reverse |
|
25 | @priorities = IssuePriority.all.reverse | |
26 | @categories = @project.issue_categories |
|
26 | @categories = @project.issue_categories | |
27 | @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
|
27 | @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort | |
28 | @authors = @project.users.sort |
|
28 | @authors = @project.users.sort | |
29 | @subprojects = @project.descendants.visible |
|
29 | @subprojects = @project.descendants.visible | |
30 |
|
30 | |||
31 | @issues_by_tracker = Issue.by_tracker(@project) |
|
31 | @issues_by_tracker = Issue.by_tracker(@project) | |
32 | @issues_by_version = Issue.by_version(@project) |
|
32 | @issues_by_version = Issue.by_version(@project) | |
33 | @issues_by_priority = Issue.by_priority(@project) |
|
33 | @issues_by_priority = Issue.by_priority(@project) | |
34 | @issues_by_category = Issue.by_category(@project) |
|
34 | @issues_by_category = Issue.by_category(@project) | |
35 | @issues_by_assigned_to = Issue.by_assigned_to(@project) |
|
35 | @issues_by_assigned_to = Issue.by_assigned_to(@project) | |
36 | @issues_by_author = Issue.by_author(@project) |
|
36 | @issues_by_author = Issue.by_author(@project) | |
37 | @issues_by_subproject = Issue.by_subproject(@project) || [] |
|
37 | @issues_by_subproject = Issue.by_subproject(@project) || [] | |
38 |
|
38 | |||
39 | render :template => "reports/issue_report" |
|
39 | render :template => "reports/issue_report" | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | def issue_report_details |
|
42 | def issue_report_details | |
43 | case params[:detail] |
|
43 | case params[:detail] | |
44 | when "tracker" |
|
44 | when "tracker" | |
45 | @field = "tracker_id" |
|
45 | @field = "tracker_id" | |
46 | @rows = @project.rolled_up_trackers(false).visible |
|
46 | @rows = @project.rolled_up_trackers(false).visible | |
47 | @data = Issue.by_tracker(@project) |
|
47 | @data = Issue.by_tracker(@project) | |
48 | @report_title = l(:field_tracker) |
|
48 | @report_title = l(:field_tracker) | |
49 | when "version" |
|
49 | when "version" | |
50 | @field = "fixed_version_id" |
|
50 | @field = "fixed_version_id" | |
51 | @rows = @project.shared_versions.sort |
|
51 | @rows = @project.shared_versions.sort | |
52 | @data = Issue.by_version(@project) |
|
52 | @data = Issue.by_version(@project) | |
53 | @report_title = l(:field_version) |
|
53 | @report_title = l(:field_version) | |
54 | when "priority" |
|
54 | when "priority" | |
55 | @field = "priority_id" |
|
55 | @field = "priority_id" | |
56 | @rows = IssuePriority.all.reverse |
|
56 | @rows = IssuePriority.all.reverse | |
57 | @data = Issue.by_priority(@project) |
|
57 | @data = Issue.by_priority(@project) | |
58 | @report_title = l(:field_priority) |
|
58 | @report_title = l(:field_priority) | |
59 | when "category" |
|
59 | when "category" | |
60 | @field = "category_id" |
|
60 | @field = "category_id" | |
61 | @rows = @project.issue_categories |
|
61 | @rows = @project.issue_categories | |
62 | @data = Issue.by_category(@project) |
|
62 | @data = Issue.by_category(@project) | |
63 | @report_title = l(:field_category) |
|
63 | @report_title = l(:field_category) | |
64 | when "assigned_to" |
|
64 | when "assigned_to" | |
65 | @field = "assigned_to_id" |
|
65 | @field = "assigned_to_id" | |
66 | @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort |
|
66 | @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sort | |
67 | @data = Issue.by_assigned_to(@project) |
|
67 | @data = Issue.by_assigned_to(@project) | |
68 | @report_title = l(:field_assigned_to) |
|
68 | @report_title = l(:field_assigned_to) | |
69 | when "author" |
|
69 | when "author" | |
70 | @field = "author_id" |
|
70 | @field = "author_id" | |
71 | @rows = @project.users.sort |
|
71 | @rows = @project.users.sort | |
72 | @data = Issue.by_author(@project) |
|
72 | @data = Issue.by_author(@project) | |
73 | @report_title = l(:field_author) |
|
73 | @report_title = l(:field_author) | |
74 | when "subproject" |
|
74 | when "subproject" | |
75 | @field = "project_id" |
|
75 | @field = "project_id" | |
76 | @rows = @project.descendants.visible |
|
76 | @rows = @project.descendants.visible | |
77 | @data = Issue.by_subproject(@project) || [] |
|
77 | @data = Issue.by_subproject(@project) || [] | |
78 | @report_title = l(:field_subproject) |
|
78 | @report_title = l(:field_subproject) | |
79 |
e |
|
79 | else | |
80 |
|
80 | render_404 | ||
81 | respond_to do |format| |
|
|||
82 | if @field |
|
|||
83 | format.html {} |
|
|||
84 | else |
|
|||
85 | format.html { redirect_to :action => 'issue_report', :id => @project } |
|
|||
86 | end |
|
|||
87 | end |
|
81 | end | |
88 | end |
|
82 | end | |
89 |
|
83 | |||
90 | private |
|
84 | private | |
91 |
|
85 | |||
92 | def find_issue_statuses |
|
86 | def find_issue_statuses | |
93 | @statuses = IssueStatus.sorted.to_a |
|
87 | @statuses = IssueStatus.sorted.to_a | |
94 | end |
|
88 | end | |
95 | end |
|
89 | end |
@@ -1,219 +1,219 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class MessagesControllerTest < Redmine::ControllerTest |
|
20 | class MessagesControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles, :boards, :messages, :enabled_modules |
|
21 | fixtures :projects, :users, :email_addresses, :user_preferences, :members, :member_roles, :roles, :boards, :messages, :enabled_modules | |
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | User.current = nil |
|
24 | User.current = nil | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | def test_show |
|
27 | def test_show | |
28 | get :show, :board_id => 1, :id => 1 |
|
28 | get :show, :board_id => 1, :id => 1 | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_template 'show' |
|
30 | ||
31 | assert_not_nil assigns(:board) |
|
31 | assert_select 'h2', :text => 'First post' | |
32 | assert_not_nil assigns(:project) |
|
|||
33 | assert_not_nil assigns(:topic) |
|
|||
34 | end |
|
32 | end | |
35 |
|
33 | |||
36 | def test_show_should_contain_reply_field_tags_for_quoting |
|
34 | def test_show_should_contain_reply_field_tags_for_quoting | |
37 | @request.session[:user_id] = 2 |
|
35 | @request.session[:user_id] = 2 | |
38 | get :show, :board_id => 1, :id => 1 |
|
36 | get :show, :board_id => 1, :id => 1 | |
39 | assert_response :success |
|
37 | assert_response :success | |
40 |
|
38 | |||
41 | # tags required by MessagesController#quote |
|
39 | # tags required by MessagesController#quote | |
42 | assert_select 'input#message_subject' |
|
40 | assert_select 'input#message_subject' | |
43 | assert_select 'textarea#message_content' |
|
41 | assert_select 'textarea#message_content' | |
44 | assert_select 'div#reply' |
|
42 | assert_select 'div#reply' | |
45 | end |
|
43 | end | |
46 |
|
44 | |||
47 | def test_show_with_pagination |
|
45 | def test_show_with_pagination | |
48 | message = Message.find(1) |
|
46 | message = Message.find(1) | |
49 | assert_difference 'Message.count', 30 do |
|
47 | assert_difference 'Message.count', 30 do | |
50 | 30.times do |
|
48 | 30.times do | |
51 | message.children << Message.new(:subject => 'Reply', |
|
49 | message.children << Message.new(:subject => 'Reply', | |
52 | :content => 'Reply body', |
|
50 | :content => 'Reply body', | |
53 | :author_id => 2, |
|
51 | :author_id => 2, | |
54 | :board_id => 1) |
|
52 | :board_id => 1) | |
55 | end |
|
53 | end | |
56 | end |
|
54 | end | |
57 | get :show, :board_id => 1, :id => 1, :r => message.children.order('id').last.id |
|
55 | reply_ids = message.children.map(&:id).sort | |
|
56 | ||||
|
57 | get :show, :board_id => 1, :id => 1, :r => reply_ids.last | |||
58 | assert_response :success |
|
58 | assert_response :success | |
59 | assert_template 'show' |
|
59 | ||
60 | replies = assigns(:replies) |
|
60 | assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.last}#message-#{reply_ids.last}" | |
61 | assert_not_nil replies |
|
61 | assert_select 'a[href=?]', "/boards/1/topics/1?r=#{reply_ids.first}#message-#{reply_ids.first}", 0 | |
62 | assert_not_include message.children.reorder('id').first, replies |
|
|||
63 | assert_include message.children.reorder('id').last, replies |
|
|||
64 | end |
|
62 | end | |
65 |
|
63 | |||
66 | def test_show_with_reply_permission |
|
64 | def test_show_with_reply_permission | |
67 | @request.session[:user_id] = 2 |
|
65 | @request.session[:user_id] = 2 | |
68 | get :show, :board_id => 1, :id => 1 |
|
66 | get :show, :board_id => 1, :id => 1 | |
69 | assert_response :success |
|
67 | assert_response :success | |
70 | assert_template 'show' |
|
68 | ||
71 | assert_select 'div#reply textarea#message_content' |
|
69 | assert_select 'div#reply textarea#message_content' | |
72 | end |
|
70 | end | |
73 |
|
71 | |||
74 | def test_show_message_not_found |
|
72 | def test_show_message_not_found | |
75 | get :show, :board_id => 1, :id => 99999 |
|
73 | get :show, :board_id => 1, :id => 99999 | |
76 | assert_response 404 |
|
74 | assert_response 404 | |
77 | end |
|
75 | end | |
78 |
|
76 | |||
79 | def test_show_message_from_invalid_board_should_respond_with_404 |
|
77 | def test_show_message_from_invalid_board_should_respond_with_404 | |
80 | get :show, :board_id => 999, :id => 1 |
|
78 | get :show, :board_id => 999, :id => 1 | |
81 | assert_response 404 |
|
79 | assert_response 404 | |
82 | end |
|
80 | end | |
83 |
|
81 | |||
84 | def test_get_new |
|
82 | def test_get_new | |
85 | @request.session[:user_id] = 2 |
|
83 | @request.session[:user_id] = 2 | |
86 | get :new, :board_id => 1 |
|
84 | get :new, :board_id => 1 | |
87 | assert_response :success |
|
85 | assert_response :success | |
88 | assert_template 'new' |
|
86 | ||
|
87 | assert_select 'input[name=?]', 'message[subject]' | |||
89 | end |
|
88 | end | |
90 |
|
89 | |||
91 | def test_get_new_with_invalid_board |
|
90 | def test_get_new_with_invalid_board | |
92 | @request.session[:user_id] = 2 |
|
91 | @request.session[:user_id] = 2 | |
93 | get :new, :board_id => 99 |
|
92 | get :new, :board_id => 99 | |
94 | assert_response 404 |
|
93 | assert_response 404 | |
95 | end |
|
94 | end | |
96 |
|
95 | |||
97 | def test_post_new |
|
96 | def test_post_new | |
98 | @request.session[:user_id] = 2 |
|
97 | @request.session[:user_id] = 2 | |
99 | ActionMailer::Base.deliveries.clear |
|
98 | ActionMailer::Base.deliveries.clear | |
100 |
|
99 | |||
101 | with_settings :notified_events => %w(message_posted) do |
|
100 | with_settings :notified_events => %w(message_posted) do | |
102 | post :new, :board_id => 1, |
|
101 | post :new, :board_id => 1, | |
103 | :message => { :subject => 'Test created message', |
|
102 | :message => { :subject => 'Test created message', | |
104 | :content => 'Message body'} |
|
103 | :content => 'Message body'} | |
105 | end |
|
104 | end | |
106 | message = Message.find_by_subject('Test created message') |
|
105 | message = Message.find_by_subject('Test created message') | |
107 | assert_not_nil message |
|
106 | assert_not_nil message | |
108 | assert_redirected_to "/boards/1/topics/#{message.to_param}" |
|
107 | assert_redirected_to "/boards/1/topics/#{message.to_param}" | |
109 | assert_equal 'Message body', message.content |
|
108 | assert_equal 'Message body', message.content | |
110 | assert_equal 2, message.author_id |
|
109 | assert_equal 2, message.author_id | |
111 | assert_equal 1, message.board_id |
|
110 | assert_equal 1, message.board_id | |
112 |
|
111 | |||
113 | mail = ActionMailer::Base.deliveries.last |
|
112 | mail = ActionMailer::Base.deliveries.last | |
114 | assert_not_nil mail |
|
113 | assert_not_nil mail | |
115 | assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject |
|
114 | assert_equal "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] Test created message", mail.subject | |
116 | assert_mail_body_match 'Message body', mail |
|
115 | assert_mail_body_match 'Message body', mail | |
117 | # author |
|
116 | # author | |
118 | assert mail.bcc.include?('jsmith@somenet.foo') |
|
117 | assert mail.bcc.include?('jsmith@somenet.foo') | |
119 | # project member |
|
118 | # project member | |
120 | assert mail.bcc.include?('dlopper@somenet.foo') |
|
119 | assert mail.bcc.include?('dlopper@somenet.foo') | |
121 | end |
|
120 | end | |
122 |
|
121 | |||
123 | def test_get_edit |
|
122 | def test_get_edit | |
124 | @request.session[:user_id] = 2 |
|
123 | @request.session[:user_id] = 2 | |
125 | get :edit, :board_id => 1, :id => 1 |
|
124 | get :edit, :board_id => 1, :id => 1 | |
126 | assert_response :success |
|
125 | assert_response :success | |
127 | assert_template 'edit' |
|
126 | ||
|
127 | assert_select 'input[name=?][value=?]', 'message[subject]', 'First post' | |||
128 | end |
|
128 | end | |
129 |
|
129 | |||
130 | def test_post_edit |
|
130 | def test_post_edit | |
131 | @request.session[:user_id] = 2 |
|
131 | @request.session[:user_id] = 2 | |
132 | post :edit, :board_id => 1, :id => 1, |
|
132 | post :edit, :board_id => 1, :id => 1, | |
133 | :message => { :subject => 'New subject', |
|
133 | :message => { :subject => 'New subject', | |
134 | :content => 'New body'} |
|
134 | :content => 'New body'} | |
135 | assert_redirected_to '/boards/1/topics/1' |
|
135 | assert_redirected_to '/boards/1/topics/1' | |
136 | message = Message.find(1) |
|
136 | message = Message.find(1) | |
137 | assert_equal 'New subject', message.subject |
|
137 | assert_equal 'New subject', message.subject | |
138 | assert_equal 'New body', message.content |
|
138 | assert_equal 'New body', message.content | |
139 | end |
|
139 | end | |
140 |
|
140 | |||
141 | def test_post_edit_sticky_and_locked |
|
141 | def test_post_edit_sticky_and_locked | |
142 | @request.session[:user_id] = 2 |
|
142 | @request.session[:user_id] = 2 | |
143 | post :edit, :board_id => 1, :id => 1, |
|
143 | post :edit, :board_id => 1, :id => 1, | |
144 | :message => { :subject => 'New subject', |
|
144 | :message => { :subject => 'New subject', | |
145 | :content => 'New body', |
|
145 | :content => 'New body', | |
146 | :locked => '1', |
|
146 | :locked => '1', | |
147 | :sticky => '1'} |
|
147 | :sticky => '1'} | |
148 | assert_redirected_to '/boards/1/topics/1' |
|
148 | assert_redirected_to '/boards/1/topics/1' | |
149 | message = Message.find(1) |
|
149 | message = Message.find(1) | |
150 | assert_equal true, message.sticky? |
|
150 | assert_equal true, message.sticky? | |
151 | assert_equal true, message.locked? |
|
151 | assert_equal true, message.locked? | |
152 | end |
|
152 | end | |
153 |
|
153 | |||
154 | def test_post_edit_should_allow_to_change_board |
|
154 | def test_post_edit_should_allow_to_change_board | |
155 | @request.session[:user_id] = 2 |
|
155 | @request.session[:user_id] = 2 | |
156 | post :edit, :board_id => 1, :id => 1, |
|
156 | post :edit, :board_id => 1, :id => 1, | |
157 | :message => { :subject => 'New subject', |
|
157 | :message => { :subject => 'New subject', | |
158 | :content => 'New body', |
|
158 | :content => 'New body', | |
159 | :board_id => 2} |
|
159 | :board_id => 2} | |
160 | assert_redirected_to '/boards/2/topics/1' |
|
160 | assert_redirected_to '/boards/2/topics/1' | |
161 | message = Message.find(1) |
|
161 | message = Message.find(1) | |
162 | assert_equal Board.find(2), message.board |
|
162 | assert_equal Board.find(2), message.board | |
163 | end |
|
163 | end | |
164 |
|
164 | |||
165 | def test_reply |
|
165 | def test_reply | |
166 | @request.session[:user_id] = 2 |
|
166 | @request.session[:user_id] = 2 | |
167 | post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } |
|
167 | post :reply, :board_id => 1, :id => 1, :reply => { :content => 'This is a test reply', :subject => 'Test reply' } | |
168 | reply = Message.order('id DESC').first |
|
168 | reply = Message.order('id DESC').first | |
169 | assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" |
|
169 | assert_redirected_to "/boards/1/topics/1?r=#{reply.id}" | |
170 | assert Message.find_by_subject('Test reply') |
|
170 | assert Message.find_by_subject('Test reply') | |
171 | end |
|
171 | end | |
172 |
|
172 | |||
173 | def test_destroy_topic |
|
173 | def test_destroy_topic | |
174 | @request.session[:user_id] = 2 |
|
174 | @request.session[:user_id] = 2 | |
175 | assert_difference 'Message.count', -3 do |
|
175 | assert_difference 'Message.count', -3 do | |
176 | post :destroy, :board_id => 1, :id => 1 |
|
176 | post :destroy, :board_id => 1, :id => 1 | |
177 | end |
|
177 | end | |
178 | assert_redirected_to '/projects/ecookbook/boards/1' |
|
178 | assert_redirected_to '/projects/ecookbook/boards/1' | |
179 | assert_nil Message.find_by_id(1) |
|
179 | assert_nil Message.find_by_id(1) | |
180 | end |
|
180 | end | |
181 |
|
181 | |||
182 | def test_destroy_reply |
|
182 | def test_destroy_reply | |
183 | @request.session[:user_id] = 2 |
|
183 | @request.session[:user_id] = 2 | |
184 | assert_difference 'Message.count', -1 do |
|
184 | assert_difference 'Message.count', -1 do | |
185 | post :destroy, :board_id => 1, :id => 2 |
|
185 | post :destroy, :board_id => 1, :id => 2 | |
186 | end |
|
186 | end | |
187 | assert_redirected_to '/boards/1/topics/1?r=2' |
|
187 | assert_redirected_to '/boards/1/topics/1?r=2' | |
188 | assert_nil Message.find_by_id(2) |
|
188 | assert_nil Message.find_by_id(2) | |
189 | end |
|
189 | end | |
190 |
|
190 | |||
191 | def test_quote |
|
191 | def test_quote | |
192 | @request.session[:user_id] = 2 |
|
192 | @request.session[:user_id] = 2 | |
193 | xhr :get, :quote, :board_id => 1, :id => 3 |
|
193 | xhr :get, :quote, :board_id => 1, :id => 3 | |
194 | assert_response :success |
|
194 | assert_response :success | |
195 | assert_equal 'text/javascript', response.content_type |
|
195 | assert_equal 'text/javascript', response.content_type | |
196 | assert_template 'quote' |
|
196 | ||
197 | assert_include 'RE: First post', response.body |
|
197 | assert_include 'RE: First post', response.body | |
198 | assert_include '> An other reply', response.body |
|
198 | assert_include '> An other reply', response.body | |
199 | end |
|
199 | end | |
200 |
|
200 | |||
201 | def test_preview_new |
|
201 | def test_preview_new | |
202 | @request.session[:user_id] = 2 |
|
202 | @request.session[:user_id] = 2 | |
203 | post :preview, |
|
203 | post :preview, | |
204 | :board_id => 1, |
|
204 | :board_id => 1, | |
205 | :message => {:subject => "", :content => "Previewed text"} |
|
205 | :message => {:subject => "", :content => "Previewed text"} | |
206 | assert_response :success |
|
206 | assert_response :success | |
207 | assert_template 'common/_preview' |
|
207 | assert_include 'Previewed text', response.body | |
208 | end |
|
208 | end | |
209 |
|
209 | |||
210 | def test_preview_edit |
|
210 | def test_preview_edit | |
211 | @request.session[:user_id] = 2 |
|
211 | @request.session[:user_id] = 2 | |
212 | post :preview, |
|
212 | post :preview, | |
213 | :id => 4, |
|
213 | :id => 4, | |
214 | :board_id => 1, |
|
214 | :board_id => 1, | |
215 | :message => {:subject => "", :content => "Previewed text"} |
|
215 | :message => {:subject => "", :content => "Previewed text"} | |
216 | assert_response :success |
|
216 | assert_response :success | |
217 | assert_template 'common/_preview' |
|
217 | assert_include 'Previewed text', response.body | |
218 | end |
|
218 | end | |
219 | end |
|
219 | end |
@@ -1,299 +1,295 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class MyControllerTest < Redmine::ControllerTest |
|
20 | class MyControllerTest < Redmine::ControllerTest | |
21 | fixtures :users, :email_addresses, :user_preferences, :roles, :projects, :members, :member_roles, |
|
21 | fixtures :users, :email_addresses, :user_preferences, :roles, :projects, :members, :member_roles, | |
22 | :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources |
|
22 | :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources | |
23 |
|
23 | |||
24 | def setup |
|
24 | def setup | |
25 | @request.session[:user_id] = 2 |
|
25 | @request.session[:user_id] = 2 | |
26 | end |
|
26 | end | |
27 |
|
27 | |||
28 | def test_index |
|
28 | def test_index | |
29 | get :index |
|
29 | get :index | |
30 | assert_response :success |
|
30 | assert_response :success | |
31 |
assert_ |
|
31 | assert_select 'h2', 'My page' | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_page |
|
34 | def test_page | |
35 | get :page |
|
35 | get :page | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 |
assert_ |
|
37 | assert_select 'h2', 'My page' | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | def test_page_with_timelog_block |
|
40 | def test_page_with_timelog_block | |
41 | preferences = User.find(2).pref |
|
41 | preferences = User.find(2).pref | |
42 | preferences[:my_page_layout] = {'top' => ['timelog']} |
|
42 | preferences[:my_page_layout] = {'top' => ['timelog']} | |
43 | preferences.save! |
|
43 | preferences.save! | |
44 | TimeEntry.create!(:user => User.find(2), :spent_on => Date.yesterday, :issue_id => 1, :hours => 2.5, :activity_id => 10) |
|
44 | TimeEntry.create!(:user => User.find(2), :spent_on => Date.yesterday, :issue_id => 1, :hours => 2.5, :activity_id => 10) | |
45 |
|
45 | |||
46 | get :page |
|
46 | get :page | |
47 | assert_response :success |
|
47 | assert_response :success | |
48 | assert_select 'tr.time-entry' do |
|
48 | assert_select 'tr.time-entry' do | |
49 | assert_select 'td.subject a[href="/issues/1"]' |
|
49 | assert_select 'td.subject a[href="/issues/1"]' | |
50 | assert_select 'td.hours', :text => '2.50' |
|
50 | assert_select 'td.hours', :text => '2.50' | |
51 | end |
|
51 | end | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | def test_page_with_all_blocks |
|
54 | def test_page_with_all_blocks | |
55 | blocks = MyController::BLOCKS.keys |
|
55 | blocks = MyController::BLOCKS.keys | |
56 | preferences = User.find(2).pref |
|
56 | preferences = User.find(2).pref | |
57 | preferences[:my_page_layout] = {'top' => blocks} |
|
57 | preferences[:my_page_layout] = {'top' => blocks} | |
58 | preferences.save! |
|
58 | preferences.save! | |
59 |
|
59 | |||
60 | get :page |
|
60 | get :page | |
61 | assert_response :success |
|
61 | assert_response :success | |
62 | assert_select 'div.mypage-box', blocks.size |
|
62 | assert_select 'div.mypage-box', blocks.size | |
63 | end |
|
63 | end | |
64 |
|
64 | |||
65 | def test_my_account_should_show_editable_custom_fields |
|
65 | def test_my_account_should_show_editable_custom_fields | |
66 | get :account |
|
66 | get :account | |
67 | assert_response :success |
|
67 | assert_response :success | |
68 | assert_template 'account' |
|
|||
69 | assert_equal User.find(2), assigns(:user) |
|
|||
70 |
|
||||
71 | assert_select 'input[name=?]', 'user[custom_field_values][4]' |
|
68 | assert_select 'input[name=?]', 'user[custom_field_values][4]' | |
72 | end |
|
69 | end | |
73 |
|
70 | |||
74 | def test_my_account_should_not_show_non_editable_custom_fields |
|
71 | def test_my_account_should_not_show_non_editable_custom_fields | |
75 | UserCustomField.find(4).update_attribute :editable, false |
|
72 | UserCustomField.find(4).update_attribute :editable, false | |
76 |
|
73 | |||
77 | get :account |
|
74 | get :account | |
78 | assert_response :success |
|
75 | assert_response :success | |
79 | assert_template 'account' |
|
|||
80 | assert_equal User.find(2), assigns(:user) |
|
|||
81 |
|
||||
82 | assert_select 'input[name=?]', 'user[custom_field_values][4]', 0 |
|
76 | assert_select 'input[name=?]', 'user[custom_field_values][4]', 0 | |
83 | end |
|
77 | end | |
84 |
|
78 | |||
85 | def test_my_account_should_show_language_select |
|
79 | def test_my_account_should_show_language_select | |
86 | get :account |
|
80 | get :account | |
87 | assert_response :success |
|
81 | assert_response :success | |
88 | assert_select 'select[name=?]', 'user[language]' |
|
82 | assert_select 'select[name=?]', 'user[language]' | |
89 | end |
|
83 | end | |
90 |
|
84 | |||
91 | def test_my_account_should_not_show_language_select_with_force_default_language_for_loggedin |
|
85 | def test_my_account_should_not_show_language_select_with_force_default_language_for_loggedin | |
92 | with_settings :force_default_language_for_loggedin => '1' do |
|
86 | with_settings :force_default_language_for_loggedin => '1' do | |
93 | get :account |
|
87 | get :account | |
94 | assert_response :success |
|
88 | assert_response :success | |
95 | assert_select 'select[name=?]', 'user[language]', 0 |
|
89 | assert_select 'select[name=?]', 'user[language]', 0 | |
96 | end |
|
90 | end | |
97 | end |
|
91 | end | |
98 |
|
92 | |||
99 | def test_update_account |
|
93 | def test_update_account | |
100 | post :account, |
|
94 | post :account, | |
101 | :user => { |
|
95 | :user => { | |
102 | :firstname => "Joe", |
|
96 | :firstname => "Joe", | |
103 | :login => "root", |
|
97 | :login => "root", | |
104 | :admin => 1, |
|
98 | :admin => 1, | |
105 | :group_ids => ['10'], |
|
99 | :group_ids => ['10'], | |
106 | :custom_field_values => {"4" => "0100562500"} |
|
100 | :custom_field_values => {"4" => "0100562500"} | |
107 | } |
|
101 | } | |
108 |
|
102 | |||
109 | assert_redirected_to '/my/account' |
|
103 | assert_redirected_to '/my/account' | |
110 | user = User.find(2) |
|
104 | user = User.find(2) | |
111 | assert_equal user, assigns(:user) |
|
|||
112 | assert_equal "Joe", user.firstname |
|
105 | assert_equal "Joe", user.firstname | |
113 | assert_equal "jsmith", user.login |
|
106 | assert_equal "jsmith", user.login | |
114 | assert_equal "0100562500", user.custom_value_for(4).value |
|
107 | assert_equal "0100562500", user.custom_value_for(4).value | |
115 | # ignored |
|
108 | # ignored | |
116 | assert !user.admin? |
|
109 | assert !user.admin? | |
117 | assert user.groups.empty? |
|
110 | assert user.groups.empty? | |
118 | end |
|
111 | end | |
119 |
|
112 | |||
120 | def test_update_account_should_send_security_notification |
|
113 | def test_update_account_should_send_security_notification | |
121 | ActionMailer::Base.deliveries.clear |
|
114 | ActionMailer::Base.deliveries.clear | |
122 | post :account, |
|
115 | post :account, | |
123 | :user => { |
|
116 | :user => { | |
124 | :mail => 'foobar@example.com' |
|
117 | :mail => 'foobar@example.com' | |
125 | } |
|
118 | } | |
126 |
|
119 | |||
127 | assert_not_nil (mail = ActionMailer::Base.deliveries.last) |
|
120 | assert_not_nil (mail = ActionMailer::Base.deliveries.last) | |
128 | assert_mail_body_match '0.0.0.0', mail |
|
121 | assert_mail_body_match '0.0.0.0', mail | |
129 | assert_mail_body_match I18n.t(:mail_body_security_notification_change_to, field: I18n.t(:field_mail), value: 'foobar@example.com'), mail |
|
122 | assert_mail_body_match I18n.t(:mail_body_security_notification_change_to, field: I18n.t(:field_mail), value: 'foobar@example.com'), mail | |
130 | assert_select_email do |
|
123 | assert_select_email do | |
131 | assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account' |
|
124 | assert_select 'a[href^=?]', 'http://localhost:3000/my/account', :text => 'My account' | |
132 | end |
|
125 | end | |
133 | # The old email address should be notified about the change for security purposes |
|
126 | # The old email address should be notified about the change for security purposes | |
134 | assert [mail.bcc, mail.cc].flatten.include?(User.find(2).mail) |
|
127 | assert [mail.bcc, mail.cc].flatten.include?(User.find(2).mail) | |
135 | assert [mail.bcc, mail.cc].flatten.include?('foobar@example.com') |
|
128 | assert [mail.bcc, mail.cc].flatten.include?('foobar@example.com') | |
136 | end |
|
129 | end | |
137 |
|
130 | |||
138 | def test_my_account_should_show_destroy_link |
|
131 | def test_my_account_should_show_destroy_link | |
139 | get :account |
|
132 | get :account | |
140 | assert_select 'a[href="/my/account/destroy"]' |
|
133 | assert_select 'a[href="/my/account/destroy"]' | |
141 | end |
|
134 | end | |
142 |
|
135 | |||
143 | def test_get_destroy_should_display_the_destroy_confirmation |
|
136 | def test_get_destroy_should_display_the_destroy_confirmation | |
144 | get :destroy |
|
137 | get :destroy | |
145 | assert_response :success |
|
138 | assert_response :success | |
146 | assert_template 'destroy' |
|
|||
147 | assert_select 'form[action="/my/account/destroy"]' do |
|
139 | assert_select 'form[action="/my/account/destroy"]' do | |
148 | assert_select 'input[name=confirm]' |
|
140 | assert_select 'input[name=confirm]' | |
149 | end |
|
141 | end | |
150 | end |
|
142 | end | |
151 |
|
143 | |||
152 | def test_post_destroy_without_confirmation_should_not_destroy_account |
|
144 | def test_post_destroy_without_confirmation_should_not_destroy_account | |
153 | assert_no_difference 'User.count' do |
|
145 | assert_no_difference 'User.count' do | |
154 | post :destroy |
|
146 | post :destroy | |
155 | end |
|
147 | end | |
156 | assert_response :success |
|
148 | assert_response :success | |
157 | assert_template 'destroy' |
|
|||
158 | end |
|
149 | end | |
159 |
|
150 | |||
160 | def test_post_destroy_without_confirmation_should_destroy_account |
|
151 | def test_post_destroy_without_confirmation_should_destroy_account | |
161 | assert_difference 'User.count', -1 do |
|
152 | assert_difference 'User.count', -1 do | |
162 | post :destroy, :confirm => '1' |
|
153 | post :destroy, :confirm => '1' | |
163 | end |
|
154 | end | |
164 | assert_redirected_to '/' |
|
155 | assert_redirected_to '/' | |
165 | assert_match /deleted/i, flash[:notice] |
|
156 | assert_match /deleted/i, flash[:notice] | |
166 | end |
|
157 | end | |
167 |
|
158 | |||
168 | def test_post_destroy_with_unsubscribe_not_allowed_should_not_destroy_account |
|
159 | def test_post_destroy_with_unsubscribe_not_allowed_should_not_destroy_account | |
169 | User.any_instance.stubs(:own_account_deletable?).returns(false) |
|
160 | User.any_instance.stubs(:own_account_deletable?).returns(false) | |
170 |
|
161 | |||
171 | assert_no_difference 'User.count' do |
|
162 | assert_no_difference 'User.count' do | |
172 | post :destroy, :confirm => '1' |
|
163 | post :destroy, :confirm => '1' | |
173 | end |
|
164 | end | |
174 | assert_redirected_to '/my/account' |
|
165 | assert_redirected_to '/my/account' | |
175 | end |
|
166 | end | |
176 |
|
167 | |||
177 | def test_change_password |
|
168 | def test_change_password | |
178 | get :password |
|
169 | get :password | |
179 | assert_response :success |
|
170 | assert_response :success | |
180 | assert_template 'password' |
|
171 | assert_select 'input[type=password][name=password]' | |
|
172 | assert_select 'input[type=password][name=new_password]' | |||
|
173 | assert_select 'input[type=password][name=new_password_confirmation]' | |||
|
174 | end | |||
181 |
|
175 | |||
182 | # non matching password confirmation |
|
176 | def test_update_password | |
|
177 | post :password, :password => 'jsmith', | |||
|
178 | :new_password => 'secret123', | |||
|
179 | :new_password_confirmation => 'secret123' | |||
|
180 | assert_redirected_to '/my/account' | |||
|
181 | assert User.try_to_login('jsmith', 'secret123') | |||
|
182 | end | |||
|
183 | ||||
|
184 | def test_update_password_with_non_matching_confirmation | |||
183 | post :password, :password => 'jsmith', |
|
185 | post :password, :password => 'jsmith', | |
184 | :new_password => 'secret123', |
|
186 | :new_password => 'secret123', | |
185 | :new_password_confirmation => 'secret1234' |
|
187 | :new_password_confirmation => 'secret1234' | |
186 | assert_response :success |
|
188 | assert_response :success | |
187 | assert_template 'password' |
|
|||
188 | assert_select_error /Password doesn.*t match confirmation/ |
|
189 | assert_select_error /Password doesn.*t match confirmation/ | |
|
190 | assert User.try_to_login('jsmith', 'jsmith') | |||
|
191 | end | |||
189 |
|
192 | |||
|
193 | def test_update_password_with_wrong_password | |||
190 | # wrong password |
|
194 | # wrong password | |
191 | post :password, :password => 'wrongpassword', |
|
195 | post :password, :password => 'wrongpassword', | |
192 | :new_password => 'secret123', |
|
196 | :new_password => 'secret123', | |
193 | :new_password_confirmation => 'secret123' |
|
197 | :new_password_confirmation => 'secret123' | |
194 | assert_response :success |
|
198 | assert_response :success | |
195 | assert_template 'password' |
|
|||
196 | assert_equal 'Wrong password', flash[:error] |
|
199 | assert_equal 'Wrong password', flash[:error] | |
197 |
|
200 | assert User.try_to_login('jsmith', 'jsmith') | ||
198 | # good password |
|
|||
199 | post :password, :password => 'jsmith', |
|
|||
200 | :new_password => 'secret123', |
|
|||
201 | :new_password_confirmation => 'secret123' |
|
|||
202 | assert_redirected_to '/my/account' |
|
|||
203 | assert User.try_to_login('jsmith', 'secret123') |
|
|||
204 | end |
|
201 | end | |
205 |
|
202 | |||
206 | def test_change_password_should_redirect_if_user_cannot_change_its_password |
|
203 | def test_change_password_should_redirect_if_user_cannot_change_its_password | |
207 | User.find(2).update_attribute(:auth_source_id, 1) |
|
204 | User.find(2).update_attribute(:auth_source_id, 1) | |
208 |
|
205 | |||
209 | get :password |
|
206 | get :password | |
210 | assert_not_nil flash[:error] |
|
207 | assert_not_nil flash[:error] | |
211 | assert_redirected_to '/my/account' |
|
208 | assert_redirected_to '/my/account' | |
212 | end |
|
209 | end | |
213 |
|
210 | |||
214 |
def test_ |
|
211 | def test_update_password_should_send_security_notification | |
215 | ActionMailer::Base.deliveries.clear |
|
212 | ActionMailer::Base.deliveries.clear | |
216 | post :password, :password => 'jsmith', |
|
213 | post :password, :password => 'jsmith', | |
217 | :new_password => 'secret123', |
|
214 | :new_password => 'secret123', | |
218 | :new_password_confirmation => 'secret123' |
|
215 | :new_password_confirmation => 'secret123' | |
219 |
|
216 | |||
220 | assert_not_nil (mail = ActionMailer::Base.deliveries.last) |
|
217 | assert_not_nil (mail = ActionMailer::Base.deliveries.last) | |
221 | assert_mail_body_no_match 'secret123', mail # just to be sure: pw should never be sent! |
|
218 | assert_mail_body_no_match 'secret123', mail # just to be sure: pw should never be sent! | |
222 | assert_select_email do |
|
219 | assert_select_email do | |
223 | assert_select 'a[href^=?]', 'http://localhost:3000/my/password', :text => 'Change password' |
|
220 | assert_select 'a[href^=?]', 'http://localhost:3000/my/password', :text => 'Change password' | |
224 | end |
|
221 | end | |
225 | end |
|
222 | end | |
226 |
|
223 | |||
227 | def test_page_layout |
|
224 | def test_page_layout | |
228 | get :page_layout |
|
225 | get :page_layout | |
229 | assert_response :success |
|
226 | assert_response :success | |
230 | assert_template 'page_layout' |
|
|||
231 | end |
|
227 | end | |
232 |
|
228 | |||
233 | def test_add_block |
|
229 | def test_add_block | |
234 | post :add_block, :block => 'issuesreportedbyme' |
|
230 | post :add_block, :block => 'issuesreportedbyme' | |
235 | assert_redirected_to '/my/page_layout' |
|
231 | assert_redirected_to '/my/page_layout' | |
236 | assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme') |
|
232 | assert User.find(2).pref[:my_page_layout]['top'].include?('issuesreportedbyme') | |
237 | end |
|
233 | end | |
238 |
|
234 | |||
239 | def test_add_invalid_block_should_redirect |
|
235 | def test_add_invalid_block_should_redirect | |
240 | post :add_block, :block => 'invalid' |
|
236 | post :add_block, :block => 'invalid' | |
241 | assert_redirected_to '/my/page_layout' |
|
237 | assert_redirected_to '/my/page_layout' | |
242 | end |
|
238 | end | |
243 |
|
239 | |||
244 | def test_remove_block |
|
240 | def test_remove_block | |
245 | post :remove_block, :block => 'issuesassignedtome' |
|
241 | post :remove_block, :block => 'issuesassignedtome' | |
246 | assert_redirected_to '/my/page_layout' |
|
242 | assert_redirected_to '/my/page_layout' | |
247 | assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome') |
|
243 | assert !User.find(2).pref[:my_page_layout].values.flatten.include?('issuesassignedtome') | |
248 | end |
|
244 | end | |
249 |
|
245 | |||
250 | def test_order_blocks |
|
246 | def test_order_blocks | |
251 | xhr :post, :order_blocks, :group => 'left', 'blocks' => ['documents', 'calendar', 'latestnews'] |
|
247 | xhr :post, :order_blocks, :group => 'left', 'blocks' => ['documents', 'calendar', 'latestnews'] | |
252 | assert_response :success |
|
248 | assert_response :success | |
253 | assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left'] |
|
249 | assert_equal ['documents', 'calendar', 'latestnews'], User.find(2).pref[:my_page_layout]['left'] | |
254 | end |
|
250 | end | |
255 |
|
251 | |||
256 | def test_reset_rss_key_with_existing_key |
|
252 | def test_reset_rss_key_with_existing_key | |
257 | @previous_token_value = User.find(2).rss_key # Will generate one if it's missing |
|
253 | @previous_token_value = User.find(2).rss_key # Will generate one if it's missing | |
258 | post :reset_rss_key |
|
254 | post :reset_rss_key | |
259 |
|
255 | |||
260 | assert_not_equal @previous_token_value, User.find(2).rss_key |
|
256 | assert_not_equal @previous_token_value, User.find(2).rss_key | |
261 | assert User.find(2).rss_token |
|
257 | assert User.find(2).rss_token | |
262 | assert_match /reset/, flash[:notice] |
|
258 | assert_match /reset/, flash[:notice] | |
263 | assert_redirected_to '/my/account' |
|
259 | assert_redirected_to '/my/account' | |
264 | end |
|
260 | end | |
265 |
|
261 | |||
266 | def test_reset_rss_key_without_existing_key |
|
262 | def test_reset_rss_key_without_existing_key | |
267 | assert_nil User.find(2).rss_token |
|
263 | assert_nil User.find(2).rss_token | |
268 | post :reset_rss_key |
|
264 | post :reset_rss_key | |
269 |
|
265 | |||
270 | assert User.find(2).rss_token |
|
266 | assert User.find(2).rss_token | |
271 | assert_match /reset/, flash[:notice] |
|
267 | assert_match /reset/, flash[:notice] | |
272 | assert_redirected_to '/my/account' |
|
268 | assert_redirected_to '/my/account' | |
273 | end |
|
269 | end | |
274 |
|
270 | |||
275 | def test_show_api_key |
|
271 | def test_show_api_key | |
276 | get :show_api_key |
|
272 | get :show_api_key | |
277 | assert_response :success |
|
273 | assert_response :success | |
278 | assert_select 'pre', User.find(2).api_key |
|
274 | assert_select 'pre', User.find(2).api_key | |
279 | end |
|
275 | end | |
280 |
|
276 | |||
281 | def test_reset_api_key_with_existing_key |
|
277 | def test_reset_api_key_with_existing_key | |
282 | @previous_token_value = User.find(2).api_key # Will generate one if it's missing |
|
278 | @previous_token_value = User.find(2).api_key # Will generate one if it's missing | |
283 | post :reset_api_key |
|
279 | post :reset_api_key | |
284 |
|
280 | |||
285 | assert_not_equal @previous_token_value, User.find(2).api_key |
|
281 | assert_not_equal @previous_token_value, User.find(2).api_key | |
286 | assert User.find(2).api_token |
|
282 | assert User.find(2).api_token | |
287 | assert_match /reset/, flash[:notice] |
|
283 | assert_match /reset/, flash[:notice] | |
288 | assert_redirected_to '/my/account' |
|
284 | assert_redirected_to '/my/account' | |
289 | end |
|
285 | end | |
290 |
|
286 | |||
291 | def test_reset_api_key_without_existing_key |
|
287 | def test_reset_api_key_without_existing_key | |
292 | assert_nil User.find(2).api_token |
|
288 | assert_nil User.find(2).api_token | |
293 | post :reset_api_key |
|
289 | post :reset_api_key | |
294 |
|
290 | |||
295 | assert User.find(2).api_token |
|
291 | assert User.find(2).api_token | |
296 | assert_match /reset/, flash[:notice] |
|
292 | assert_match /reset/, flash[:notice] | |
297 | assert_redirected_to '/my/account' |
|
293 | assert_redirected_to '/my/account' | |
298 | end |
|
294 | end | |
299 | end |
|
295 | end |
@@ -1,178 +1,172 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class NewsControllerTest < Redmine::ControllerTest |
|
20 | class NewsControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, |
|
21 | fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles, | |
22 | :enabled_modules, :news, :comments, |
|
22 | :enabled_modules, :news, :comments, | |
23 | :attachments |
|
23 | :attachments | |
24 |
|
24 | |||
25 | def setup |
|
25 | def setup | |
26 | User.current = nil |
|
26 | User.current = nil | |
27 | end |
|
27 | end | |
28 |
|
28 | |||
29 | def test_index |
|
29 | def test_index | |
30 | get :index |
|
30 | get :index | |
31 | assert_response :success |
|
31 | assert_response :success | |
32 | assert_template 'index' |
|
32 | assert_select 'h3 a', :text => 'eCookbook first release !' | |
33 | assert_not_nil assigns(:newss) |
|
|||
34 | assert_nil assigns(:project) |
|
|||
35 | end |
|
33 | end | |
36 |
|
34 | |||
37 | def test_index_with_project |
|
35 | def test_index_with_project | |
38 | get :index, :project_id => 1 |
|
36 | get :index, :project_id => 1 | |
39 | assert_response :success |
|
37 | assert_response :success | |
40 | assert_template 'index' |
|
38 | assert_select 'h3 a', :text => 'eCookbook first release !' | |
41 | assert_not_nil assigns(:newss) |
|
|||
42 | end |
|
39 | end | |
43 |
|
40 | |||
44 | def test_index_with_invalid_project_should_respond_with_404 |
|
41 | def test_index_with_invalid_project_should_respond_with_404 | |
45 | get :index, :project_id => 999 |
|
42 | get :index, :project_id => 999 | |
46 | assert_response 404 |
|
43 | assert_response 404 | |
47 | end |
|
44 | end | |
48 |
|
45 | |||
49 | def test_show |
|
46 | def test_show | |
50 | get :show, :id => 1 |
|
47 | get :show, :id => 1 | |
51 | assert_response :success |
|
48 | assert_response :success | |
52 | assert_template 'show' |
|
49 | assert_select 'h2', :text => 'eCookbook first release !' | |
53 | assert_select 'h2', :text => /eCookbook first release/ |
|
|||
54 | end |
|
50 | end | |
55 |
|
51 | |||
56 | def test_show_should_show_attachments |
|
52 | def test_show_should_show_attachments | |
57 | attachment = Attachment.first |
|
53 | attachment = Attachment.first | |
58 | attachment.container = News.find(1) |
|
54 | attachment.container = News.find(1) | |
59 | attachment.save! |
|
55 | attachment.save! | |
60 |
|
56 | |||
61 | get :show, :id => 1 |
|
57 | get :show, :id => 1 | |
62 | assert_response :success |
|
58 | assert_response :success | |
63 | assert_select 'a', :text => attachment.filename |
|
59 | assert_select 'a', :text => attachment.filename | |
64 | end |
|
60 | end | |
65 |
|
61 | |||
66 | def test_show_with_comments_in_reverse_order |
|
62 | def test_show_with_comments_in_reverse_order | |
67 | user = User.find(1) |
|
63 | user = User.find(1) | |
68 | user.pref[:comments_sorting] = 'desc' |
|
64 | user.pref[:comments_sorting] = 'desc' | |
69 | user.pref.save! |
|
65 | user.pref.save! | |
70 |
|
66 | |||
71 | @request.session[:user_id] = 1 |
|
67 | @request.session[:user_id] = 1 | |
72 | get :show, :id => 1 |
|
68 | get :show, :id => 1 | |
73 | assert_response :success |
|
69 | assert_response :success | |
74 | assert_equal News.find(1).comments.to_a.sort_by(&:created_on).reverse, assigns(:comments) |
|
70 | ||
|
71 | comments = css_select('#comments .wiki').map(&:text).map(&:strip) | |||
|
72 | assert_equal ["This is an other comment", "my first comment"], comments | |||
75 | end |
|
73 | end | |
76 |
|
74 | |||
77 | def test_show_not_found |
|
75 | def test_show_not_found | |
78 | get :show, :id => 999 |
|
76 | get :show, :id => 999 | |
79 | assert_response 404 |
|
77 | assert_response 404 | |
80 | end |
|
78 | end | |
81 |
|
79 | |||
82 | def test_get_new |
|
80 | def test_get_new | |
83 | @request.session[:user_id] = 2 |
|
81 | @request.session[:user_id] = 2 | |
84 | get :new, :project_id => 1 |
|
82 | get :new, :project_id => 1 | |
85 | assert_response :success |
|
83 | assert_response :success | |
86 | assert_template 'new' |
|
84 | assert_select 'input[name=?]', 'news[title]' | |
87 | end |
|
85 | end | |
88 |
|
86 | |||
89 | def test_post_create |
|
87 | def test_post_create | |
90 | ActionMailer::Base.deliveries.clear |
|
88 | ActionMailer::Base.deliveries.clear | |
91 | @request.session[:user_id] = 2 |
|
89 | @request.session[:user_id] = 2 | |
92 |
|
90 | |||
93 | with_settings :notified_events => %w(news_added) do |
|
91 | with_settings :notified_events => %w(news_added) do | |
94 | post :create, :project_id => 1, :news => { :title => 'NewsControllerTest', |
|
92 | post :create, :project_id => 1, :news => { :title => 'NewsControllerTest', | |
95 | :description => 'This is the description', |
|
93 | :description => 'This is the description', | |
96 | :summary => '' } |
|
94 | :summary => '' } | |
97 | end |
|
95 | end | |
98 | assert_redirected_to '/projects/ecookbook/news' |
|
96 | assert_redirected_to '/projects/ecookbook/news' | |
99 |
|
97 | |||
100 | news = News.find_by_title('NewsControllerTest') |
|
98 | news = News.find_by_title('NewsControllerTest') | |
101 | assert_not_nil news |
|
99 | assert_not_nil news | |
102 | assert_equal 'This is the description', news.description |
|
100 | assert_equal 'This is the description', news.description | |
103 | assert_equal User.find(2), news.author |
|
101 | assert_equal User.find(2), news.author | |
104 | assert_equal Project.find(1), news.project |
|
102 | assert_equal Project.find(1), news.project | |
105 | assert_equal 1, ActionMailer::Base.deliveries.size |
|
103 | assert_equal 1, ActionMailer::Base.deliveries.size | |
106 | end |
|
104 | end | |
107 |
|
105 | |||
108 | def test_post_create_with_attachment |
|
106 | def test_post_create_with_attachment | |
109 | set_tmp_attachments_directory |
|
107 | set_tmp_attachments_directory | |
110 | @request.session[:user_id] = 2 |
|
108 | @request.session[:user_id] = 2 | |
111 | assert_difference 'News.count' do |
|
109 | assert_difference 'News.count' do | |
112 | assert_difference 'Attachment.count' do |
|
110 | assert_difference 'Attachment.count' do | |
113 | post :create, :project_id => 1, |
|
111 | post :create, :project_id => 1, | |
114 | :news => { :title => 'Test', :description => 'This is the description' }, |
|
112 | :news => { :title => 'Test', :description => 'This is the description' }, | |
115 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
113 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
116 | end |
|
114 | end | |
117 | end |
|
115 | end | |
118 | attachment = Attachment.order('id DESC').first |
|
116 | attachment = Attachment.order('id DESC').first | |
119 | news = News.order('id DESC').first |
|
117 | news = News.order('id DESC').first | |
120 | assert_equal news, attachment.container |
|
118 | assert_equal news, attachment.container | |
121 | end |
|
119 | end | |
122 |
|
120 | |||
123 | def test_post_create_with_validation_failure |
|
121 | def test_post_create_with_validation_failure | |
124 | @request.session[:user_id] = 2 |
|
122 | @request.session[:user_id] = 2 | |
125 | post :create, :project_id => 1, :news => { :title => '', |
|
123 | post :create, :project_id => 1, :news => { :title => '', | |
126 | :description => 'This is the description', |
|
124 | :description => 'This is the description', | |
127 | :summary => '' } |
|
125 | :summary => '' } | |
128 | assert_response :success |
|
126 | assert_response :success | |
129 | assert_template 'new' |
|
|||
130 | assert_not_nil assigns(:news) |
|
|||
131 | assert assigns(:news).new_record? |
|
|||
132 | assert_select_error /title cannot be blank/i |
|
127 | assert_select_error /title cannot be blank/i | |
133 | end |
|
128 | end | |
134 |
|
129 | |||
135 | def test_get_edit |
|
130 | def test_get_edit | |
136 | @request.session[:user_id] = 2 |
|
131 | @request.session[:user_id] = 2 | |
137 | get :edit, :id => 1 |
|
132 | get :edit, :id => 1 | |
138 | assert_response :success |
|
133 | assert_response :success | |
139 | assert_template 'edit' |
|
134 | assert_select 'input[name=?][value=?]', 'news[title]', 'eCookbook first release !' | |
140 | end |
|
135 | end | |
141 |
|
136 | |||
142 | def test_put_update |
|
137 | def test_put_update | |
143 | @request.session[:user_id] = 2 |
|
138 | @request.session[:user_id] = 2 | |
144 | put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } |
|
139 | put :update, :id => 1, :news => { :description => 'Description changed by test_post_edit' } | |
145 | assert_redirected_to '/news/1' |
|
140 | assert_redirected_to '/news/1' | |
146 | news = News.find(1) |
|
141 | news = News.find(1) | |
147 | assert_equal 'Description changed by test_post_edit', news.description |
|
142 | assert_equal 'Description changed by test_post_edit', news.description | |
148 | end |
|
143 | end | |
149 |
|
144 | |||
150 | def test_put_update_with_attachment |
|
145 | def test_put_update_with_attachment | |
151 | set_tmp_attachments_directory |
|
146 | set_tmp_attachments_directory | |
152 | @request.session[:user_id] = 2 |
|
147 | @request.session[:user_id] = 2 | |
153 | assert_no_difference 'News.count' do |
|
148 | assert_no_difference 'News.count' do | |
154 | assert_difference 'Attachment.count' do |
|
149 | assert_difference 'Attachment.count' do | |
155 | put :update, :id => 1, |
|
150 | put :update, :id => 1, | |
156 | :news => { :description => 'This is the description' }, |
|
151 | :news => { :description => 'This is the description' }, | |
157 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} |
|
152 | :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain')}} | |
158 | end |
|
153 | end | |
159 | end |
|
154 | end | |
160 | attachment = Attachment.order('id DESC').first |
|
155 | attachment = Attachment.order('id DESC').first | |
161 | assert_equal News.find(1), attachment.container |
|
156 | assert_equal News.find(1), attachment.container | |
162 | end |
|
157 | end | |
163 |
|
158 | |||
164 | def test_update_with_failure |
|
159 | def test_update_with_failure | |
165 | @request.session[:user_id] = 2 |
|
160 | @request.session[:user_id] = 2 | |
166 | put :update, :id => 1, :news => { :description => '' } |
|
161 | put :update, :id => 1, :news => { :description => '' } | |
167 | assert_response :success |
|
162 | assert_response :success | |
168 | assert_template 'edit' |
|
|||
169 | assert_select_error /description cannot be blank/i |
|
163 | assert_select_error /description cannot be blank/i | |
170 | end |
|
164 | end | |
171 |
|
165 | |||
172 | def test_destroy |
|
166 | def test_destroy | |
173 | @request.session[:user_id] = 2 |
|
167 | @request.session[:user_id] = 2 | |
174 | delete :destroy, :id => 1 |
|
168 | delete :destroy, :id => 1 | |
175 | assert_redirected_to '/projects/ecookbook/news' |
|
169 | assert_redirected_to '/projects/ecookbook/news' | |
176 | assert_nil News.find_by_id(1) |
|
170 | assert_nil News.find_by_id(1) | |
177 | end |
|
171 | end | |
178 | end |
|
172 | end |
@@ -1,95 +1,99 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class PreviewsControllerTest < Redmine::ControllerTest |
|
20 | class PreviewsControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
21 | fixtures :projects, :trackers, :issue_statuses, :issues, | |
22 | :enumerations, :users, :issue_categories, |
|
22 | :enumerations, :users, :issue_categories, | |
23 | :projects_trackers, |
|
23 | :projects_trackers, | |
24 | :roles, |
|
24 | :roles, | |
25 | :member_roles, |
|
25 | :member_roles, | |
26 | :members, |
|
26 | :members, | |
27 | :enabled_modules, |
|
27 | :enabled_modules, | |
28 | :journals, :journal_details, |
|
28 | :journals, :journal_details, | |
29 | :news |
|
29 | :news | |
30 |
|
30 | |||
31 | def test_preview_new_issue |
|
31 | def test_preview_new_issue | |
32 | @request.session[:user_id] = 2 |
|
32 | @request.session[:user_id] = 2 | |
33 | post :issue, :project_id => '1', :issue => {:description => 'Foo'} |
|
33 | post :issue, :project_id => '1', :issue => {:description => 'Foo'} | |
34 | assert_response :success |
|
34 | assert_response :success | |
35 | assert_template 'previews/issue' |
|
35 | assert_select 'fieldset' do | |
36 | assert_not_nil assigns(:description) |
|
36 | assert_select 'legend', :text => 'Description' | |
|
37 | assert_select 'p', :text => 'Foo' | |||
|
38 | end | |||
37 | end |
|
39 | end | |
38 |
|
40 | |||
39 | def test_preview_issue_notes |
|
41 | def test_preview_issue_notes_with_no_change_to_description | |
40 | @request.session[:user_id] = 2 |
|
42 | @request.session[:user_id] = 2 | |
41 | post :issue, :project_id => '1', :id => 1, |
|
43 | post :issue, :project_id => '1', :id => 1, | |
42 | :issue => {:description => Issue.find(1).description, :notes => 'Foo'} |
|
44 | :issue => {:description => Issue.find(1).description, :notes => 'Foo'} | |
43 | assert_response :success |
|
45 | assert_response :success | |
44 | assert_template 'previews/issue' |
|
46 | assert_select 'legend', :text => 'Description', :count => 0 | |
45 | assert_not_nil assigns(:notes) |
|
47 | assert_select 'legend', :text => 'Notes' | |
|
48 | end | |||
|
49 | ||||
|
50 | def test_preview_issue_notes_with_no_change_to_description | |||
|
51 | @request.session[:user_id] = 2 | |||
|
52 | post :issue, :project_id => '1', :id => 1, | |||
|
53 | :issue => {:description => 'Changed description', :notes => 'Foo'} | |||
|
54 | assert_response :success | |||
|
55 | assert_select 'legend', :text => 'Description' | |||
|
56 | assert_select 'legend', :text => 'Notes' | |||
46 | end |
|
57 | end | |
47 |
|
58 | |||
48 | def test_preview_journal_notes_for_update |
|
59 | def test_preview_journal_notes_for_update | |
49 | @request.session[:user_id] = 2 |
|
60 | @request.session[:user_id] = 2 | |
50 | post :issue, :project_id => '1', :id => 1, :notes => 'Foo' |
|
61 | post :issue, :project_id => '1', :id => 1, :notes => 'Foo' | |
51 | assert_response :success |
|
62 | assert_response :success | |
52 | assert_template 'previews/issue' |
|
63 | assert_select 'legend', :text => 'Notes' | |
53 | assert_not_nil assigns(:notes) |
|
|||
54 | assert_select 'p', :text => 'Foo' |
|
64 | assert_select 'p', :text => 'Foo' | |
55 | end |
|
65 | end | |
56 |
|
66 | |||
57 | def test_preview_issue_notes_should_support_links_to_existing_attachments |
|
67 | def test_preview_issue_notes_should_support_links_to_existing_attachments | |
58 | Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar') |
|
68 | Attachment.generate!(:container => Issue.find(1), :filename => 'foo.bar') | |
59 | @request.session[:user_id] = 2 |
|
69 | @request.session[:user_id] = 2 | |
60 | post :issue, :project_id => '1', :id => 1, :notes => 'attachment:foo.bar' |
|
70 | post :issue, :project_id => '1', :id => 1, :notes => 'attachment:foo.bar' | |
61 | assert_response :success |
|
71 | assert_response :success | |
62 | assert_select 'a.attachment', :text => 'foo.bar' |
|
72 | assert_select 'a.attachment', :text => 'foo.bar' | |
63 | end |
|
73 | end | |
64 |
|
74 | |||
65 | def test_preview_issue_with_project_changed |
|
75 | def test_preview_issue_with_project_changed | |
66 | @request.session[:user_id] = 2 |
|
76 | @request.session[:user_id] = 2 | |
67 | post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'notes', :project_id => 2} |
|
77 | post :issue, :project_id => '1', :id => 1, :issue => {:notes => 'notes', :project_id => 2} | |
68 | assert_response :success |
|
78 | assert_response :success | |
69 | assert_not_nil assigns(:issue) |
|
79 | assert_select 'legend', :text => 'Notes' | |
70 | assert_not_nil assigns(:notes) |
|
|||
71 | end |
|
80 | end | |
72 |
|
81 | |||
73 | def test_preview_new_news |
|
82 | def test_preview_new_news | |
74 | get :news, :project_id => 1, |
|
83 | get :news, :project_id => 1, | |
75 | :news => {:title => '', |
|
84 | :news => {:title => '', | |
76 | :description => 'News description', |
|
85 | :description => 'News description', | |
77 | :summary => ''} |
|
86 | :summary => ''} | |
78 | assert_response :success |
|
87 | assert_response :success | |
79 | assert_template 'common/_preview' |
|
|||
80 | assert_select 'fieldset.preview', :text => /News description/ |
|
88 | assert_select 'fieldset.preview', :text => /News description/ | |
81 | end |
|
89 | end | |
82 |
|
90 | |||
83 |
def test_existing |
|
91 | def test_preview_existing_news | |
84 | get :news, :project_id => 1, :id => 2, |
|
92 | get :news, :project_id => 1, :id => 2, | |
85 | :news => {:title => '', |
|
93 | :news => {:title => '', | |
86 | :description => 'News description', |
|
94 | :description => 'News description', | |
87 | :summary => ''} |
|
95 | :summary => ''} | |
88 | assert_response :success |
|
96 | assert_response :success | |
89 | assert_template 'common/_preview' |
|
|||
90 | assert_equal News.find(2), assigns(:previewed) |
|
|||
91 | assert_not_nil assigns(:attachments) |
|
|||
92 |
|
||||
93 | assert_select 'fieldset.preview', :text => /News description/ |
|
97 | assert_select 'fieldset.preview', :text => /News description/ | |
94 | end |
|
98 | end | |
95 | end |
|
99 | end |
@@ -1,209 +1,201 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class PrincipalMembershipsControllerTest < Redmine::ControllerTest |
|
20 | class PrincipalMembershipsControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :users, :members, :member_roles, :roles, :groups_users |
|
21 | fixtures :projects, :users, :members, :member_roles, :roles, :groups_users | |
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | @request.session[:user_id] = 1 |
|
24 | @request.session[:user_id] = 1 | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | def test_new_user_membership |
|
27 | def test_new_user_membership | |
28 | get :new, :user_id => 7 |
|
28 | get :new, :user_id => 7 | |
29 | assert_response :success |
|
29 | assert_response :success | |
30 | assert_select 'label', :text => 'eCookbook' do |
|
30 | assert_select 'label', :text => 'eCookbook' do | |
31 | assert_select 'input[name=?][value="1"]:not([disabled])', 'membership[project_ids][]' |
|
31 | assert_select 'input[name=?][value="1"]:not([disabled])', 'membership[project_ids][]' | |
32 | end |
|
32 | end | |
33 | end |
|
33 | end | |
34 |
|
34 | |||
35 | def test_new_user_membership_should_disable_user_projects |
|
35 | def test_new_user_membership_should_disable_user_projects | |
36 | Member.create!(:user_id => 7, :project_id => 1, :role_ids => [1]) |
|
36 | Member.create!(:user_id => 7, :project_id => 1, :role_ids => [1]) | |
37 |
|
37 | |||
38 | get :new, :user_id => 7 |
|
38 | get :new, :user_id => 7 | |
39 | assert_response :success |
|
39 | assert_response :success | |
40 | assert_select 'label', :text => 'eCookbook' do |
|
40 | assert_select 'label', :text => 'eCookbook' do | |
41 | assert_select 'input[name=?][value="1"][disabled=disabled]', 'membership[project_ids][]' |
|
41 | assert_select 'input[name=?][value="1"][disabled=disabled]', 'membership[project_ids][]' | |
42 | end |
|
42 | end | |
43 | end |
|
43 | end | |
44 |
|
44 | |||
45 | def test_xhr_new_user_membership |
|
45 | def test_xhr_new_user_membership | |
46 | xhr :get, :new, :user_id => 7 |
|
46 | xhr :get, :new, :user_id => 7 | |
47 | assert_response :success |
|
47 | assert_response :success | |
48 | assert_equal 'text/javascript', response.content_type |
|
48 | assert_equal 'text/javascript', response.content_type | |
49 | end |
|
49 | end | |
50 |
|
50 | |||
51 | def test_create_user_membership |
|
51 | def test_create_user_membership | |
52 | assert_difference 'Member.count' do |
|
52 | assert_difference 'Member.count' do | |
53 | post :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]} |
|
53 | post :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]} | |
54 | end |
|
54 | end | |
55 | assert_redirected_to '/users/7/edit?tab=memberships' |
|
55 | assert_redirected_to '/users/7/edit?tab=memberships' | |
56 | member = Member.order('id DESC').first |
|
56 | member = Member.order('id DESC').first | |
57 | assert_equal User.find(7), member.principal |
|
57 | assert_equal User.find(7), member.principal | |
58 | assert_equal [2], member.role_ids |
|
58 | assert_equal [2], member.role_ids | |
59 | assert_equal 3, member.project_id |
|
59 | assert_equal 3, member.project_id | |
60 | end |
|
60 | end | |
61 |
|
61 | |||
62 | def test_create_user_membership_with_multiple_roles |
|
62 | def test_create_user_membership_with_multiple_roles | |
63 | assert_difference 'Member.count' do |
|
63 | assert_difference 'Member.count' do | |
64 | post :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2, 3]} |
|
64 | post :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2, 3]} | |
65 | end |
|
65 | end | |
66 | member = Member.order('id DESC').first |
|
66 | member = Member.order('id DESC').first | |
67 | assert_equal User.find(7), member.principal |
|
67 | assert_equal User.find(7), member.principal | |
68 | assert_equal [2, 3], member.role_ids.sort |
|
68 | assert_equal [2, 3], member.role_ids.sort | |
69 | assert_equal 3, member.project_id |
|
69 | assert_equal 3, member.project_id | |
70 | end |
|
70 | end | |
71 |
|
71 | |||
72 | def test_create_user_membership_with_multiple_projects_and_roles |
|
72 | def test_create_user_membership_with_multiple_projects_and_roles | |
73 | assert_difference 'Member.count', 2 do |
|
73 | assert_difference 'Member.count', 2 do | |
74 | post :create, :user_id => 7, :membership => {:project_ids => [1, 3], :role_ids => [2, 3]} |
|
74 | post :create, :user_id => 7, :membership => {:project_ids => [1, 3], :role_ids => [2, 3]} | |
75 | end |
|
75 | end | |
76 | members = Member.order('id DESC').limit(2).sort_by(&:project_id) |
|
76 | members = Member.order('id DESC').limit(2).sort_by(&:project_id) | |
77 | assert_equal 1, members[0].project_id |
|
77 | assert_equal 1, members[0].project_id | |
78 | assert_equal 3, members[1].project_id |
|
78 | assert_equal 3, members[1].project_id | |
79 | members.each do |member| |
|
79 | members.each do |member| | |
80 | assert_equal User.find(7), member.principal |
|
80 | assert_equal User.find(7), member.principal | |
81 | assert_equal [2, 3], member.role_ids.sort |
|
81 | assert_equal [2, 3], member.role_ids.sort | |
82 | end |
|
82 | end | |
83 | end |
|
83 | end | |
84 |
|
84 | |||
85 | def test_xhr_create_user_membership |
|
85 | def test_xhr_create_user_membership | |
86 | assert_difference 'Member.count' do |
|
86 | assert_difference 'Member.count' do | |
87 | xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]}, :format => 'js' |
|
87 | xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3], :role_ids => [2]}, :format => 'js' | |
88 | assert_response :success |
|
88 | assert_response :success | |
89 | assert_template 'create' |
|
|||
90 | assert_equal 'text/javascript', response.content_type |
|
89 | assert_equal 'text/javascript', response.content_type | |
91 | end |
|
90 | end | |
92 | member = Member.order('id DESC').first |
|
91 | member = Member.order('id DESC').first | |
93 | assert_equal User.find(7), member.principal |
|
92 | assert_equal User.find(7), member.principal | |
94 | assert_equal [2], member.role_ids |
|
93 | assert_equal [2], member.role_ids | |
95 | assert_equal 3, member.project_id |
|
94 | assert_equal 3, member.project_id | |
96 | assert_include 'tab-content-memberships', response.body |
|
95 | assert_include 'tab-content-memberships', response.body | |
97 | end |
|
96 | end | |
98 |
|
97 | |||
99 | def test_xhr_create_user_membership_with_failure |
|
98 | def test_xhr_create_user_membership_with_failure | |
100 | assert_no_difference 'Member.count' do |
|
99 | assert_no_difference 'Member.count' do | |
101 | xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3]}, :format => 'js' |
|
100 | xhr :post, :create, :user_id => 7, :membership => {:project_ids => [3]}, :format => 'js' | |
102 | assert_response :success |
|
101 | assert_response :success | |
103 | assert_template 'create' |
|
|||
104 | assert_equal 'text/javascript', response.content_type |
|
102 | assert_equal 'text/javascript', response.content_type | |
105 | end |
|
103 | end | |
106 | assert_include 'alert', response.body, "Alert message not sent" |
|
104 | assert_include 'alert', response.body, "Alert message not sent" | |
107 | assert_include 'Role cannot be empty', response.body, "Error message not sent" |
|
105 | assert_include 'Role cannot be empty', response.body, "Error message not sent" | |
108 | end |
|
106 | end | |
109 |
|
107 | |||
110 | def test_update_user_membership |
|
108 | def test_update_user_membership | |
111 | assert_no_difference 'Member.count' do |
|
109 | assert_no_difference 'Member.count' do | |
112 | put :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]} |
|
110 | put :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]} | |
113 | assert_redirected_to '/users/2/edit?tab=memberships' |
|
111 | assert_redirected_to '/users/2/edit?tab=memberships' | |
114 | end |
|
112 | end | |
115 | assert_equal [2], Member.find(1).role_ids |
|
113 | assert_equal [2], Member.find(1).role_ids | |
116 | end |
|
114 | end | |
117 |
|
115 | |||
118 | def test_xhr_update_user_membership |
|
116 | def test_xhr_update_user_membership | |
119 | assert_no_difference 'Member.count' do |
|
117 | assert_no_difference 'Member.count' do | |
120 | xhr :put, :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]}, :format => 'js' |
|
118 | xhr :put, :update, :user_id => 2, :id => 1, :membership => {:role_ids => [2]}, :format => 'js' | |
121 | assert_response :success |
|
119 | assert_response :success | |
122 | assert_template 'update' |
|
|||
123 | assert_equal 'text/javascript', response.content_type |
|
120 | assert_equal 'text/javascript', response.content_type | |
124 | end |
|
121 | end | |
125 | assert_equal [2], Member.find(1).role_ids |
|
122 | assert_equal [2], Member.find(1).role_ids | |
126 | assert_include 'tab-content-memberships', response.body |
|
123 | assert_include 'tab-content-memberships', response.body | |
127 | end |
|
124 | end | |
128 |
|
125 | |||
129 | def test_destroy_user_membership |
|
126 | def test_destroy_user_membership | |
130 | assert_difference 'Member.count', -1 do |
|
127 | assert_difference 'Member.count', -1 do | |
131 | delete :destroy, :user_id => 2, :id => 1 |
|
128 | delete :destroy, :user_id => 2, :id => 1 | |
132 | end |
|
129 | end | |
133 | assert_redirected_to '/users/2/edit?tab=memberships' |
|
130 | assert_redirected_to '/users/2/edit?tab=memberships' | |
134 | assert_nil Member.find_by_id(1) |
|
131 | assert_nil Member.find_by_id(1) | |
135 | end |
|
132 | end | |
136 |
|
133 | |||
137 | def test_xhr_destroy_user_membership_js_format |
|
134 | def test_xhr_destroy_user_membership_js_format | |
138 | assert_difference 'Member.count', -1 do |
|
135 | assert_difference 'Member.count', -1 do | |
139 | xhr :delete, :destroy, :user_id => 2, :id => 1 |
|
136 | xhr :delete, :destroy, :user_id => 2, :id => 1 | |
140 | assert_response :success |
|
137 | assert_response :success | |
141 | assert_template 'destroy' |
|
|||
142 | assert_equal 'text/javascript', response.content_type |
|
138 | assert_equal 'text/javascript', response.content_type | |
143 | end |
|
139 | end | |
144 | assert_nil Member.find_by_id(1) |
|
140 | assert_nil Member.find_by_id(1) | |
145 | assert_include 'tab-content-memberships', response.body |
|
141 | assert_include 'tab-content-memberships', response.body | |
146 | end |
|
142 | end | |
147 |
|
143 | |||
148 | def test_xhr_new_group_membership |
|
144 | def test_xhr_new_group_membership | |
149 | xhr :get, :new, :group_id => 10 |
|
145 | xhr :get, :new, :group_id => 10 | |
150 | assert_response :success |
|
146 | assert_response :success | |
151 | assert_equal 'text/javascript', response.content_type |
|
147 | assert_equal 'text/javascript', response.content_type | |
152 | end |
|
148 | end | |
153 |
|
149 | |||
154 | def test_create_group_membership |
|
150 | def test_create_group_membership | |
155 | assert_difference 'Group.find(10).members.count' do |
|
151 | assert_difference 'Group.find(10).members.count' do | |
156 | post :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']} |
|
152 | post :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']} | |
157 | end |
|
153 | end | |
158 | end |
|
154 | end | |
159 |
|
155 | |||
160 | def test_xhr_create_group_membership |
|
156 | def test_xhr_create_group_membership | |
161 | assert_difference 'Group.find(10).members.count' do |
|
157 | assert_difference 'Group.find(10).members.count' do | |
162 | xhr :post, :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']} |
|
158 | xhr :post, :create, :group_id => 10, :membership => {:project_ids => [2], :role_ids => ['1', '2']} | |
163 | assert_response :success |
|
159 | assert_response :success | |
164 | assert_template 'create' |
|
|||
165 | assert_equal 'text/javascript', response.content_type |
|
160 | assert_equal 'text/javascript', response.content_type | |
166 | end |
|
161 | end | |
167 | assert_match /OnlineStore/, response.body |
|
162 | assert_match /OnlineStore/, response.body | |
168 | end |
|
163 | end | |
169 |
|
164 | |||
170 | def test_xhr_create_group_membership_with_failure |
|
165 | def test_xhr_create_group_membership_with_failure | |
171 | assert_no_difference 'Group.find(10).members.count' do |
|
166 | assert_no_difference 'Group.find(10).members.count' do | |
172 | xhr :post, :create, :group_id => 10, :membership => {:project_ids => [999], :role_ids => ['1', '2']} |
|
167 | xhr :post, :create, :group_id => 10, :membership => {:project_ids => [999], :role_ids => ['1', '2']} | |
173 | assert_response :success |
|
168 | assert_response :success | |
174 | assert_template 'create' |
|
|||
175 | assert_equal 'text/javascript', response.content_type |
|
169 | assert_equal 'text/javascript', response.content_type | |
176 | end |
|
170 | end | |
177 | assert_match /alert/, response.body, "Alert message not sent" |
|
171 | assert_match /alert/, response.body, "Alert message not sent" | |
178 | end |
|
172 | end | |
179 |
|
173 | |||
180 | def test_update_group_membership |
|
174 | def test_update_group_membership | |
181 | assert_no_difference 'Group.find(10).members.count' do |
|
175 | assert_no_difference 'Group.find(10).members.count' do | |
182 | put :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']} |
|
176 | put :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']} | |
183 | end |
|
177 | end | |
184 | end |
|
178 | end | |
185 |
|
179 | |||
186 | def test_xhr_update_group_membership |
|
180 | def test_xhr_update_group_membership | |
187 | assert_no_difference 'Group.find(10).members.count' do |
|
181 | assert_no_difference 'Group.find(10).members.count' do | |
188 | xhr :post, :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']} |
|
182 | xhr :post, :update, :group_id => 10, :id => 6, :membership => {:role_ids => ['1', '3']} | |
189 | assert_response :success |
|
183 | assert_response :success | |
190 | assert_template 'update' |
|
|||
191 | assert_equal 'text/javascript', response.content_type |
|
184 | assert_equal 'text/javascript', response.content_type | |
192 | end |
|
185 | end | |
193 | end |
|
186 | end | |
194 |
|
187 | |||
195 | def test_destroy_group_membership |
|
188 | def test_destroy_group_membership | |
196 | assert_difference 'Group.find(10).members.count', -1 do |
|
189 | assert_difference 'Group.find(10).members.count', -1 do | |
197 | delete :destroy, :group_id => 10, :id => 6 |
|
190 | delete :destroy, :group_id => 10, :id => 6 | |
198 | end |
|
191 | end | |
199 | end |
|
192 | end | |
200 |
|
193 | |||
201 | def test_xhr_destroy_group_membership |
|
194 | def test_xhr_destroy_group_membership | |
202 | assert_difference 'Group.find(10).members.count', -1 do |
|
195 | assert_difference 'Group.find(10).members.count', -1 do | |
203 | xhr :delete, :destroy, :group_id => 10, :id => 6 |
|
196 | xhr :delete, :destroy, :group_id => 10, :id => 6 | |
204 | assert_response :success |
|
197 | assert_response :success | |
205 | assert_template 'destroy' |
|
|||
206 | assert_equal 'text/javascript', response.content_type |
|
198 | assert_equal 'text/javascript', response.content_type | |
207 | end |
|
199 | end | |
208 | end |
|
200 | end | |
209 | end |
|
201 | end |
@@ -1,694 +1,675 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class ProjectsControllerTest < Redmine::ControllerTest |
|
20 | class ProjectsControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :versions, :users, :email_addresses, :roles, :members, |
|
21 | fixtures :projects, :versions, :users, :email_addresses, :roles, :members, | |
22 | :member_roles, :issues, :journals, :journal_details, |
|
22 | :member_roles, :issues, :journals, :journal_details, | |
23 | :trackers, :projects_trackers, :issue_statuses, |
|
23 | :trackers, :projects_trackers, :issue_statuses, | |
24 | :enabled_modules, :enumerations, :boards, :messages, |
|
24 | :enabled_modules, :enumerations, :boards, :messages, | |
25 | :attachments, :custom_fields, :custom_values, :time_entries, |
|
25 | :attachments, :custom_fields, :custom_values, :time_entries, | |
26 | :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions |
|
26 | :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions | |
27 |
|
27 | |||
28 | def setup |
|
28 | def setup | |
29 | @request.session[:user_id] = nil |
|
29 | @request.session[:user_id] = nil | |
30 | Setting.default_language = 'en' |
|
30 | Setting.default_language = 'en' | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_index_by_anonymous_should_not_show_private_projects |
|
33 | def test_index_by_anonymous_should_not_show_private_projects | |
34 | get :index |
|
34 | get :index | |
35 | assert_response :success |
|
35 | assert_response :success | |
36 | assert_template 'index' |
|
|||
37 | projects = assigns(:projects) |
|
|||
38 | assert_not_nil projects |
|
|||
39 | assert projects.all?(&:is_public?) |
|
|||
40 |
|
36 | |||
41 | assert_select 'ul' do |
|
37 | assert_select 'ul' do | |
42 | assert_select 'li' do |
|
38 | assert_select 'li' do | |
43 | assert_select 'a', :text => 'eCookbook' |
|
39 | assert_select 'a', :text => 'eCookbook' | |
44 | assert_select 'ul' do |
|
40 | assert_select 'ul' do | |
45 | assert_select 'a', :text => 'Child of private child' |
|
41 | assert_select 'a', :text => 'Child of private child' | |
46 | end |
|
42 | end | |
47 | end |
|
43 | end | |
48 | end |
|
44 | end | |
49 | assert_select 'a', :text => /Private child of eCookbook/, :count => 0 |
|
45 | assert_select 'a', :text => /Private child of eCookbook/, :count => 0 | |
50 | end |
|
46 | end | |
51 |
|
47 | |||
52 | def test_index_atom |
|
48 | def test_index_atom | |
53 | get :index, :format => 'atom' |
|
49 | get :index, :format => 'atom' | |
54 | assert_response :success |
|
50 | assert_response :success | |
55 | assert_template 'common/feed' |
|
|||
56 | assert_select 'feed>title', :text => 'Redmine: Latest projects' |
|
51 | assert_select 'feed>title', :text => 'Redmine: Latest projects' | |
57 | assert_select 'feed>entry', :count => Project.visible(User.current).count |
|
52 | assert_select 'feed>entry', :count => Project.visible(User.current).count | |
58 | end |
|
53 | end | |
59 |
|
54 | |||
60 | test "#index by non-admin user with view_time_entries permission should show overall spent time link" do |
|
55 | test "#index by non-admin user with view_time_entries permission should show overall spent time link" do | |
61 | @request.session[:user_id] = 3 |
|
56 | @request.session[:user_id] = 3 | |
62 | get :index |
|
57 | get :index | |
63 | assert_template 'index' |
|
|||
64 | assert_select 'a[href=?]', '/time_entries' |
|
58 | assert_select 'a[href=?]', '/time_entries' | |
65 | end |
|
59 | end | |
66 |
|
60 | |||
67 | test "#index by non-admin user without view_time_entries permission should not show overall spent time link" do |
|
61 | test "#index by non-admin user without view_time_entries permission should not show overall spent time link" do | |
68 | Role.find(2).remove_permission! :view_time_entries |
|
62 | Role.find(2).remove_permission! :view_time_entries | |
69 | Role.non_member.remove_permission! :view_time_entries |
|
63 | Role.non_member.remove_permission! :view_time_entries | |
70 | Role.anonymous.remove_permission! :view_time_entries |
|
64 | Role.anonymous.remove_permission! :view_time_entries | |
71 | @request.session[:user_id] = 3 |
|
65 | @request.session[:user_id] = 3 | |
72 |
|
66 | |||
73 | get :index |
|
67 | get :index | |
74 | assert_template 'index' |
|
|||
75 | assert_select 'a[href=?]', '/time_entries', 0 |
|
68 | assert_select 'a[href=?]', '/time_entries', 0 | |
76 | end |
|
69 | end | |
77 |
|
70 | |||
78 | test "#index by non-admin user with permission should show add project link" do |
|
71 | test "#index by non-admin user with permission should show add project link" do | |
79 | Role.find(1).add_permission! :add_project |
|
72 | Role.find(1).add_permission! :add_project | |
80 | @request.session[:user_id] = 2 |
|
73 | @request.session[:user_id] = 2 | |
|
74 | ||||
81 | get :index |
|
75 | get :index | |
82 | assert_template 'index' |
|
|||
83 | assert_select 'a[href=?]', '/projects/new' |
|
76 | assert_select 'a[href=?]', '/projects/new' | |
84 | end |
|
77 | end | |
85 |
|
78 | |||
86 | test "#new by admin user should accept get" do |
|
79 | test "#new by admin user should accept get" do | |
87 | @request.session[:user_id] = 1 |
|
80 | @request.session[:user_id] = 1 | |
88 |
|
81 | |||
89 | get :new |
|
82 | get :new | |
90 | assert_response :success |
|
83 | assert_response :success | |
91 | assert_template 'new' |
|
84 | assert_select 'input[name=?]', 'project[name]' | |
|
85 | assert_select 'select[name=?]', 'project[parent_id]' | |||
92 | end |
|
86 | end | |
93 |
|
87 | |||
94 | test "#new by non-admin user with add_project permission should accept get" do |
|
88 | test "#new by non-admin user with add_project permission should accept get" do | |
95 | Role.non_member.add_permission! :add_project |
|
89 | Role.non_member.add_permission! :add_project | |
96 | @request.session[:user_id] = 9 |
|
90 | @request.session[:user_id] = 9 | |
97 |
|
91 | |||
98 | get :new |
|
92 | get :new | |
99 | assert_response :success |
|
93 | assert_response :success | |
100 | assert_template 'new' |
|
94 | assert_select 'input[name=?]', 'project[name]' | |
101 | assert_select 'select[name=?]', 'project[parent_id]', 0 |
|
95 | assert_select 'select[name=?]', 'project[parent_id]', 0 | |
102 | end |
|
96 | end | |
103 |
|
97 | |||
104 | test "#new by non-admin user with add_subprojects permission should accept get" do |
|
98 | test "#new by non-admin user with add_subprojects permission should accept get" do | |
105 | Role.find(1).remove_permission! :add_project |
|
99 | Role.find(1).remove_permission! :add_project | |
106 | Role.find(1).add_permission! :add_subprojects |
|
100 | Role.find(1).add_permission! :add_subprojects | |
107 | @request.session[:user_id] = 2 |
|
101 | @request.session[:user_id] = 2 | |
108 |
|
102 | |||
109 | get :new, :parent_id => 'ecookbook' |
|
103 | get :new, :parent_id => 'ecookbook' | |
110 | assert_response :success |
|
104 | assert_response :success | |
111 | assert_template 'new' |
|
|||
112 |
|
105 | |||
113 | assert_select 'select[name=?]', 'project[parent_id]' do |
|
106 | assert_select 'select[name=?]', 'project[parent_id]' do | |
114 | # parent project selected |
|
107 | # parent project selected | |
115 | assert_select 'option[value="1"][selected=selected]' |
|
108 | assert_select 'option[value="1"][selected=selected]' | |
116 | # no empty value |
|
109 | # no empty value | |
117 | assert_select 'option[value=""]', 0 |
|
110 | assert_select 'option[value=""]', 0 | |
118 | end |
|
111 | end | |
119 | end |
|
112 | end | |
120 |
|
113 | |||
121 | def test_new_should_not_display_invalid_search_link |
|
114 | def test_new_should_not_display_invalid_search_link | |
122 | @request.session[:user_id] = 1 |
|
115 | @request.session[:user_id] = 1 | |
123 |
|
116 | |||
124 | get :new |
|
117 | get :new | |
125 | assert_response :success |
|
118 | assert_response :success | |
126 | assert_select '#quick-search form[action=?]', '/search' |
|
119 | assert_select '#quick-search form[action=?]', '/search' | |
127 | assert_select '#quick-search a[href=?]', '/search' |
|
120 | assert_select '#quick-search a[href=?]', '/search' | |
128 | end |
|
121 | end | |
129 |
|
122 | |||
130 | test "#create by admin user should create a new project" do |
|
123 | test "#create by admin user should create a new project" do | |
131 | @request.session[:user_id] = 1 |
|
124 | @request.session[:user_id] = 1 | |
132 |
|
125 | |||
133 | post :create, |
|
126 | post :create, | |
134 | :project => { |
|
127 | :project => { | |
135 | :name => "blog", |
|
128 | :name => "blog", | |
136 | :description => "weblog", |
|
129 | :description => "weblog", | |
137 | :homepage => 'http://weblog', |
|
130 | :homepage => 'http://weblog', | |
138 | :identifier => "blog", |
|
131 | :identifier => "blog", | |
139 | :is_public => 1, |
|
132 | :is_public => 1, | |
140 | :custom_field_values => { '3' => 'Beta' }, |
|
133 | :custom_field_values => { '3' => 'Beta' }, | |
141 | :tracker_ids => ['1', '3'], |
|
134 | :tracker_ids => ['1', '3'], | |
142 | # an issue custom field that is not for all project |
|
135 | # an issue custom field that is not for all project | |
143 | :issue_custom_field_ids => ['9'], |
|
136 | :issue_custom_field_ids => ['9'], | |
144 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] |
|
137 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
145 | } |
|
138 | } | |
146 | assert_redirected_to '/projects/blog/settings' |
|
139 | assert_redirected_to '/projects/blog/settings' | |
147 |
|
140 | |||
148 | project = Project.find_by_name('blog') |
|
141 | project = Project.find_by_name('blog') | |
149 | assert_kind_of Project, project |
|
142 | assert_kind_of Project, project | |
150 | assert project.active? |
|
143 | assert project.active? | |
151 | assert_equal 'weblog', project.description |
|
144 | assert_equal 'weblog', project.description | |
152 | assert_equal 'http://weblog', project.homepage |
|
145 | assert_equal 'http://weblog', project.homepage | |
153 | assert_equal true, project.is_public? |
|
146 | assert_equal true, project.is_public? | |
154 | assert_nil project.parent |
|
147 | assert_nil project.parent | |
155 | assert_equal 'Beta', project.custom_value_for(3).value |
|
148 | assert_equal 'Beta', project.custom_value_for(3).value | |
156 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
149 | assert_equal [1, 3], project.trackers.map(&:id).sort | |
157 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort |
|
150 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
158 | assert project.issue_custom_fields.include?(IssueCustomField.find(9)) |
|
151 | assert project.issue_custom_fields.include?(IssueCustomField.find(9)) | |
159 | end |
|
152 | end | |
160 |
|
153 | |||
161 | test "#create by admin user should create a new subproject" do |
|
154 | test "#create by admin user should create a new subproject" do | |
162 | @request.session[:user_id] = 1 |
|
155 | @request.session[:user_id] = 1 | |
163 |
|
156 | |||
164 | assert_difference 'Project.count' do |
|
157 | assert_difference 'Project.count' do | |
165 | post :create, :project => { :name => "blog", |
|
158 | post :create, :project => { :name => "blog", | |
166 | :description => "weblog", |
|
159 | :description => "weblog", | |
167 | :identifier => "blog", |
|
160 | :identifier => "blog", | |
168 | :is_public => 1, |
|
161 | :is_public => 1, | |
169 | :custom_field_values => { '3' => 'Beta' }, |
|
162 | :custom_field_values => { '3' => 'Beta' }, | |
170 | :parent_id => 1 |
|
163 | :parent_id => 1 | |
171 | } |
|
164 | } | |
172 | assert_redirected_to '/projects/blog/settings' |
|
165 | assert_redirected_to '/projects/blog/settings' | |
173 | end |
|
166 | end | |
174 |
|
167 | |||
175 | project = Project.find_by_name('blog') |
|
168 | project = Project.find_by_name('blog') | |
176 | assert_kind_of Project, project |
|
169 | assert_kind_of Project, project | |
177 | assert_equal Project.find(1), project.parent |
|
170 | assert_equal Project.find(1), project.parent | |
178 | end |
|
171 | end | |
179 |
|
172 | |||
180 | test "#create by admin user should continue" do |
|
173 | test "#create by admin user should continue" do | |
181 | @request.session[:user_id] = 1 |
|
174 | @request.session[:user_id] = 1 | |
182 |
|
175 | |||
183 | assert_difference 'Project.count' do |
|
176 | assert_difference 'Project.count' do | |
184 | post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' |
|
177 | post :create, :project => {:name => "blog", :identifier => "blog"}, :continue => 'Create and continue' | |
185 | end |
|
178 | end | |
186 | assert_redirected_to '/projects/new' |
|
179 | assert_redirected_to '/projects/new' | |
187 | end |
|
180 | end | |
188 |
|
181 | |||
189 | test "#create by non-admin user with add_project permission should create a new project" do |
|
182 | test "#create by non-admin user with add_project permission should create a new project" do | |
190 | Role.non_member.add_permission! :add_project |
|
183 | Role.non_member.add_permission! :add_project | |
191 | @request.session[:user_id] = 9 |
|
184 | @request.session[:user_id] = 9 | |
192 |
|
185 | |||
193 | post :create, :project => { :name => "blog", |
|
186 | post :create, :project => { :name => "blog", | |
194 | :description => "weblog", |
|
187 | :description => "weblog", | |
195 | :identifier => "blog", |
|
188 | :identifier => "blog", | |
196 | :is_public => 1, |
|
189 | :is_public => 1, | |
197 | :custom_field_values => { '3' => 'Beta' }, |
|
190 | :custom_field_values => { '3' => 'Beta' }, | |
198 | :tracker_ids => ['1', '3'], |
|
191 | :tracker_ids => ['1', '3'], | |
199 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] |
|
192 | :enabled_module_names => ['issue_tracking', 'news', 'repository'] | |
200 | } |
|
193 | } | |
201 |
|
194 | |||
202 | assert_redirected_to '/projects/blog/settings' |
|
195 | assert_redirected_to '/projects/blog/settings' | |
203 |
|
196 | |||
204 | project = Project.find_by_name('blog') |
|
197 | project = Project.find_by_name('blog') | |
205 | assert_kind_of Project, project |
|
198 | assert_kind_of Project, project | |
206 | assert_equal 'weblog', project.description |
|
199 | assert_equal 'weblog', project.description | |
207 | assert_equal true, project.is_public? |
|
200 | assert_equal true, project.is_public? | |
208 | assert_equal [1, 3], project.trackers.map(&:id).sort |
|
201 | assert_equal [1, 3], project.trackers.map(&:id).sort | |
209 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort |
|
202 | assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort | |
210 |
|
203 | |||
211 | # User should be added as a project member |
|
204 | # User should be added as a project member | |
212 | assert User.find(9).member_of?(project) |
|
205 | assert User.find(9).member_of?(project) | |
213 | assert_equal 1, project.members.size |
|
206 | assert_equal 1, project.members.size | |
214 | end |
|
207 | end | |
215 |
|
208 | |||
216 | test "#create by non-admin user with add_project permission should fail with parent_id" do |
|
209 | test "#create by non-admin user with add_project permission should fail with parent_id" do | |
217 | Role.non_member.add_permission! :add_project |
|
210 | Role.non_member.add_permission! :add_project | |
|
211 | User.find(9).update! :language => 'en' | |||
218 | @request.session[:user_id] = 9 |
|
212 | @request.session[:user_id] = 9 | |
219 |
|
213 | |||
220 | assert_no_difference 'Project.count' do |
|
214 | assert_no_difference 'Project.count' do | |
221 | post :create, :project => { :name => "blog", |
|
215 | post :create, :project => { :name => "blog", | |
222 | :description => "weblog", |
|
216 | :description => "weblog", | |
223 | :identifier => "blog", |
|
217 | :identifier => "blog", | |
224 | :is_public => 1, |
|
218 | :is_public => 1, | |
225 | :custom_field_values => { '3' => 'Beta' }, |
|
219 | :custom_field_values => { '3' => 'Beta' }, | |
226 | :parent_id => 1 |
|
220 | :parent_id => 1 | |
227 | } |
|
221 | } | |
228 | end |
|
222 | end | |
229 | assert_response :success |
|
223 | assert_response :success | |
230 | project = assigns(:project) |
|
224 | assert_select_error /Subproject of is invalid/ | |
231 | assert_kind_of Project, project |
|
|||
232 | assert_not_equal [], project.errors[:parent_id] |
|
|||
233 | end |
|
225 | end | |
234 |
|
226 | |||
235 | test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do |
|
227 | test "#create by non-admin user with add_subprojects permission should create a project with a parent_id" do | |
236 | Role.find(1).remove_permission! :add_project |
|
228 | Role.find(1).remove_permission! :add_project | |
237 | Role.find(1).add_permission! :add_subprojects |
|
229 | Role.find(1).add_permission! :add_subprojects | |
238 | @request.session[:user_id] = 2 |
|
230 | @request.session[:user_id] = 2 | |
239 |
|
231 | |||
240 | post :create, :project => { :name => "blog", |
|
232 | post :create, :project => { :name => "blog", | |
241 | :description => "weblog", |
|
233 | :description => "weblog", | |
242 | :identifier => "blog", |
|
234 | :identifier => "blog", | |
243 | :is_public => 1, |
|
235 | :is_public => 1, | |
244 | :custom_field_values => { '3' => 'Beta' }, |
|
236 | :custom_field_values => { '3' => 'Beta' }, | |
245 | :parent_id => 1 |
|
237 | :parent_id => 1 | |
246 | } |
|
238 | } | |
247 | assert_redirected_to '/projects/blog/settings' |
|
239 | assert_redirected_to '/projects/blog/settings' | |
248 | project = Project.find_by_name('blog') |
|
240 | project = Project.find_by_name('blog') | |
|
241 | assert_equal 1, project.parent_id | |||
249 | end |
|
242 | end | |
250 |
|
243 | |||
251 | test "#create by non-admin user with add_subprojects permission should fail without parent_id" do |
|
244 | test "#create by non-admin user with add_subprojects permission should fail without parent_id" do | |
252 | Role.find(1).remove_permission! :add_project |
|
245 | Role.find(1).remove_permission! :add_project | |
253 | Role.find(1).add_permission! :add_subprojects |
|
246 | Role.find(1).add_permission! :add_subprojects | |
254 | @request.session[:user_id] = 2 |
|
247 | @request.session[:user_id] = 2 | |
255 |
|
248 | |||
256 | assert_no_difference 'Project.count' do |
|
249 | assert_no_difference 'Project.count' do | |
257 | post :create, :project => { :name => "blog", |
|
250 | post :create, :project => { :name => "blog", | |
258 | :description => "weblog", |
|
251 | :description => "weblog", | |
259 | :identifier => "blog", |
|
252 | :identifier => "blog", | |
260 | :is_public => 1, |
|
253 | :is_public => 1, | |
261 | :custom_field_values => { '3' => 'Beta' } |
|
254 | :custom_field_values => { '3' => 'Beta' } | |
262 | } |
|
255 | } | |
263 | end |
|
256 | end | |
264 | assert_response :success |
|
257 | assert_response :success | |
265 | project = assigns(:project) |
|
258 | assert_select_error /Subproject of is invalid/ | |
266 | assert_kind_of Project, project |
|
|||
267 | assert_not_equal [], project.errors[:parent_id] |
|
|||
268 | end |
|
259 | end | |
269 |
|
260 | |||
270 | test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do |
|
261 | test "#create by non-admin user with add_subprojects permission should fail with unauthorized parent_id" do | |
271 | Role.find(1).remove_permission! :add_project |
|
262 | Role.find(1).remove_permission! :add_project | |
272 | Role.find(1).add_permission! :add_subprojects |
|
263 | Role.find(1).add_permission! :add_subprojects | |
273 | @request.session[:user_id] = 2 |
|
264 | @request.session[:user_id] = 2 | |
274 |
|
265 | |||
275 | assert !User.find(2).member_of?(Project.find(6)) |
|
266 | assert !User.find(2).member_of?(Project.find(6)) | |
276 | assert_no_difference 'Project.count' do |
|
267 | assert_no_difference 'Project.count' do | |
277 | post :create, :project => { :name => "blog", |
|
268 | post :create, :project => { :name => "blog", | |
278 | :description => "weblog", |
|
269 | :description => "weblog", | |
279 | :identifier => "blog", |
|
270 | :identifier => "blog", | |
280 | :is_public => 1, |
|
271 | :is_public => 1, | |
281 | :custom_field_values => { '3' => 'Beta' }, |
|
272 | :custom_field_values => { '3' => 'Beta' }, | |
282 | :parent_id => 6 |
|
273 | :parent_id => 6 | |
283 | } |
|
274 | } | |
284 | end |
|
275 | end | |
285 | assert_response :success |
|
276 | assert_response :success | |
286 | project = assigns(:project) |
|
277 | assert_select_error /Subproject of is invalid/ | |
287 | assert_kind_of Project, project |
|
|||
288 | assert_not_equal [], project.errors[:parent_id] |
|
|||
289 | end |
|
278 | end | |
290 |
|
279 | |||
291 | def test_create_subproject_with_inherit_members_should_inherit_members |
|
280 | def test_create_subproject_with_inherit_members_should_inherit_members | |
292 | Role.find_by_name('Manager').add_permission! :add_subprojects |
|
281 | Role.find_by_name('Manager').add_permission! :add_subprojects | |
293 | parent = Project.find(1) |
|
282 | parent = Project.find(1) | |
294 | @request.session[:user_id] = 2 |
|
283 | @request.session[:user_id] = 2 | |
295 |
|
284 | |||
296 | assert_difference 'Project.count' do |
|
285 | assert_difference 'Project.count' do | |
297 | post :create, :project => { |
|
286 | post :create, :project => { | |
298 | :name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1' |
|
287 | :name => 'inherited', :identifier => 'inherited', :parent_id => parent.id, :inherit_members => '1' | |
299 | } |
|
288 | } | |
300 | assert_response 302 |
|
289 | assert_response 302 | |
301 | end |
|
290 | end | |
302 |
|
291 | |||
303 | project = Project.order('id desc').first |
|
292 | project = Project.order('id desc').first | |
304 | assert_equal 'inherited', project.name |
|
293 | assert_equal 'inherited', project.name | |
305 | assert_equal parent, project.parent |
|
294 | assert_equal parent, project.parent | |
306 | assert project.memberships.count > 0 |
|
295 | assert project.memberships.count > 0 | |
307 | assert_equal parent.memberships.count, project.memberships.count |
|
296 | assert_equal parent.memberships.count, project.memberships.count | |
308 | end |
|
297 | end | |
309 |
|
298 | |||
310 | def test_create_should_preserve_modules_on_validation_failure |
|
299 | def test_create_should_preserve_modules_on_validation_failure | |
311 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do |
|
300 | with_settings :default_projects_modules => ['issue_tracking', 'repository'] do | |
312 | @request.session[:user_id] = 1 |
|
301 | @request.session[:user_id] = 1 | |
313 | assert_no_difference 'Project.count' do |
|
302 | assert_no_difference 'Project.count' do | |
314 | post :create, :project => { |
|
303 | post :create, :project => { | |
315 | :name => "blog", |
|
304 | :name => "blog", | |
316 | :identifier => "", |
|
305 | :identifier => "", | |
317 | :enabled_module_names => %w(issue_tracking news) |
|
306 | :enabled_module_names => %w(issue_tracking news) | |
318 | } |
|
307 | } | |
319 | end |
|
308 | end | |
320 | assert_response :success |
|
309 | assert_response :success | |
321 | project = assigns(:project) |
|
310 | %w(issue_tracking news).each do |mod| | |
322 | assert_equal %w(issue_tracking news), project.enabled_module_names.sort |
|
311 | assert_select 'input[name=?][value=?][checked=checked]', 'project[enabled_module_names][]', mod | |
|
312 | end | |||
|
313 | assert_select 'input[name=?][checked=checked]', 'project[enabled_module_names][]', :count => 2 | |||
323 | end |
|
314 | end | |
324 | end |
|
315 | end | |
325 |
|
316 | |||
326 | def test_show_by_id |
|
317 | def test_show_by_id | |
327 | get :show, :id => 1 |
|
318 | get :show, :id => 1 | |
328 | assert_response :success |
|
319 | assert_response :success | |
329 | assert_template 'show' |
|
320 | assert_select '#header h1', :text => "eCookbook" | |
330 | assert_not_nil assigns(:project) |
|
|||
331 | end |
|
321 | end | |
332 |
|
322 | |||
333 | def test_show_by_identifier |
|
323 | def test_show_by_identifier | |
334 | get :show, :id => 'ecookbook' |
|
324 | get :show, :id => 'ecookbook' | |
335 | assert_response :success |
|
325 | assert_response :success | |
336 | assert_template 'show' |
|
326 | assert_select '#header h1', :text => "eCookbook" | |
337 | assert_not_nil assigns(:project) |
|
|||
338 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
|||
339 |
|
||||
340 | assert_select 'li', :text => /Development status/ |
|
|||
341 | end |
|
327 | end | |
342 |
|
328 | |||
343 | def test_show_should_not_display_empty_sidebar |
|
329 | def test_show_should_not_display_empty_sidebar | |
344 | p = Project.find(1) |
|
330 | p = Project.find(1) | |
345 | p.enabled_module_names = [] |
|
331 | p.enabled_module_names = [] | |
346 | p.save! |
|
332 | p.save! | |
347 |
|
333 | |||
348 | get :show, :id => 'ecookbook' |
|
334 | get :show, :id => 'ecookbook' | |
349 | assert_response :success |
|
335 | assert_response :success | |
350 | assert_select '#main.nosidebar' |
|
336 | assert_select '#main.nosidebar' | |
351 | end |
|
337 | end | |
352 |
|
338 | |||
|
339 | def test_show_should_display_visible_custom_fields | |||
|
340 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, true | |||
|
341 | get :show, :id => 'ecookbook' | |||
|
342 | assert_response :success | |||
|
343 | ||||
|
344 | assert_select 'li', :text => /Development status/ | |||
|
345 | end | |||
|
346 | ||||
353 | def test_show_should_not_display_hidden_custom_fields |
|
347 | def test_show_should_not_display_hidden_custom_fields | |
354 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false |
|
348 | ProjectCustomField.find_by_name('Development status').update_attribute :visible, false | |
355 | get :show, :id => 'ecookbook' |
|
349 | get :show, :id => 'ecookbook' | |
356 | assert_response :success |
|
350 | assert_response :success | |
357 | assert_template 'show' |
|
|||
358 | assert_not_nil assigns(:project) |
|
|||
359 |
|
351 | |||
360 | assert_select 'li', :text => /Development status/, :count => 0 |
|
352 | assert_select 'li', :text => /Development status/, :count => 0 | |
361 | end |
|
353 | end | |
362 |
|
354 | |||
363 | def test_show_should_not_display_blank_custom_fields_with_multiple_values |
|
355 | def test_show_should_not_display_blank_custom_fields_with_multiple_values | |
364 | f1 = ProjectCustomField.generate! :field_format => 'list', :possible_values => %w(Foo Bar), :multiple => true |
|
356 | f1 = ProjectCustomField.generate! :field_format => 'list', :possible_values => %w(Foo Bar), :multiple => true | |
365 | f2 = ProjectCustomField.generate! :field_format => 'list', :possible_values => %w(Baz Qux), :multiple => true |
|
357 | f2 = ProjectCustomField.generate! :field_format => 'list', :possible_values => %w(Baz Qux), :multiple => true | |
366 | project = Project.generate!(:custom_field_values => {f2.id.to_s => %w(Qux)}) |
|
358 | project = Project.generate!(:custom_field_values => {f2.id.to_s => %w(Qux)}) | |
367 |
|
359 | |||
368 | get :show, :id => project.id |
|
360 | get :show, :id => project.id | |
369 | assert_response :success |
|
361 | assert_response :success | |
370 |
|
362 | |||
371 | assert_select 'li', :text => /#{f1.name}/, :count => 0 |
|
363 | assert_select 'li', :text => /#{f1.name}/, :count => 0 | |
372 | assert_select 'li', :text => /#{f2.name}/ |
|
364 | assert_select 'li', :text => /#{f2.name}/ | |
373 | end |
|
365 | end | |
374 |
|
366 | |||
375 | def test_show_should_not_display_blank_text_custom_fields |
|
367 | def test_show_should_not_display_blank_text_custom_fields | |
376 | f1 = ProjectCustomField.generate! :field_format => 'text' |
|
368 | f1 = ProjectCustomField.generate! :field_format => 'text' | |
377 |
|
369 | |||
378 | get :show, :id => 1 |
|
370 | get :show, :id => 1 | |
379 | assert_response :success |
|
371 | assert_response :success | |
380 |
|
372 | |||
381 | assert_select 'li', :text => /#{f1.name}/, :count => 0 |
|
373 | assert_select 'li', :text => /#{f1.name}/, :count => 0 | |
382 | end |
|
374 | end | |
383 |
|
375 | |||
384 | def test_show_should_not_fail_when_custom_values_are_nil |
|
376 | def test_show_should_not_fail_when_custom_values_are_nil | |
385 | project = Project.find_by_identifier('ecookbook') |
|
377 | project = Project.find_by_identifier('ecookbook') | |
386 | project.custom_values.first.update_attribute(:value, nil) |
|
378 | project.custom_values.first.update_attribute(:value, nil) | |
387 | get :show, :id => 'ecookbook' |
|
379 | get :show, :id => 'ecookbook' | |
388 | assert_response :success |
|
380 | assert_response :success | |
389 | assert_template 'show' |
|
|||
390 | assert_not_nil assigns(:project) |
|
|||
391 | assert_equal Project.find_by_identifier('ecookbook'), assigns(:project) |
|
|||
392 | end |
|
381 | end | |
393 |
|
382 | |||
394 | def show_archived_project_should_be_denied |
|
383 | def show_archived_project_should_be_denied | |
395 | project = Project.find_by_identifier('ecookbook') |
|
384 | project = Project.find_by_identifier('ecookbook') | |
396 | project.archive! |
|
385 | project.archive! | |
397 |
|
386 | |||
398 | get :show, :id => 'ecookbook' |
|
387 | get :show, :id => 'ecookbook' | |
399 | assert_response 403 |
|
388 | assert_response 403 | |
400 | assert_nil assigns(:project) |
|
|||
401 | assert_select 'p', :text => /archived/ |
|
389 | assert_select 'p', :text => /archived/ | |
|
390 | assert_not_include project.name, response.body | |||
402 | end |
|
391 | end | |
403 |
|
392 | |||
404 | def test_show_should_not_show_private_subprojects_that_are_not_visible |
|
393 | def test_show_should_not_show_private_subprojects_that_are_not_visible | |
405 | get :show, :id => 'ecookbook' |
|
394 | get :show, :id => 'ecookbook' | |
406 | assert_response :success |
|
395 | assert_response :success | |
407 | assert_template 'show' |
|
|||
408 | assert_select 'a', :text => /Private child/, :count => 0 |
|
396 | assert_select 'a', :text => /Private child/, :count => 0 | |
409 | end |
|
397 | end | |
410 |
|
398 | |||
411 | def test_show_should_show_private_subprojects_that_are_visible |
|
399 | def test_show_should_show_private_subprojects_that_are_visible | |
412 | @request.session[:user_id] = 2 # manager who is a member of the private subproject |
|
400 | @request.session[:user_id] = 2 # manager who is a member of the private subproject | |
413 | get :show, :id => 'ecookbook' |
|
401 | get :show, :id => 'ecookbook' | |
414 | assert_response :success |
|
402 | assert_response :success | |
415 | assert_template 'show' |
|
|||
416 | assert_select 'a', :text => /Private child/ |
|
403 | assert_select 'a', :text => /Private child/ | |
417 | end |
|
404 | end | |
418 |
|
405 | |||
419 | def test_settings |
|
406 | def test_settings | |
420 | @request.session[:user_id] = 2 # manager |
|
407 | @request.session[:user_id] = 2 # manager | |
421 | get :settings, :id => 1 |
|
408 | get :settings, :id => 1 | |
422 | assert_response :success |
|
409 | assert_response :success | |
423 | assert_template 'settings' |
|
410 | ||
|
411 | assert_select 'input[name=?]', 'project[name]' | |||
424 | end |
|
412 | end | |
425 |
|
413 | |||
426 | def test_settings_of_subproject |
|
414 | def test_settings_of_subproject | |
427 | @request.session[:user_id] = 2 |
|
415 | @request.session[:user_id] = 2 | |
428 | get :settings, :id => 'private-child' |
|
416 | get :settings, :id => 'private-child' | |
429 | assert_response :success |
|
417 | assert_response :success | |
430 | assert_template 'settings' |
|
|||
431 |
|
418 | |||
432 | assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]' |
|
419 | assert_select 'input[type=checkbox][name=?]', 'project[inherit_members]' | |
433 | end |
|
420 | end | |
434 |
|
421 | |||
435 | def test_settings_should_be_denied_for_member_on_closed_project |
|
422 | def test_settings_should_be_denied_for_member_on_closed_project | |
436 | Project.find(1).close |
|
423 | Project.find(1).close | |
437 | @request.session[:user_id] = 2 # manager |
|
424 | @request.session[:user_id] = 2 # manager | |
438 |
|
425 | |||
439 | get :settings, :id => 1 |
|
426 | get :settings, :id => 1 | |
440 | assert_response 403 |
|
427 | assert_response 403 | |
441 | end |
|
428 | end | |
442 |
|
429 | |||
443 | def test_settings_should_be_denied_for_anonymous_on_closed_project |
|
430 | def test_settings_should_be_denied_for_anonymous_on_closed_project | |
444 | Project.find(1).close |
|
431 | Project.find(1).close | |
445 |
|
432 | |||
446 | get :settings, :id => 1 |
|
433 | get :settings, :id => 1 | |
447 | assert_response 302 |
|
434 | assert_response 302 | |
448 | end |
|
435 | end | |
449 |
|
436 | |||
450 | def test_setting_with_wiki_module_and_no_wiki |
|
437 | def test_setting_with_wiki_module_and_no_wiki | |
451 | Project.find(1).wiki.destroy |
|
438 | Project.find(1).wiki.destroy | |
452 | Role.find(1).add_permission! :manage_wiki |
|
439 | Role.find(1).add_permission! :manage_wiki | |
453 | @request.session[:user_id] = 2 |
|
440 | @request.session[:user_id] = 2 | |
454 |
|
441 | |||
455 | get :settings, :id => 1 |
|
442 | get :settings, :id => 1 | |
456 | assert_response :success |
|
443 | assert_response :success | |
457 | assert_template 'settings' |
|
|||
458 |
|
444 | |||
459 | assert_select 'form[action=?]', '/projects/ecookbook/wiki' do |
|
445 | assert_select 'form[action=?]', '/projects/ecookbook/wiki' do | |
460 | assert_select 'input[name=?]', 'wiki[start_page]' |
|
446 | assert_select 'input[name=?]', 'wiki[start_page]' | |
461 | end |
|
447 | end | |
462 | end |
|
448 | end | |
463 |
|
449 | |||
464 | def test_update |
|
450 | def test_update | |
465 | @request.session[:user_id] = 2 # manager |
|
451 | @request.session[:user_id] = 2 # manager | |
466 | post :update, :id => 1, :project => {:name => 'Test changed name', |
|
452 | post :update, :id => 1, :project => {:name => 'Test changed name', | |
467 | :issue_custom_field_ids => ['']} |
|
453 | :issue_custom_field_ids => ['']} | |
468 | assert_redirected_to '/projects/ecookbook/settings' |
|
454 | assert_redirected_to '/projects/ecookbook/settings' | |
469 | project = Project.find(1) |
|
455 | project = Project.find(1) | |
470 | assert_equal 'Test changed name', project.name |
|
456 | assert_equal 'Test changed name', project.name | |
471 | end |
|
457 | end | |
472 |
|
458 | |||
473 | def test_update_with_failure |
|
459 | def test_update_with_failure | |
474 | @request.session[:user_id] = 2 # manager |
|
460 | @request.session[:user_id] = 2 # manager | |
475 | post :update, :id => 1, :project => {:name => ''} |
|
461 | post :update, :id => 1, :project => {:name => ''} | |
476 | assert_response :success |
|
462 | assert_response :success | |
477 | assert_template 'settings' |
|
|||
478 | assert_select_error /name cannot be blank/i |
|
463 | assert_select_error /name cannot be blank/i | |
479 | end |
|
464 | end | |
480 |
|
465 | |||
481 | def test_update_should_be_denied_for_member_on_closed_project |
|
466 | def test_update_should_be_denied_for_member_on_closed_project | |
482 | Project.find(1).close |
|
467 | Project.find(1).close | |
483 | @request.session[:user_id] = 2 # manager |
|
468 | @request.session[:user_id] = 2 # manager | |
484 |
|
469 | |||
485 | post :update, :id => 1, :project => {:name => 'Closed'} |
|
470 | post :update, :id => 1, :project => {:name => 'Closed'} | |
486 | assert_response 403 |
|
471 | assert_response 403 | |
487 | assert_equal 'eCookbook', Project.find(1).name |
|
472 | assert_equal 'eCookbook', Project.find(1).name | |
488 | end |
|
473 | end | |
489 |
|
474 | |||
490 | def test_update_should_be_denied_for_anonymous_on_closed_project |
|
475 | def test_update_should_be_denied_for_anonymous_on_closed_project | |
491 | Project.find(1).close |
|
476 | Project.find(1).close | |
492 |
|
477 | |||
493 | post :update, :id => 1, :project => {:name => 'Closed'} |
|
478 | post :update, :id => 1, :project => {:name => 'Closed'} | |
494 | assert_response 302 |
|
479 | assert_response 302 | |
495 | assert_equal 'eCookbook', Project.find(1).name |
|
480 | assert_equal 'eCookbook', Project.find(1).name | |
496 | end |
|
481 | end | |
497 |
|
482 | |||
498 | def test_update_child_project_without_parent_permission_should_not_show_validation_error |
|
483 | def test_update_child_project_without_parent_permission_should_not_show_validation_error | |
499 | child = Project.generate_with_parent! |
|
484 | child = Project.generate_with_parent! | |
500 | user = User.generate! |
|
485 | user = User.generate! | |
501 | User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project])) |
|
486 | User.add_to_project(user, child, Role.generate!(:permissions => [:edit_project])) | |
502 | @request.session[:user_id] = user.id |
|
487 | @request.session[:user_id] = user.id | |
503 |
|
488 | |||
504 | post :update, :id => child.id, :project => {:name => 'Updated'} |
|
489 | post :update, :id => child.id, :project => {:name => 'Updated'} | |
505 | assert_response 302 |
|
490 | assert_response 302 | |
506 | assert_match /Successful update/, flash[:notice] |
|
491 | assert_match /Successful update/, flash[:notice] | |
507 | end |
|
492 | end | |
508 |
|
493 | |||
509 | def test_modules |
|
494 | def test_modules | |
510 | @request.session[:user_id] = 2 |
|
495 | @request.session[:user_id] = 2 | |
511 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] |
|
496 | Project.find(1).enabled_module_names = ['issue_tracking', 'news'] | |
512 |
|
497 | |||
513 | post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] |
|
498 | post :modules, :id => 1, :enabled_module_names => ['issue_tracking', 'repository', 'documents'] | |
514 | assert_redirected_to '/projects/ecookbook/settings/modules' |
|
499 | assert_redirected_to '/projects/ecookbook/settings/modules' | |
515 | assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort |
|
500 | assert_equal ['documents', 'issue_tracking', 'repository'], Project.find(1).enabled_module_names.sort | |
516 | end |
|
501 | end | |
517 |
|
502 | |||
518 | def test_destroy_leaf_project_without_confirmation_should_show_confirmation |
|
503 | def test_destroy_leaf_project_without_confirmation_should_show_confirmation | |
519 | @request.session[:user_id] = 1 # admin |
|
504 | @request.session[:user_id] = 1 # admin | |
520 |
|
505 | |||
521 | assert_no_difference 'Project.count' do |
|
506 | assert_no_difference 'Project.count' do | |
522 | delete :destroy, :id => 2 |
|
507 | delete :destroy, :id => 2 | |
523 | assert_response :success |
|
508 | assert_response :success | |
524 | assert_template 'destroy' |
|
|||
525 | end |
|
509 | end | |
|
510 | assert_select '.warning', :text => /Are you sure you want to delete this project/ | |||
526 | end |
|
511 | end | |
527 |
|
512 | |||
528 | def test_destroy_without_confirmation_should_show_confirmation_with_subprojects |
|
513 | def test_destroy_without_confirmation_should_show_confirmation_with_subprojects | |
529 | @request.session[:user_id] = 1 # admin |
|
514 | @request.session[:user_id] = 1 # admin | |
530 |
|
515 | |||
531 | assert_no_difference 'Project.count' do |
|
516 | assert_no_difference 'Project.count' do | |
532 | delete :destroy, :id => 1 |
|
517 | delete :destroy, :id => 1 | |
533 | assert_response :success |
|
518 | assert_response :success | |
534 | assert_template 'destroy' |
|
|||
535 | end |
|
519 | end | |
536 | assert_select 'strong', |
|
520 | assert_select 'strong', | |
537 | :text => ['Private child of eCookbook', |
|
521 | :text => ['Private child of eCookbook', | |
538 | 'Child of private child, eCookbook Subproject 1', |
|
522 | 'Child of private child, eCookbook Subproject 1', | |
539 | 'eCookbook Subproject 2'].join(', ') |
|
523 | 'eCookbook Subproject 2'].join(', ') | |
540 | end |
|
524 | end | |
541 |
|
525 | |||
542 | def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects |
|
526 | def test_destroy_with_confirmation_should_destroy_the_project_and_subprojects | |
543 | @request.session[:user_id] = 1 # admin |
|
527 | @request.session[:user_id] = 1 # admin | |
544 |
|
528 | |||
545 | assert_difference 'Project.count', -5 do |
|
529 | assert_difference 'Project.count', -5 do | |
546 | delete :destroy, :id => 1, :confirm => 1 |
|
530 | delete :destroy, :id => 1, :confirm => 1 | |
547 | assert_redirected_to '/admin/projects' |
|
531 | assert_redirected_to '/admin/projects' | |
548 | end |
|
532 | end | |
549 | assert_nil Project.find_by_id(1) |
|
533 | assert_nil Project.find_by_id(1) | |
550 | end |
|
534 | end | |
551 |
|
535 | |||
552 | def test_archive |
|
536 | def test_archive | |
553 | @request.session[:user_id] = 1 # admin |
|
537 | @request.session[:user_id] = 1 # admin | |
554 | post :archive, :id => 1 |
|
538 | post :archive, :id => 1 | |
555 | assert_redirected_to '/admin/projects' |
|
539 | assert_redirected_to '/admin/projects' | |
556 | assert !Project.find(1).active? |
|
540 | assert !Project.find(1).active? | |
557 | end |
|
541 | end | |
558 |
|
542 | |||
559 | def test_archive_with_failure |
|
543 | def test_archive_with_failure | |
560 | @request.session[:user_id] = 1 |
|
544 | @request.session[:user_id] = 1 | |
561 | Project.any_instance.stubs(:archive).returns(false) |
|
545 | Project.any_instance.stubs(:archive).returns(false) | |
562 | post :archive, :id => 1 |
|
546 | post :archive, :id => 1 | |
563 | assert_redirected_to '/admin/projects' |
|
547 | assert_redirected_to '/admin/projects' | |
564 | assert_match /project cannot be archived/i, flash[:error] |
|
548 | assert_match /project cannot be archived/i, flash[:error] | |
565 | end |
|
549 | end | |
566 |
|
550 | |||
567 | def test_unarchive |
|
551 | def test_unarchive | |
568 | @request.session[:user_id] = 1 # admin |
|
552 | @request.session[:user_id] = 1 # admin | |
569 | Project.find(1).archive |
|
553 | Project.find(1).archive | |
570 | post :unarchive, :id => 1 |
|
554 | post :unarchive, :id => 1 | |
571 | assert_redirected_to '/admin/projects' |
|
555 | assert_redirected_to '/admin/projects' | |
572 | assert Project.find(1).active? |
|
556 | assert Project.find(1).active? | |
573 | end |
|
557 | end | |
574 |
|
558 | |||
575 | def test_close |
|
559 | def test_close | |
576 | @request.session[:user_id] = 2 |
|
560 | @request.session[:user_id] = 2 | |
577 | post :close, :id => 1 |
|
561 | post :close, :id => 1 | |
578 | assert_redirected_to '/projects/ecookbook' |
|
562 | assert_redirected_to '/projects/ecookbook' | |
579 | assert_equal Project::STATUS_CLOSED, Project.find(1).status |
|
563 | assert_equal Project::STATUS_CLOSED, Project.find(1).status | |
580 | end |
|
564 | end | |
581 |
|
565 | |||
582 | def test_reopen |
|
566 | def test_reopen | |
583 | Project.find(1).close |
|
567 | Project.find(1).close | |
584 | @request.session[:user_id] = 2 |
|
568 | @request.session[:user_id] = 2 | |
585 | post :reopen, :id => 1 |
|
569 | post :reopen, :id => 1 | |
586 | assert_redirected_to '/projects/ecookbook' |
|
570 | assert_redirected_to '/projects/ecookbook' | |
587 | assert Project.find(1).active? |
|
571 | assert Project.find(1).active? | |
588 | end |
|
572 | end | |
589 |
|
573 | |||
590 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors |
|
574 | def test_project_breadcrumbs_should_be_limited_to_3_ancestors | |
591 | CustomField.delete_all |
|
575 | CustomField.delete_all | |
592 | parent = nil |
|
576 | parent = nil | |
593 | 6.times do |i| |
|
577 | 6.times do |i| | |
594 | p = Project.generate_with_parent!(parent) |
|
578 | p = Project.generate_with_parent!(parent) | |
595 | get :show, :id => p |
|
579 | get :show, :id => p | |
596 | assert_select '#header h1' do |
|
580 | assert_select '#header h1' do | |
597 | assert_select 'a', :count => [i, 3].min |
|
581 | assert_select 'a', :count => [i, 3].min | |
598 | end |
|
582 | end | |
599 |
|
583 | |||
600 | parent = p |
|
584 | parent = p | |
601 | end |
|
585 | end | |
602 | end |
|
586 | end | |
603 |
|
587 | |||
604 | def test_get_copy |
|
588 | def test_get_copy | |
605 | @request.session[:user_id] = 1 # admin |
|
589 | @request.session[:user_id] = 1 # admin | |
606 | get :copy, :id => 1 |
|
590 | orig = Project.find(1) | |
|
591 | ||||
|
592 | get :copy, :id => orig.id | |||
607 | assert_response :success |
|
593 | assert_response :success | |
608 | assert_template 'copy' |
|
|||
609 | assert assigns(:project) |
|
|||
610 | assert_equal Project.find(1).description, assigns(:project).description |
|
|||
611 | assert_nil assigns(:project).id |
|
|||
612 |
|
594 | |||
|
595 | assert_select 'textarea[name=?]', 'project[description]', :text => orig.description | |||
613 | assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1 |
|
596 | assert_select 'input[name=?][value=?]', 'project[enabled_module_names][]', 'issue_tracking', 1 | |
614 | end |
|
597 | end | |
615 |
|
598 | |||
616 | def test_get_copy_with_invalid_source_should_respond_with_404 |
|
599 | def test_get_copy_with_invalid_source_should_respond_with_404 | |
617 | @request.session[:user_id] = 1 |
|
600 | @request.session[:user_id] = 1 | |
618 | get :copy, :id => 99 |
|
601 | get :copy, :id => 99 | |
619 | assert_response 404 |
|
602 | assert_response 404 | |
620 | end |
|
603 | end | |
621 |
|
604 | |||
622 | def test_get_copy_should_preselect_custom_fields |
|
605 | def test_get_copy_should_preselect_custom_fields | |
623 | field1 = IssueCustomField.generate!(:is_for_all => false) |
|
606 | field1 = IssueCustomField.generate!(:is_for_all => false) | |
624 | field2 = IssueCustomField.generate!(:is_for_all => false) |
|
607 | field2 = IssueCustomField.generate!(:is_for_all => false) | |
625 | source = Project.generate!(:issue_custom_fields => [field1]) |
|
608 | source = Project.generate!(:issue_custom_fields => [field1]) | |
626 | @request.session[:user_id] = 1 |
|
609 | @request.session[:user_id] = 1 | |
627 |
|
610 | |||
628 | get :copy, :id => source.id |
|
611 | get :copy, :id => source.id | |
629 | assert_response :success |
|
612 | assert_response :success | |
630 | assert_select 'fieldset#project_issue_custom_fields' do |
|
613 | assert_select 'fieldset#project_issue_custom_fields' do | |
631 | assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s |
|
614 | assert_select 'input[type=checkbox][value=?][checked=checked]', field1.id.to_s | |
632 | assert_select 'input[type=checkbox][value=?]:not([checked])', field2.id.to_s |
|
615 | assert_select 'input[type=checkbox][value=?]:not([checked])', field2.id.to_s | |
633 | end |
|
616 | end | |
634 | end |
|
617 | end | |
635 |
|
618 | |||
636 | def test_post_copy_should_copy_requested_items |
|
619 | def test_post_copy_should_copy_requested_items | |
637 | @request.session[:user_id] = 1 # admin |
|
620 | @request.session[:user_id] = 1 # admin | |
638 | CustomField.delete_all |
|
621 | CustomField.delete_all | |
639 |
|
622 | |||
640 | assert_difference 'Project.count' do |
|
623 | assert_difference 'Project.count' do | |
641 | post :copy, :id => 1, |
|
624 | post :copy, :id => 1, | |
642 | :project => { |
|
625 | :project => { | |
643 | :name => 'Copy', |
|
626 | :name => 'Copy', | |
644 | :identifier => 'unique-copy', |
|
627 | :identifier => 'unique-copy', | |
645 | :tracker_ids => ['1', '2', '3', ''], |
|
628 | :tracker_ids => ['1', '2', '3', ''], | |
646 | :enabled_module_names => %w(issue_tracking time_tracking) |
|
629 | :enabled_module_names => %w(issue_tracking time_tracking) | |
647 | }, |
|
630 | }, | |
648 | :only => %w(issues versions) |
|
631 | :only => %w(issues versions) | |
649 | end |
|
632 | end | |
650 | project = Project.find('unique-copy') |
|
633 | project = Project.find('unique-copy') | |
651 | source = Project.find(1) |
|
634 | source = Project.find(1) | |
652 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort |
|
635 | assert_equal %w(issue_tracking time_tracking), project.enabled_module_names.sort | |
653 |
|
636 | |||
654 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" |
|
637 | assert_equal source.versions.count, project.versions.count, "All versions were not copied" | |
655 | assert_equal source.issues.count, project.issues.count, "All issues were not copied" |
|
638 | assert_equal source.issues.count, project.issues.count, "All issues were not copied" | |
656 | assert_equal 0, project.members.count |
|
639 | assert_equal 0, project.members.count | |
657 | end |
|
640 | end | |
658 |
|
641 | |||
659 | def test_post_copy_should_redirect_to_settings_when_successful |
|
642 | def test_post_copy_should_redirect_to_settings_when_successful | |
660 | @request.session[:user_id] = 1 # admin |
|
643 | @request.session[:user_id] = 1 # admin | |
661 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} |
|
644 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => 'unique-copy'} | |
662 | assert_response :redirect |
|
645 | assert_response :redirect | |
663 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' |
|
646 | assert_redirected_to :controller => 'projects', :action => 'settings', :id => 'unique-copy' | |
664 | end |
|
647 | end | |
665 |
|
648 | |||
666 | def test_post_copy_with_failure |
|
649 | def test_post_copy_with_failure | |
667 | @request.session[:user_id] = 1 |
|
650 | @request.session[:user_id] = 1 | |
668 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => ''} |
|
651 | post :copy, :id => 1, :project => {:name => 'Copy', :identifier => ''} | |
669 | assert_response :success |
|
652 | assert_response :success | |
670 | assert_template 'copy' |
|
653 | assert_select_error /Identifier cannot be blank/ | |
671 | end |
|
654 | end | |
672 |
|
655 | |||
673 | def test_jump_should_redirect_to_active_tab |
|
656 | def test_jump_should_redirect_to_active_tab | |
674 | get :show, :id => 1, :jump => 'issues' |
|
657 | get :show, :id => 1, :jump => 'issues' | |
675 | assert_redirected_to '/projects/ecookbook/issues' |
|
658 | assert_redirected_to '/projects/ecookbook/issues' | |
676 | end |
|
659 | end | |
677 |
|
660 | |||
678 | def test_jump_should_not_redirect_to_inactive_tab |
|
661 | def test_jump_should_not_redirect_to_inactive_tab | |
679 | get :show, :id => 3, :jump => 'documents' |
|
662 | get :show, :id => 3, :jump => 'documents' | |
680 | assert_response :success |
|
663 | assert_response :success | |
681 | assert_template 'show' |
|
|||
682 | end |
|
664 | end | |
683 |
|
665 | |||
684 | def test_jump_should_not_redirect_to_unknown_tab |
|
666 | def test_jump_should_not_redirect_to_unknown_tab | |
685 | get :show, :id => 3, :jump => 'foobar' |
|
667 | get :show, :id => 3, :jump => 'foobar' | |
686 | assert_response :success |
|
668 | assert_response :success | |
687 | assert_template 'show' |
|
|||
688 | end |
|
669 | end | |
689 |
|
670 | |||
690 | def test_body_should_have_project_css_class |
|
671 | def test_body_should_have_project_css_class | |
691 | get :show, :id => 1 |
|
672 | get :show, :id => 1 | |
692 | assert_select 'body.project-ecookbook' |
|
673 | assert_select 'body.project-ecookbook' | |
693 | end |
|
674 | end | |
694 | end |
|
675 | end |
@@ -1,401 +1,400 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class QueriesControllerTest < Redmine::ControllerTest |
|
20 | class QueriesControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries, :enabled_modules |
|
21 | fixtures :projects, :users, :members, :member_roles, :roles, :trackers, :issue_statuses, :issue_categories, :enumerations, :issues, :custom_fields, :custom_values, :queries, :enabled_modules | |
22 |
|
22 | |||
23 | def setup |
|
23 | def setup | |
24 | User.current = nil |
|
24 | User.current = nil | |
25 | end |
|
25 | end | |
26 |
|
26 | |||
27 | def test_index |
|
27 | def test_index | |
28 | get :index |
|
28 | get :index | |
29 | # HTML response not implemented |
|
29 | # HTML response not implemented | |
30 | assert_response 406 |
|
30 | assert_response 406 | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_new_project_query |
|
33 | def test_new_project_query | |
34 | @request.session[:user_id] = 2 |
|
34 | @request.session[:user_id] = 2 | |
35 | get :new, :project_id => 1 |
|
35 | get :new, :project_id => 1 | |
36 | assert_response :success |
|
36 | assert_response :success | |
37 | assert_template 'new' |
|
37 | ||
38 | assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]' |
|
38 | assert_select 'input[name=?][value="0"][checked=checked]', 'query[visibility]' | |
39 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])' |
|
39 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])' | |
40 | assert_select 'select[name=?]', 'c[]' do |
|
40 | assert_select 'select[name=?]', 'c[]' do | |
41 | assert_select 'option[value=tracker]' |
|
41 | assert_select 'option[value=tracker]' | |
42 | assert_select 'option[value=subject]' |
|
42 | assert_select 'option[value=subject]' | |
43 | end |
|
43 | end | |
44 | end |
|
44 | end | |
45 |
|
45 | |||
46 | def test_new_global_query |
|
46 | def test_new_global_query | |
47 | @request.session[:user_id] = 2 |
|
47 | @request.session[:user_id] = 2 | |
48 | get :new |
|
48 | get :new | |
49 | assert_response :success |
|
49 | assert_response :success | |
50 | assert_template 'new' |
|
50 | ||
51 | assert_select 'input[name=?]', 'query[visibility]', 0 |
|
51 | assert_select 'input[name=?]', 'query[visibility]', 0 | |
52 | assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])' |
|
52 | assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])' | |
53 | end |
|
53 | end | |
54 |
|
54 | |||
55 | def test_new_on_invalid_project |
|
55 | def test_new_on_invalid_project | |
56 | @request.session[:user_id] = 2 |
|
56 | @request.session[:user_id] = 2 | |
57 | get :new, :project_id => 'invalid' |
|
57 | get :new, :project_id => 'invalid' | |
58 | assert_response 404 |
|
58 | assert_response 404 | |
59 | end |
|
59 | end | |
60 |
|
60 | |||
61 | def test_new_time_entry_query |
|
61 | def test_new_time_entry_query | |
62 | @request.session[:user_id] = 2 |
|
62 | @request.session[:user_id] = 2 | |
63 | get :new, :project_id => 1, :type => 'TimeEntryQuery' |
|
63 | get :new, :project_id => 1, :type => 'TimeEntryQuery' | |
64 | assert_response :success |
|
64 | assert_response :success | |
65 | assert_select 'input[name=type][value=?]', 'TimeEntryQuery' |
|
65 | assert_select 'input[name=type][value=?]', 'TimeEntryQuery' | |
66 | end |
|
66 | end | |
67 |
|
67 | |||
68 | def test_create_project_public_query |
|
68 | def test_create_project_public_query | |
69 | @request.session[:user_id] = 2 |
|
69 | @request.session[:user_id] = 2 | |
70 | post :create, |
|
70 | post :create, | |
71 | :project_id => 'ecookbook', |
|
71 | :project_id => 'ecookbook', | |
72 | :default_columns => '1', |
|
72 | :default_columns => '1', | |
73 | :f => ["status_id", "assigned_to_id"], |
|
73 | :f => ["status_id", "assigned_to_id"], | |
74 | :op => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
74 | :op => {"assigned_to_id" => "=", "status_id" => "o"}, | |
75 | :v => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, |
|
75 | :v => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, | |
76 | :query => {"name" => "test_new_project_public_query", "visibility" => "2"} |
|
76 | :query => {"name" => "test_new_project_public_query", "visibility" => "2"} | |
77 |
|
77 | |||
78 | q = Query.find_by_name('test_new_project_public_query') |
|
78 | q = Query.find_by_name('test_new_project_public_query') | |
79 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q |
|
79 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q | |
80 | assert q.is_public? |
|
80 | assert q.is_public? | |
81 | assert q.has_default_columns? |
|
81 | assert q.has_default_columns? | |
82 | assert q.valid? |
|
82 | assert q.valid? | |
83 | end |
|
83 | end | |
84 |
|
84 | |||
85 | def test_create_project_private_query |
|
85 | def test_create_project_private_query | |
86 | @request.session[:user_id] = 3 |
|
86 | @request.session[:user_id] = 3 | |
87 | post :create, |
|
87 | post :create, | |
88 | :project_id => 'ecookbook', |
|
88 | :project_id => 'ecookbook', | |
89 | :default_columns => '1', |
|
89 | :default_columns => '1', | |
90 | :fields => ["status_id", "assigned_to_id"], |
|
90 | :fields => ["status_id", "assigned_to_id"], | |
91 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
91 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, | |
92 | :values => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, |
|
92 | :values => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, | |
93 | :query => {"name" => "test_new_project_private_query", "visibility" => "0"} |
|
93 | :query => {"name" => "test_new_project_private_query", "visibility" => "0"} | |
94 |
|
94 | |||
95 | q = Query.find_by_name('test_new_project_private_query') |
|
95 | q = Query.find_by_name('test_new_project_private_query') | |
96 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q |
|
96 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q | |
97 | assert !q.is_public? |
|
97 | assert !q.is_public? | |
98 | assert q.has_default_columns? |
|
98 | assert q.has_default_columns? | |
99 | assert q.valid? |
|
99 | assert q.valid? | |
100 | end |
|
100 | end | |
101 |
|
101 | |||
102 | def test_create_project_roles_query |
|
102 | def test_create_project_roles_query | |
103 | @request.session[:user_id] = 2 |
|
103 | @request.session[:user_id] = 2 | |
104 | post :create, |
|
104 | post :create, | |
105 | :project_id => 'ecookbook', |
|
105 | :project_id => 'ecookbook', | |
106 | :default_columns => '1', |
|
106 | :default_columns => '1', | |
107 | :fields => ["status_id", "assigned_to_id"], |
|
107 | :fields => ["status_id", "assigned_to_id"], | |
108 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
108 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, | |
109 | :values => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, |
|
109 | :values => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, | |
110 | :query => {"name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]} |
|
110 | :query => {"name" => "test_create_project_roles_query", "visibility" => "1", "role_ids" => ["1", "2", ""]} | |
111 |
|
111 | |||
112 | q = Query.find_by_name('test_create_project_roles_query') |
|
112 | q = Query.find_by_name('test_create_project_roles_query') | |
113 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q |
|
113 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :query_id => q | |
114 | assert_equal Query::VISIBILITY_ROLES, q.visibility |
|
114 | assert_equal Query::VISIBILITY_ROLES, q.visibility | |
115 | assert_equal [1, 2], q.roles.ids.sort |
|
115 | assert_equal [1, 2], q.roles.ids.sort | |
116 | end |
|
116 | end | |
117 |
|
117 | |||
118 | def test_create_global_private_query_with_custom_columns |
|
118 | def test_create_global_private_query_with_custom_columns | |
119 | @request.session[:user_id] = 3 |
|
119 | @request.session[:user_id] = 3 | |
120 | post :create, |
|
120 | post :create, | |
121 | :fields => ["status_id", "assigned_to_id"], |
|
121 | :fields => ["status_id", "assigned_to_id"], | |
122 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
122 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, | |
123 | :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, |
|
123 | :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, | |
124 | :query => {"name" => "test_new_global_private_query", "visibility" => "0"}, |
|
124 | :query => {"name" => "test_new_global_private_query", "visibility" => "0"}, | |
125 | :c => ["", "tracker", "subject", "priority", "category"] |
|
125 | :c => ["", "tracker", "subject", "priority", "category"] | |
126 |
|
126 | |||
127 | q = Query.find_by_name('test_new_global_private_query') |
|
127 | q = Query.find_by_name('test_new_global_private_query') | |
128 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q |
|
128 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q | |
129 | assert !q.is_public? |
|
129 | assert !q.is_public? | |
130 | assert !q.has_default_columns? |
|
130 | assert !q.has_default_columns? | |
131 | assert_equal [:id, :tracker, :subject, :priority, :category], q.columns.collect {|c| c.name} |
|
131 | assert_equal [:id, :tracker, :subject, :priority, :category], q.columns.collect {|c| c.name} | |
132 | assert q.valid? |
|
132 | assert q.valid? | |
133 | end |
|
133 | end | |
134 |
|
134 | |||
135 | def test_create_global_query_with_custom_filters |
|
135 | def test_create_global_query_with_custom_filters | |
136 | @request.session[:user_id] = 3 |
|
136 | @request.session[:user_id] = 3 | |
137 | post :create, |
|
137 | post :create, | |
138 | :fields => ["assigned_to_id"], |
|
138 | :fields => ["assigned_to_id"], | |
139 | :operators => {"assigned_to_id" => "="}, |
|
139 | :operators => {"assigned_to_id" => "="}, | |
140 | :values => { "assigned_to_id" => ["me"]}, |
|
140 | :values => { "assigned_to_id" => ["me"]}, | |
141 | :query => {"name" => "test_new_global_query"} |
|
141 | :query => {"name" => "test_new_global_query"} | |
142 |
|
142 | |||
143 | q = Query.find_by_name('test_new_global_query') |
|
143 | q = Query.find_by_name('test_new_global_query') | |
144 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q |
|
144 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => nil, :query_id => q | |
145 | assert !q.is_public? |
|
145 | assert !q.is_public? | |
146 | assert !q.has_filter?(:status_id) |
|
146 | assert !q.has_filter?(:status_id) | |
147 | assert_equal ['assigned_to_id'], q.filters.keys |
|
147 | assert_equal ['assigned_to_id'], q.filters.keys | |
148 | assert q.valid? |
|
148 | assert q.valid? | |
149 | end |
|
149 | end | |
150 |
|
150 | |||
151 | def test_create_with_sort |
|
151 | def test_create_with_sort | |
152 | @request.session[:user_id] = 1 |
|
152 | @request.session[:user_id] = 1 | |
153 | post :create, |
|
153 | post :create, | |
154 | :default_columns => '1', |
|
154 | :default_columns => '1', | |
155 | :operators => {"status_id" => "o"}, |
|
155 | :operators => {"status_id" => "o"}, | |
156 | :values => {"status_id" => ["1"]}, |
|
156 | :values => {"status_id" => ["1"]}, | |
157 | :query => {:name => "test_new_with_sort", |
|
157 | :query => {:name => "test_new_with_sort", | |
158 | :visibility => "2", |
|
158 | :visibility => "2", | |
159 | :sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}} |
|
159 | :sort_criteria => {"0" => ["due_date", "desc"], "1" => ["tracker", ""]}} | |
160 |
|
160 | |||
161 | query = Query.find_by_name("test_new_with_sort") |
|
161 | query = Query.find_by_name("test_new_with_sort") | |
162 | assert_not_nil query |
|
162 | assert_not_nil query | |
163 | assert_equal [['due_date', 'desc'], ['tracker', 'asc']], query.sort_criteria |
|
163 | assert_equal [['due_date', 'desc'], ['tracker', 'asc']], query.sort_criteria | |
164 | end |
|
164 | end | |
165 |
|
165 | |||
166 | def test_create_with_failure |
|
166 | def test_create_with_failure | |
167 | @request.session[:user_id] = 2 |
|
167 | @request.session[:user_id] = 2 | |
168 | assert_no_difference '::Query.count' do |
|
168 | assert_no_difference '::Query.count' do | |
169 | post :create, :project_id => 'ecookbook', :query => {:name => ''} |
|
169 | post :create, :project_id => 'ecookbook', :query => {:name => ''} | |
170 | end |
|
170 | end | |
171 | assert_response :success |
|
171 | assert_response :success | |
172 | assert_template 'new' |
|
172 | ||
173 | assert_select 'input[name=?]', 'query[name]' |
|
173 | assert_select 'input[name=?]', 'query[name]' | |
174 | end |
|
174 | end | |
175 |
|
175 | |||
176 | def test_create_global_query_from_gantt |
|
176 | def test_create_global_query_from_gantt | |
177 | @request.session[:user_id] = 1 |
|
177 | @request.session[:user_id] = 1 | |
178 | assert_difference 'IssueQuery.count' do |
|
178 | assert_difference 'IssueQuery.count' do | |
179 | post :create, |
|
179 | post :create, | |
180 | :gantt => 1, |
|
180 | :gantt => 1, | |
181 | :operators => {"status_id" => "o"}, |
|
181 | :operators => {"status_id" => "o"}, | |
182 | :values => {"status_id" => ["1"]}, |
|
182 | :values => {"status_id" => ["1"]}, | |
183 | :query => {:name => "test_create_from_gantt", |
|
183 | :query => {:name => "test_create_from_gantt", | |
184 | :draw_relations => '1', |
|
184 | :draw_relations => '1', | |
185 | :draw_progress_line => '1'} |
|
185 | :draw_progress_line => '1'} | |
186 | assert_response 302 |
|
186 | assert_response 302 | |
187 | end |
|
187 | end | |
188 | query = IssueQuery.order('id DESC').first |
|
188 | query = IssueQuery.order('id DESC').first | |
189 | assert_redirected_to "/issues/gantt?query_id=#{query.id}" |
|
189 | assert_redirected_to "/issues/gantt?query_id=#{query.id}" | |
190 | assert_equal true, query.draw_relations |
|
190 | assert_equal true, query.draw_relations | |
191 | assert_equal true, query.draw_progress_line |
|
191 | assert_equal true, query.draw_progress_line | |
192 | end |
|
192 | end | |
193 |
|
193 | |||
194 | def test_create_project_query_from_gantt |
|
194 | def test_create_project_query_from_gantt | |
195 | @request.session[:user_id] = 1 |
|
195 | @request.session[:user_id] = 1 | |
196 | assert_difference 'IssueQuery.count' do |
|
196 | assert_difference 'IssueQuery.count' do | |
197 | post :create, |
|
197 | post :create, | |
198 | :project_id => 'ecookbook', |
|
198 | :project_id => 'ecookbook', | |
199 | :gantt => 1, |
|
199 | :gantt => 1, | |
200 | :operators => {"status_id" => "o"}, |
|
200 | :operators => {"status_id" => "o"}, | |
201 | :values => {"status_id" => ["1"]}, |
|
201 | :values => {"status_id" => ["1"]}, | |
202 | :query => {:name => "test_create_from_gantt", |
|
202 | :query => {:name => "test_create_from_gantt", | |
203 | :draw_relations => '0', |
|
203 | :draw_relations => '0', | |
204 | :draw_progress_line => '0'} |
|
204 | :draw_progress_line => '0'} | |
205 | assert_response 302 |
|
205 | assert_response 302 | |
206 | end |
|
206 | end | |
207 | query = IssueQuery.order('id DESC').first |
|
207 | query = IssueQuery.order('id DESC').first | |
208 | assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}" |
|
208 | assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}" | |
209 | assert_equal false, query.draw_relations |
|
209 | assert_equal false, query.draw_relations | |
210 | assert_equal false, query.draw_progress_line |
|
210 | assert_equal false, query.draw_progress_line | |
211 | end |
|
211 | end | |
212 |
|
212 | |||
213 | def test_create_project_public_query_should_force_private_without_manage_public_queries_permission |
|
213 | def test_create_project_public_query_should_force_private_without_manage_public_queries_permission | |
214 | @request.session[:user_id] = 3 |
|
214 | @request.session[:user_id] = 3 | |
215 | query = new_record(Query) do |
|
215 | query = new_record(Query) do | |
216 | post :create, |
|
216 | post :create, | |
217 | :project_id => 'ecookbook', |
|
217 | :project_id => 'ecookbook', | |
218 | :query => {"name" => "name", "visibility" => "2"} |
|
218 | :query => {"name" => "name", "visibility" => "2"} | |
219 | assert_response 302 |
|
219 | assert_response 302 | |
220 | end |
|
220 | end | |
221 | assert_not_nil query.project |
|
221 | assert_not_nil query.project | |
222 | assert_equal Query::VISIBILITY_PRIVATE, query.visibility |
|
222 | assert_equal Query::VISIBILITY_PRIVATE, query.visibility | |
223 | end |
|
223 | end | |
224 |
|
224 | |||
225 | def test_create_global_public_query_should_force_private_without_manage_public_queries_permission |
|
225 | def test_create_global_public_query_should_force_private_without_manage_public_queries_permission | |
226 | @request.session[:user_id] = 3 |
|
226 | @request.session[:user_id] = 3 | |
227 | query = new_record(Query) do |
|
227 | query = new_record(Query) do | |
228 | post :create, |
|
228 | post :create, | |
229 | :project_id => 'ecookbook', :query_is_for_all => '1', |
|
229 | :project_id => 'ecookbook', :query_is_for_all => '1', | |
230 | :query => {"name" => "name", "visibility" => "2"} |
|
230 | :query => {"name" => "name", "visibility" => "2"} | |
231 | assert_response 302 |
|
231 | assert_response 302 | |
232 | end |
|
232 | end | |
233 | assert_nil query.project |
|
233 | assert_nil query.project | |
234 | assert_equal Query::VISIBILITY_PRIVATE, query.visibility |
|
234 | assert_equal Query::VISIBILITY_PRIVATE, query.visibility | |
235 | end |
|
235 | end | |
236 |
|
236 | |||
237 | def test_create_project_public_query_with_manage_public_queries_permission |
|
237 | def test_create_project_public_query_with_manage_public_queries_permission | |
238 | @request.session[:user_id] = 2 |
|
238 | @request.session[:user_id] = 2 | |
239 | query = new_record(Query) do |
|
239 | query = new_record(Query) do | |
240 | post :create, |
|
240 | post :create, | |
241 | :project_id => 'ecookbook', |
|
241 | :project_id => 'ecookbook', | |
242 | :query => {"name" => "name", "visibility" => "2"} |
|
242 | :query => {"name" => "name", "visibility" => "2"} | |
243 | assert_response 302 |
|
243 | assert_response 302 | |
244 | end |
|
244 | end | |
245 | assert_not_nil query.project |
|
245 | assert_not_nil query.project | |
246 | assert_equal Query::VISIBILITY_PUBLIC, query.visibility |
|
246 | assert_equal Query::VISIBILITY_PUBLIC, query.visibility | |
247 | end |
|
247 | end | |
248 |
|
248 | |||
249 | def test_create_global_public_query_should_force_private_with_manage_public_queries_permission |
|
249 | def test_create_global_public_query_should_force_private_with_manage_public_queries_permission | |
250 | @request.session[:user_id] = 2 |
|
250 | @request.session[:user_id] = 2 | |
251 | query = new_record(Query) do |
|
251 | query = new_record(Query) do | |
252 | post :create, |
|
252 | post :create, | |
253 | :project_id => 'ecookbook', :query_is_for_all => '1', |
|
253 | :project_id => 'ecookbook', :query_is_for_all => '1', | |
254 | :query => {"name" => "name", "visibility" => "2"} |
|
254 | :query => {"name" => "name", "visibility" => "2"} | |
255 | assert_response 302 |
|
255 | assert_response 302 | |
256 | end |
|
256 | end | |
257 | assert_nil query.project |
|
257 | assert_nil query.project | |
258 | assert_equal Query::VISIBILITY_PRIVATE, query.visibility |
|
258 | assert_equal Query::VISIBILITY_PRIVATE, query.visibility | |
259 | end |
|
259 | end | |
260 |
|
260 | |||
261 | def test_create_global_public_query_by_admin |
|
261 | def test_create_global_public_query_by_admin | |
262 | @request.session[:user_id] = 1 |
|
262 | @request.session[:user_id] = 1 | |
263 | query = new_record(Query) do |
|
263 | query = new_record(Query) do | |
264 | post :create, |
|
264 | post :create, | |
265 | :project_id => 'ecookbook', :query_is_for_all => '1', |
|
265 | :project_id => 'ecookbook', :query_is_for_all => '1', | |
266 | :query => {"name" => "name", "visibility" => "2"} |
|
266 | :query => {"name" => "name", "visibility" => "2"} | |
267 | assert_response 302 |
|
267 | assert_response 302 | |
268 | end |
|
268 | end | |
269 | assert_nil query.project |
|
269 | assert_nil query.project | |
270 | assert_equal Query::VISIBILITY_PUBLIC, query.visibility |
|
270 | assert_equal Query::VISIBILITY_PUBLIC, query.visibility | |
271 | end |
|
271 | end | |
272 |
|
272 | |||
273 | def test_create_project_public_time_entry_query |
|
273 | def test_create_project_public_time_entry_query | |
274 | @request.session[:user_id] = 2 |
|
274 | @request.session[:user_id] = 2 | |
275 |
|
275 | |||
276 | q = new_record(TimeEntryQuery) do |
|
276 | q = new_record(TimeEntryQuery) do | |
277 | post :create, |
|
277 | post :create, | |
278 | :project_id => 'ecookbook', |
|
278 | :project_id => 'ecookbook', | |
279 | :type => 'TimeEntryQuery', |
|
279 | :type => 'TimeEntryQuery', | |
280 | :default_columns => '1', |
|
280 | :default_columns => '1', | |
281 | :f => ["spent_on"], |
|
281 | :f => ["spent_on"], | |
282 | :op => {"spent_on" => "="}, |
|
282 | :op => {"spent_on" => "="}, | |
283 | :v => { "spent_on" => ["2016-07-14"]}, |
|
283 | :v => { "spent_on" => ["2016-07-14"]}, | |
284 | :query => {"name" => "test_new_project_public_query", "visibility" => "2"} |
|
284 | :query => {"name" => "test_new_project_public_query", "visibility" => "2"} | |
285 | end |
|
285 | end | |
286 |
|
286 | |||
287 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :query_id => q.id |
|
287 | assert_redirected_to :controller => 'timelog', :action => 'index', :project_id => 'ecookbook', :query_id => q.id | |
288 | assert q.is_public? |
|
288 | assert q.is_public? | |
289 | assert q.has_default_columns? |
|
289 | assert q.has_default_columns? | |
290 | assert q.valid? |
|
290 | assert q.valid? | |
291 | end |
|
291 | end | |
292 |
|
292 | |||
293 | def test_edit_global_public_query |
|
293 | def test_edit_global_public_query | |
294 | @request.session[:user_id] = 1 |
|
294 | @request.session[:user_id] = 1 | |
295 | get :edit, :id => 4 |
|
295 | get :edit, :id => 4 | |
296 | assert_response :success |
|
296 | assert_response :success | |
297 | assert_template 'edit' |
|
297 | ||
298 | assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' |
|
298 | assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' | |
299 | assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]' |
|
299 | assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]' | |
300 | end |
|
300 | end | |
301 |
|
301 | |||
302 | def test_edit_global_private_query |
|
302 | def test_edit_global_private_query | |
303 | @request.session[:user_id] = 3 |
|
303 | @request.session[:user_id] = 3 | |
304 | get :edit, :id => 3 |
|
304 | get :edit, :id => 3 | |
305 | assert_response :success |
|
305 | assert_response :success | |
306 | assert_template 'edit' |
|
306 | ||
307 | assert_select 'input[name=?]', 'query[visibility]', 0 |
|
307 | assert_select 'input[name=?]', 'query[visibility]', 0 | |
308 | assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]' |
|
308 | assert_select 'input[name=query_is_for_all][type=checkbox][checked=checked]' | |
309 | end |
|
309 | end | |
310 |
|
310 | |||
311 | def test_edit_project_private_query |
|
311 | def test_edit_project_private_query | |
312 | @request.session[:user_id] = 3 |
|
312 | @request.session[:user_id] = 3 | |
313 | get :edit, :id => 2 |
|
313 | get :edit, :id => 2 | |
314 | assert_response :success |
|
314 | assert_response :success | |
315 | assert_template 'edit' |
|
315 | ||
316 | assert_select 'input[name=?]', 'query[visibility]', 0 |
|
316 | assert_select 'input[name=?]', 'query[visibility]', 0 | |
317 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])' |
|
317 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])' | |
318 | end |
|
318 | end | |
319 |
|
319 | |||
320 | def test_edit_project_public_query |
|
320 | def test_edit_project_public_query | |
321 | @request.session[:user_id] = 2 |
|
321 | @request.session[:user_id] = 2 | |
322 | get :edit, :id => 1 |
|
322 | get :edit, :id => 1 | |
323 | assert_response :success |
|
323 | assert_response :success | |
324 | assert_template 'edit' |
|
324 | ||
325 | assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' |
|
325 | assert_select 'input[name=?][value="2"][checked=checked]', 'query[visibility]' | |
326 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])' |
|
326 | assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked])' | |
327 | end |
|
327 | end | |
328 |
|
328 | |||
329 | def test_edit_sort_criteria |
|
329 | def test_edit_sort_criteria | |
330 | @request.session[:user_id] = 1 |
|
330 | @request.session[:user_id] = 1 | |
331 | get :edit, :id => 5 |
|
331 | get :edit, :id => 5 | |
332 | assert_response :success |
|
332 | assert_response :success | |
333 | assert_template 'edit' |
|
333 | ||
334 | assert_select 'select[name=?]', 'query[sort_criteria][0][]' do |
|
334 | assert_select 'select[name=?]', 'query[sort_criteria][0][]' do | |
335 | assert_select 'option[value=priority][selected=selected]' |
|
335 | assert_select 'option[value=priority][selected=selected]' | |
336 | assert_select 'option[value=desc][selected=selected]' |
|
336 | assert_select 'option[value=desc][selected=selected]' | |
337 | end |
|
337 | end | |
338 | end |
|
338 | end | |
339 |
|
339 | |||
340 | def test_edit_invalid_query |
|
340 | def test_edit_invalid_query | |
341 | @request.session[:user_id] = 2 |
|
341 | @request.session[:user_id] = 2 | |
342 | get :edit, :id => 99 |
|
342 | get :edit, :id => 99 | |
343 | assert_response 404 |
|
343 | assert_response 404 | |
344 | end |
|
344 | end | |
345 |
|
345 | |||
346 | def test_udpate_global_private_query |
|
346 | def test_udpate_global_private_query | |
347 | @request.session[:user_id] = 3 |
|
347 | @request.session[:user_id] = 3 | |
348 | put :update, |
|
348 | put :update, | |
349 | :id => 3, |
|
349 | :id => 3, | |
350 | :default_columns => '1', |
|
350 | :default_columns => '1', | |
351 | :fields => ["status_id", "assigned_to_id"], |
|
351 | :fields => ["status_id", "assigned_to_id"], | |
352 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
352 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, | |
353 | :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, |
|
353 | :values => { "assigned_to_id" => ["me"], "status_id" => ["1"]}, | |
354 | :query => {"name" => "test_edit_global_private_query", "visibility" => "2"} |
|
354 | :query => {"name" => "test_edit_global_private_query", "visibility" => "2"} | |
355 |
|
355 | |||
356 | assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3 |
|
356 | assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 3 | |
357 | q = Query.find_by_name('test_edit_global_private_query') |
|
357 | q = Query.find_by_name('test_edit_global_private_query') | |
358 | assert !q.is_public? |
|
358 | assert !q.is_public? | |
359 | assert q.has_default_columns? |
|
359 | assert q.has_default_columns? | |
360 | assert q.valid? |
|
360 | assert q.valid? | |
361 | end |
|
361 | end | |
362 |
|
362 | |||
363 | def test_update_global_public_query |
|
363 | def test_update_global_public_query | |
364 | @request.session[:user_id] = 1 |
|
364 | @request.session[:user_id] = 1 | |
365 | put :update, |
|
365 | put :update, | |
366 | :id => 4, |
|
366 | :id => 4, | |
367 | :default_columns => '1', |
|
367 | :default_columns => '1', | |
368 | :fields => ["status_id", "assigned_to_id"], |
|
368 | :fields => ["status_id", "assigned_to_id"], | |
369 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, |
|
369 | :operators => {"assigned_to_id" => "=", "status_id" => "o"}, | |
370 | :values => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, |
|
370 | :values => { "assigned_to_id" => ["1"], "status_id" => ["1"]}, | |
371 | :query => {"name" => "test_edit_global_public_query", "visibility" => "2"} |
|
371 | :query => {"name" => "test_edit_global_public_query", "visibility" => "2"} | |
372 |
|
372 | |||
373 | assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4 |
|
373 | assert_redirected_to :controller => 'issues', :action => 'index', :query_id => 4 | |
374 | q = Query.find_by_name('test_edit_global_public_query') |
|
374 | q = Query.find_by_name('test_edit_global_public_query') | |
375 | assert q.is_public? |
|
375 | assert q.is_public? | |
376 | assert q.has_default_columns? |
|
376 | assert q.has_default_columns? | |
377 | assert q.valid? |
|
377 | assert q.valid? | |
378 | end |
|
378 | end | |
379 |
|
379 | |||
380 | def test_update_with_failure |
|
380 | def test_update_with_failure | |
381 | @request.session[:user_id] = 1 |
|
381 | @request.session[:user_id] = 1 | |
382 | put :update, :id => 4, :query => {:name => ''} |
|
382 | put :update, :id => 4, :query => {:name => ''} | |
383 | assert_response :success |
|
383 | assert_response :success | |
384 | assert_template 'edit' |
|
384 | assert_select_error /Name cannot be blank/ | |
385 | end |
|
385 | end | |
386 |
|
386 | |||
387 | def test_destroy |
|
387 | def test_destroy | |
388 | @request.session[:user_id] = 2 |
|
388 | @request.session[:user_id] = 2 | |
389 | delete :destroy, :id => 1 |
|
389 | delete :destroy, :id => 1 | |
390 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil |
|
390 | assert_redirected_to :controller => 'issues', :action => 'index', :project_id => 'ecookbook', :set_filter => 1, :query_id => nil | |
391 | assert_nil Query.find_by_id(1) |
|
391 | assert_nil Query.find_by_id(1) | |
392 | end |
|
392 | end | |
393 |
|
393 | |||
394 | def test_backslash_should_be_escaped_in_filters |
|
394 | def test_backslash_should_be_escaped_in_filters | |
395 | @request.session[:user_id] = 2 |
|
395 | @request.session[:user_id] = 2 | |
396 | get :new, :subject => 'foo/bar' |
|
396 | get :new, :subject => 'foo/bar' | |
397 | assert_response :success |
|
397 | assert_response :success | |
398 | assert_template 'new' |
|
|||
399 | assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body |
|
398 | assert_include 'addFilter("subject", "=", ["foo\/bar"]);', response.body | |
400 | end |
|
399 | end | |
401 | end |
|
400 | end |
@@ -1,85 +1,64 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2016 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
19 |
|
19 | |||
20 | class ReportsControllerTest < Redmine::ControllerTest |
|
20 | class ReportsControllerTest < Redmine::ControllerTest | |
21 | fixtures :projects, :trackers, :issue_statuses, :issues, |
|
21 | fixtures :projects, :trackers, :issue_statuses, :issues, | |
22 | :enumerations, :users, :issue_categories, |
|
22 | :enumerations, :users, :issue_categories, | |
23 | :projects_trackers, |
|
23 | :projects_trackers, | |
24 | :roles, |
|
24 | :roles, | |
25 | :member_roles, |
|
25 | :member_roles, | |
26 | :members, |
|
26 | :members, | |
27 | :enabled_modules, |
|
27 | :enabled_modules, | |
28 | :versions |
|
28 | :versions | |
29 |
|
29 | |||
30 | def test_get_issue_report |
|
30 | def test_get_issue_report | |
31 | get :issue_report, :id => 1 |
|
31 | get :issue_report, :id => 1 | |
32 |
|
||||
33 | assert_response :success |
|
32 | assert_response :success | |
34 | assert_template 'issue_report' |
|
|||
35 |
|
||||
36 | [:issues_by_tracker, :issues_by_version, :issues_by_category, :issues_by_assigned_to, |
|
|||
37 | :issues_by_author, :issues_by_subproject, :issues_by_priority].each do |ivar| |
|
|||
38 | assert_not_nil assigns(ivar) |
|
|||
39 | end |
|
|||
40 |
|
||||
41 | assert_equal IssuePriority.all.reverse, assigns(:priorities) |
|
|||
42 | end |
|
33 | end | |
43 |
|
34 | |||
44 | def test_get_issue_report_details |
|
35 | def test_get_issue_report_details | |
45 | %w(tracker version priority category assigned_to author subproject).each do |detail| |
|
36 | %w(tracker version priority category assigned_to author subproject).each do |detail| | |
46 | get :issue_report_details, :id => 1, :detail => detail |
|
37 | get :issue_report_details, :id => 1, :detail => detail | |
47 |
|
||||
48 | assert_response :success |
|
38 | assert_response :success | |
49 | assert_template 'issue_report_details' |
|
|||
50 | assert_not_nil assigns(:field) |
|
|||
51 | assert_not_nil assigns(:rows) |
|
|||
52 | assert_not_nil assigns(:data) |
|
|||
53 | assert_not_nil assigns(:report_title) |
|
|||
54 | end |
|
39 | end | |
55 | end |
|
40 | end | |
56 |
|
41 | |||
57 | def test_get_issue_report_details_by_tracker_should_show_issue_count |
|
42 | def test_get_issue_report_details_by_tracker_should_show_issue_count | |
58 | Issue.delete_all |
|
43 | Issue.delete_all | |
59 | Issue.generate!(:tracker_id => 1) |
|
44 | Issue.generate!(:tracker_id => 1) | |
60 | Issue.generate!(:tracker_id => 1) |
|
45 | Issue.generate!(:tracker_id => 1) | |
61 | Issue.generate!(:tracker_id => 1, :status_id => 5) |
|
46 | Issue.generate!(:tracker_id => 1, :status_id => 5) | |
62 | Issue.generate!(:tracker_id => 2) |
|
47 | Issue.generate!(:tracker_id => 2) | |
63 |
|
48 | |||
64 | get :issue_report_details, :id => 1, :detail => 'tracker' |
|
49 | get :issue_report_details, :id => 1, :detail => 'tracker' | |
65 | assert_select 'table.list tbody :nth-child(1)' do |
|
50 | assert_select 'table.list tbody :nth-child(1)' do | |
66 | assert_select 'td', :text => 'Bug' |
|
51 | assert_select 'td', :text => 'Bug' | |
67 | assert_select ':nth-child(2)', :text => '2' # status:1 |
|
52 | assert_select ':nth-child(2)', :text => '2' # status:1 | |
68 | assert_select ':nth-child(3)', :text => '-' # status:2 |
|
53 | assert_select ':nth-child(3)', :text => '-' # status:2 | |
69 | assert_select ':nth-child(8)', :text => '2' # open |
|
54 | assert_select ':nth-child(8)', :text => '2' # open | |
70 | assert_select ':nth-child(9)', :text => '1' # closed |
|
55 | assert_select ':nth-child(9)', :text => '1' # closed | |
71 | assert_select ':nth-child(10)', :text => '3' # total |
|
56 | assert_select ':nth-child(10)', :text => '3' # total | |
72 | end |
|
57 | end | |
73 | end |
|
58 | end | |
74 |
|
59 | |||
75 | def test_get_issue_report_details_by_priority |
|
|||
76 | get :issue_report_details, :id => 1, :detail => 'priority' |
|
|||
77 | assert_equal IssuePriority.all.reverse, assigns(:rows) |
|
|||
78 | end |
|
|||
79 |
|
||||
80 | def test_get_issue_report_details_with_an_invalid_detail |
|
60 | def test_get_issue_report_details_with_an_invalid_detail | |
81 | get :issue_report_details, :id => 1, :detail => 'invalid' |
|
61 | get :issue_report_details, :id => 1, :detail => 'invalid' | |
82 |
|
62 | assert_response 404 | ||
83 | assert_redirected_to '/projects/ecookbook/issues/report' |
|
|||
84 | end |
|
63 | end | |
85 | end |
|
64 | end |
General Comments 0
You need to be logged in to leave comments.
Login now