@@ -1,127 +1,126 | |||||
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 | :watchers |
|
24 | :watchers | |
25 |
|
25 | |||
26 | # create an issue |
|
26 | # create an issue | |
27 | def test_add_issue |
|
27 | def test_add_issue | |
28 | log_user('jsmith', 'jsmith') |
|
28 | log_user('jsmith', 'jsmith') | |
29 | visit new_issue_path(:project_id => 1) |
|
29 | visit new_issue_path(:project_id => 1) | |
30 | within('form#issue-form') do |
|
30 | within('form#issue-form') do | |
31 | select 'Bug', :from => 'Tracker' |
|
31 | select 'Bug', :from => 'Tracker' | |
32 | select 'Low', :from => 'Priority' |
|
32 | select 'Low', :from => 'Priority' | |
33 | fill_in 'Subject', :with => 'new test issue' |
|
33 | fill_in 'Subject', :with => 'new test issue' | |
34 | fill_in 'Description', :with => 'new issue' |
|
34 | fill_in 'Description', :with => 'new issue' | |
35 | select '0 %', :from => 'Done' |
|
35 | select '0 %', :from => 'Done' | |
36 | fill_in 'Due date', :with => '' |
|
36 | fill_in 'Due date', :with => '' | |
37 | select '', :from => 'Assignee' |
|
37 | select '', :from => 'Assignee' | |
38 | fill_in 'Searchable field', :with => 'Value for field 2' |
|
38 | fill_in 'Searchable field', :with => 'Value for field 2' | |
39 | # click_button 'Create' would match both 'Create' and 'Create and continue' buttons |
|
39 | # click_button 'Create' would match both 'Create' and 'Create and continue' buttons | |
40 | find('input[name=commit]').click |
|
40 | find('input[name=commit]').click | |
41 | end |
|
41 | end | |
42 |
|
42 | |||
43 | # find created issue |
|
43 | # find created issue | |
44 | issue = Issue.find_by_subject("new test issue") |
|
44 | issue = Issue.find_by_subject("new test issue") | |
45 | assert_kind_of Issue, issue |
|
45 | assert_kind_of Issue, issue | |
46 |
|
46 | |||
47 | # check redirection |
|
47 | # check redirection | |
48 | find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created." |
|
48 | find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created." | |
49 | assert_equal issue_path(:id => issue), current_path |
|
49 | assert_equal issue_path(:id => issue), current_path | |
50 |
|
50 | |||
51 | # check issue attributes |
|
51 | # check issue attributes | |
52 | assert_equal 'jsmith', issue.author.login |
|
52 | assert_equal 'jsmith', issue.author.login | |
53 | assert_equal 1, issue.project.id |
|
53 | assert_equal 1, issue.project.id | |
54 | assert_equal IssueStatus.find_by_name('New'), issue.status |
|
54 | assert_equal IssueStatus.find_by_name('New'), issue.status | |
55 | assert_equal Tracker.find_by_name('Bug'), issue.tracker |
|
55 | assert_equal Tracker.find_by_name('Bug'), issue.tracker | |
56 | assert_equal IssuePriority.find_by_name('Low'), issue.priority |
|
56 | assert_equal IssuePriority.find_by_name('Low'), issue.priority | |
57 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) |
|
57 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) | |
58 | end |
|
58 | end | |
59 |
|
59 | |||
60 | def test_create_issue_with_watchers |
|
60 | def test_create_issue_with_watchers | |
61 | User.generate!(:firstname => 'Some', :lastname => 'Watcher') |
|
61 | User.generate!(:firstname => 'Some', :lastname => 'Watcher') | |
62 |
|
62 | |||
63 | assert_difference 'Issue.count' do |
|
63 | assert_difference 'Issue.count' do | |
64 | log_user('jsmith', 'jsmith') |
|
64 | log_user('jsmith', 'jsmith') | |
65 | visit '/projects/ecookbook/issues/new' |
|
65 | visit '/projects/ecookbook/issues/new' | |
66 | fill_in 'Subject', :with => 'Issue with watchers' |
|
66 | fill_in 'Subject', :with => 'Issue with watchers' | |
67 | # Add a project member as watcher |
|
67 | # Add a project member as watcher | |
68 | check 'Dave Lopper' |
|
68 | check 'Dave Lopper' | |
69 | # Search for another user |
|
69 | # Search for another user | |
70 | click_link 'Search for watchers to add' |
|
70 | click_link 'Search for watchers to add' | |
71 | within('form#new-watcher-form') do |
|
71 | within('form#new-watcher-form') do | |
72 | assert page.has_content?('Some One') |
|
72 | assert page.has_content?('Some One') | |
73 | fill_in 'user_search', :with => 'watch' |
|
73 | fill_in 'user_search', :with => 'watch' | |
74 | sleep(2) # autocomplete delay |
|
74 | assert page.has_no_content?('Some One') | |
75 | assert !page.has_content?('Some One') |
|
|||
76 | check 'Some Watcher' |
|
75 | check 'Some Watcher' | |
77 | click_button 'Add' |
|
76 | click_button 'Add' | |
78 | end |
|
77 | end | |
79 | find('input[name=commit]').click |
|
78 | find('input[name=commit]').click | |
80 | end |
|
79 | end | |
81 |
|
80 | |||
82 | issue = Issue.order('id desc').first |
|
81 | issue = Issue.order('id desc').first | |
83 | assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort |
|
82 | assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort | |
84 | end |
|
83 | end | |
85 |
|
84 | |||
86 | # TODO: `fill_in 'Description'` makes all visit calls inoperative |
|
85 | # TODO: `fill_in 'Description'` makes all visit calls inoperative | |
87 | # and breaks all tests that run after that |
|
86 | # and breaks all tests that run after that | |
88 | def test_preview_issue_description |
|
87 | def test_preview_issue_description | |
89 | skip("Breaks the test suite") |
|
88 | skip("Breaks the test suite") | |
90 |
|
89 | |||
91 | log_user('jsmith', 'jsmith') |
|
90 | log_user('jsmith', 'jsmith') | |
92 | visit new_issue_path(:project_id => 1) |
|
91 | visit new_issue_path(:project_id => 1) | |
93 | within('form#issue-form') do |
|
92 | within('form#issue-form') do | |
94 | fill_in 'Description', :with => 'new issue description' |
|
93 | fill_in 'Description', :with => 'new issue description' | |
95 | click_link 'Preview' |
|
94 | click_link 'Preview' | |
96 | end |
|
95 | end | |
97 | find 'div#preview fieldset', :visible => true, :text => 'new issue description' |
|
96 | find 'div#preview fieldset', :visible => true, :text => 'new issue description' | |
98 | end |
|
97 | end | |
99 |
|
98 | |||
100 | def test_watch_issue_via_context_menu |
|
99 | def test_watch_issue_via_context_menu | |
101 |
|
|
100 | log_user('jsmith', 'jsmith') | |
102 |
|
|
101 | visit '/issues' | |
103 |
|
|
102 | find('tr#issue-1 td.updated_on').click | |
104 |
|
|
103 | page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');" | |
105 | assert_difference 'Watcher.count' do |
|
104 | assert_difference 'Watcher.count' do | |
106 | within('#context-menu') do |
|
105 | within('#context-menu') do | |
107 | click_link 'Watch' |
|
106 | click_link 'Watch' | |
108 | end |
|
107 | end | |
109 | end |
|
108 | end | |
110 | assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) |
|
109 | assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) | |
111 | end |
|
110 | end | |
112 |
|
111 | |||
113 | def test_bulk_watch_issues_via_context_menu |
|
112 | def test_bulk_watch_issues_via_context_menu | |
114 | assert_difference 'Watcher.count', 2 do |
|
|||
115 |
|
|
113 | log_user('jsmith', 'jsmith') | |
116 |
|
|
114 | visit '/issues' | |
117 |
|
|
115 | find('tr#issue-1 input[type=checkbox]').click | |
118 |
|
|
116 | find('tr#issue-4 input[type=checkbox]').click | |
119 |
|
|
117 | page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');" | |
|
118 | assert_difference 'Watcher.count', 2 do | |||
120 | within('#context-menu') do |
|
119 | within('#context-menu') do | |
121 | click_link 'Watch' |
|
120 | click_link 'Watch' | |
122 | end |
|
121 | end | |
123 | end |
|
122 | end | |
124 | assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) |
|
123 | assert Issue.find(1).watched_by?(User.find_by_login('jsmith')) | |
125 | assert Issue.find(4).watched_by?(User.find_by_login('jsmith')) |
|
124 | assert Issue.find(4).watched_by?(User.find_by_login('jsmith')) | |
126 | end |
|
125 | end | |
127 | end |
|
126 | end |
General Comments 0
You need to be logged in to leave comments.
Login now