@@ -1,126 +1,128 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | require File.expand_path('../base', __FILE__) |
|
19 | 19 | |
|
20 | 20 | class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base |
|
21 | 21 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
22 | 22 | :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, |
|
23 | 23 | :enumerations, :custom_fields, :custom_values, :custom_fields_trackers, |
|
24 | 24 | :watchers |
|
25 | 25 | |
|
26 |
|
|
|
27 | def test_add_issue | |
|
26 | def test_create_issue | |
|
28 | 27 | log_user('jsmith', 'jsmith') |
|
29 | visit new_issue_path(:project_id => 1) | |
|
28 | visit '/projects/ecookbook/issues/new' | |
|
30 | 29 | within('form#issue-form') do |
|
31 | 30 | select 'Bug', :from => 'Tracker' |
|
32 | 31 | select 'Low', :from => 'Priority' |
|
33 | 32 | fill_in 'Subject', :with => 'new test issue' |
|
34 | 33 | fill_in 'Description', :with => 'new issue' |
|
35 | 34 | select '0 %', :from => 'Done' |
|
36 | 35 | fill_in 'Due date', :with => '' |
|
37 | 36 | select '', :from => 'Assignee' |
|
38 | 37 | fill_in 'Searchable field', :with => 'Value for field 2' |
|
39 | 38 | # click_button 'Create' would match both 'Create' and 'Create and continue' buttons |
|
40 | 39 | find('input[name=commit]').click |
|
41 | 40 | end |
|
42 | 41 | |
|
43 | 42 | # find created issue |
|
44 | 43 | issue = Issue.find_by_subject("new test issue") |
|
45 | 44 | assert_kind_of Issue, issue |
|
46 | 45 | |
|
47 | 46 | # check redirection |
|
48 | 47 | find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created." |
|
49 | 48 | assert_equal issue_path(:id => issue), current_path |
|
50 | 49 | |
|
51 | 50 | # check issue attributes |
|
52 | 51 | assert_equal 'jsmith', issue.author.login |
|
53 | 52 | assert_equal 1, issue.project.id |
|
54 | 53 | assert_equal IssueStatus.find_by_name('New'), issue.status |
|
55 | 54 | assert_equal Tracker.find_by_name('Bug'), issue.tracker |
|
56 | 55 | assert_equal IssuePriority.find_by_name('Low'), issue.priority |
|
57 | 56 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) |
|
58 | 57 | end |
|
59 | 58 | |
|
60 | 59 | def test_create_issue_with_watchers |
|
61 | 60 | User.generate!(:firstname => 'Some', :lastname => 'Watcher') |
|
62 | 61 | |
|
62 | log_user('jsmith', 'jsmith') | |
|
63 | visit '/projects/ecookbook/issues/new' | |
|
64 | fill_in 'Subject', :with => 'Issue with watchers' | |
|
65 | # Add a project member as watcher | |
|
66 | check 'Dave Lopper' | |
|
67 | # Search for another user | |
|
68 | click_link 'Search for watchers to add' | |
|
69 | within('form#new-watcher-form') do | |
|
70 | assert page.has_content?('Some One') | |
|
71 | fill_in 'user_search', :with => 'watch' | |
|
72 | assert page.has_no_content?('Some One') | |
|
73 | check 'Some Watcher' | |
|
74 | click_button 'Add' | |
|
75 | end | |
|
63 | 76 | assert_difference 'Issue.count' do |
|
64 | log_user('jsmith', 'jsmith') | |
|
65 | visit '/projects/ecookbook/issues/new' | |
|
66 | fill_in 'Subject', :with => 'Issue with watchers' | |
|
67 | # Add a project member as watcher | |
|
68 | check 'Dave Lopper' | |
|
69 | # Search for another user | |
|
70 | click_link 'Search for watchers to add' | |
|
71 | within('form#new-watcher-form') do | |
|
72 | assert page.has_content?('Some One') | |
|
73 | fill_in 'user_search', :with => 'watch' | |
|
74 | assert page.has_no_content?('Some One') | |
|
75 | check 'Some Watcher' | |
|
76 | click_button 'Add' | |
|
77 | end | |
|
78 | 77 | find('input[name=commit]').click |
|
79 | 78 | end |
|
80 | 79 | |
|
81 | 80 | issue = Issue.order('id desc').first |
|
82 | 81 | assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort |
|
83 | 82 | end |
|
84 | 83 | |
|
85 | # TODO: `fill_in 'Description'` makes all visit calls inoperative | |
|
86 | # and breaks all tests that run after that | |
|
87 | 84 | def test_preview_issue_description |
|
88 | skip("Breaks the test suite") | |
|
89 | ||
|
90 | 85 | log_user('jsmith', 'jsmith') |
|
91 | visit new_issue_path(:project_id => 1) | |
|
86 | visit '/projects/ecookbook/issues/new' | |
|
92 | 87 | within('form#issue-form') do |
|
88 | fill_in 'Subject', :with => 'new issue subject' | |
|
93 | 89 | fill_in 'Description', :with => 'new issue description' |
|
94 | 90 | click_link 'Preview' |
|
95 | 91 | end |
|
96 | 92 | find 'div#preview fieldset', :visible => true, :text => 'new issue description' |
|
93 | assert_difference 'Issue.count' do | |
|
94 | find('input[name=commit]').click | |
|
95 | end | |
|
96 | ||
|
97 | issue = Issue.order('id desc').first | |
|
98 | assert_equal 'new issue description', issue.description | |
|
97 | 99 | end |
|
98 | 100 | |
|
99 | 101 | def test_watch_issue_via_context_menu |
|
100 | 102 | log_user('jsmith', 'jsmith') |
|
101 | 103 | visit '/issues' |
|
102 | 104 | find('tr#issue-1 td.updated_on').click |
|
103 | 105 | page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');" |
|
104 | 106 | assert_difference 'Watcher.count' do |
|
105 | 107 | within('#context-menu') do |
|
106 | 108 | click_link 'Watch' |
|
107 | 109 | end |
|
108 | 110 | end |
|
109 | 111 | assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) |
|
110 | 112 | end |
|
111 | 113 | |
|
112 | 114 | def test_bulk_watch_issues_via_context_menu |
|
113 | 115 | log_user('jsmith', 'jsmith') |
|
114 | 116 | visit '/issues' |
|
115 | 117 | find('tr#issue-1 input[type=checkbox]').click |
|
116 | 118 | find('tr#issue-4 input[type=checkbox]').click |
|
117 | 119 | page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');" |
|
118 | 120 | assert_difference 'Watcher.count', 2 do |
|
119 | 121 | within('#context-menu') do |
|
120 | 122 | click_link 'Watch' |
|
121 | 123 | end |
|
122 | 124 | end |
|
123 | 125 | assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) |
|
124 | 126 | assert Issue.find(4).watched_by?(User.find_by_login('jsmith')) |
|
125 | 127 | end |
|
126 | 128 | end |
General Comments 0
You need to be logged in to leave comments.
Login now