@@ -1,68 +1,94 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2013 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('../base', __FILE__) |
|
18 | require File.expand_path('../base', __FILE__) | |
19 |
|
19 | |||
20 | class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base |
|
20 | class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base | |
21 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
21 | fixtures :projects, :users, :roles, :members, :member_roles, | |
22 | :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, |
|
22 | :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, | |
23 | :enumerations, :custom_fields, :custom_values, :custom_fields_trackers |
|
23 | :enumerations, :custom_fields, :custom_values, :custom_fields_trackers | |
24 |
|
24 | |||
25 | # create an issue |
|
25 | # create an issue | |
26 | def test_add_issue |
|
26 | def test_add_issue | |
27 | log_user('jsmith', 'jsmith') |
|
27 | log_user('jsmith', 'jsmith') | |
28 | visit new_issue_path(:project_id => 1) |
|
28 | visit new_issue_path(:project_id => 1) | |
29 | within('form#issue-form') do |
|
29 | within('form#issue-form') do | |
30 | select 'Bug', :from => 'Tracker' |
|
30 | select 'Bug', :from => 'Tracker' | |
31 | select 'Low', :from => 'Priority' |
|
31 | select 'Low', :from => 'Priority' | |
32 | fill_in 'Subject', :with => 'new test issue' |
|
32 | fill_in 'Subject', :with => 'new test issue' | |
33 | fill_in 'Description', :with => 'new issue' |
|
33 | fill_in 'Description', :with => 'new issue' | |
34 | select '0 %', :from => 'Done' |
|
34 | select '0 %', :from => 'Done' | |
35 | fill_in 'Due date', :with => '' |
|
35 | fill_in 'Due date', :with => '' | |
36 | select '', :from => 'Assignee' |
|
36 | select '', :from => 'Assignee' | |
37 | fill_in 'Searchable field', :with => 'Value for field 2' |
|
37 | fill_in 'Searchable field', :with => 'Value for field 2' | |
38 | # click_button 'Create' would match both 'Create' and 'Create and continue' buttons |
|
38 | # click_button 'Create' would match both 'Create' and 'Create and continue' buttons | |
39 | find('input[name=commit]').click |
|
39 | find('input[name=commit]').click | |
40 | end |
|
40 | end | |
41 |
|
41 | |||
42 | # find created issue |
|
42 | # find created issue | |
43 | issue = Issue.find_by_subject("new test issue") |
|
43 | issue = Issue.find_by_subject("new test issue") | |
44 | assert_kind_of Issue, issue |
|
44 | assert_kind_of Issue, issue | |
45 |
|
45 | |||
46 | # check redirection |
|
46 | # check redirection | |
47 | find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created." |
|
47 | find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created." | |
48 | assert_equal issue_path(:id => issue), current_path |
|
48 | assert_equal issue_path(:id => issue), current_path | |
49 |
|
49 | |||
50 | # check issue attributes |
|
50 | # check issue attributes | |
51 | assert_equal 'jsmith', issue.author.login |
|
51 | assert_equal 'jsmith', issue.author.login | |
52 | assert_equal 1, issue.project.id |
|
52 | assert_equal 1, issue.project.id | |
53 | assert_equal IssueStatus.find_by_name('New'), issue.status |
|
53 | assert_equal IssueStatus.find_by_name('New'), issue.status | |
54 | assert_equal Tracker.find_by_name('Bug'), issue.tracker |
|
54 | assert_equal Tracker.find_by_name('Bug'), issue.tracker | |
55 | assert_equal IssuePriority.find_by_name('Low'), issue.priority |
|
55 | assert_equal IssuePriority.find_by_name('Low'), issue.priority | |
56 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) |
|
56 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) | |
57 | end |
|
57 | end | |
58 |
|
58 | |||
|
59 | def test_create_issue_with_watchers | |||
|
60 | User.generate!(:firstname => 'Some', :lastname => 'Watcher') | |||
|
61 | ||||
|
62 | assert_difference 'Issue.count' do | |||
|
63 | log_user('jsmith', 'jsmith') | |||
|
64 | visit '/projects/ecookbook/issues/new' | |||
|
65 | fill_in 'Subject', :with => 'Issue with watchers' | |||
|
66 | # Add a project member as watcher | |||
|
67 | check 'Dave Lopper' | |||
|
68 | # Search for another user | |||
|
69 | click_link 'Search for watchers to add' | |||
|
70 | within('form#new-watcher-form') do | |||
|
71 | assert page.has_content?('Some One') | |||
|
72 | fill_in 'user_search', :with => 'watch' | |||
|
73 | sleep(2) # autocomplete delay | |||
|
74 | assert !page.has_content?('Some One') | |||
|
75 | check 'Some Watcher' | |||
|
76 | click_button 'Add' | |||
|
77 | end | |||
|
78 | find('input[name=commit]').click | |||
|
79 | end | |||
|
80 | ||||
|
81 | issue = Issue.order('id desc').first | |||
|
82 | assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort | |||
|
83 | end | |||
|
84 | ||||
59 | def test_preview_issue_description |
|
85 | def test_preview_issue_description | |
60 | log_user('jsmith', 'jsmith') |
|
86 | log_user('jsmith', 'jsmith') | |
61 | visit new_issue_path(:project_id => 1) |
|
87 | visit new_issue_path(:project_id => 1) | |
62 | within('form#issue-form') do |
|
88 | within('form#issue-form') do | |
63 | fill_in 'Description', :with => 'new issue description' |
|
89 | fill_in 'Description', :with => 'new issue description' | |
64 | click_link 'Preview' |
|
90 | click_link 'Preview' | |
65 | end |
|
91 | end | |
66 | find 'div#preview fieldset', :visible => true, :text => 'new issue description' |
|
92 | find 'div#preview fieldset', :visible => true, :text => 'new issue description' | |
67 | end |
|
93 | end | |
68 | end |
|
94 | end |
General Comments 0
You need to be logged in to leave comments.
Login now