##// END OF EJS Templates
Removes calls to #assert_template and #assigns in integration tests....
Jean-Philippe Lang -
r15345:e1da6de36f0d
parent child
Show More
@@ -27,7 +27,6 class AccountTest < Redmine::IntegrationTest
27
27
28 get "/my/account"
28 get "/my/account"
29 assert_response :success
29 assert_response :success
30 assert_template "my/account"
31 end
30 end
32
31
33 def test_login_should_set_session_token
32 def test_login_should_set_session_token
@@ -67,7 +66,6 class AccountTest < Redmine::IntegrationTest
67 cookies[:autologin] = token.value
66 cookies[:autologin] = token.value
68 get '/my/page'
67 get '/my/page'
69 assert_response :success
68 assert_response :success
70 assert_template 'my/page'
71 assert_equal user.id, session[:user_id]
69 assert_equal user.id, session[:user_id]
72 assert_not_nil user.reload.last_login_on
70 assert_not_nil user.reload.last_login_on
73 end
71 end
@@ -106,7 +104,6 class AccountTest < Redmine::IntegrationTest
106
104
107 get "/account/lost_password"
105 get "/account/lost_password"
108 assert_response :success
106 assert_response :success
109 assert_template "account/lost_password"
110 assert_select 'input[name=mail]'
107 assert_select 'input[name=mail]'
111
108
112 post "/account/lost_password", :mail => 'jSmith@somenet.foo'
109 post "/account/lost_password", :mail => 'jSmith@somenet.foo'
@@ -119,7 +116,6 class AccountTest < Redmine::IntegrationTest
119
116
120 get "/account/lost_password", :token => token.value
117 get "/account/lost_password", :token => token.value
121 assert_response :success
118 assert_response :success
122 assert_template "account/password_recovery"
123 assert_select 'input[type=hidden][name=token][value=?]', token.value
119 assert_select 'input[type=hidden][name=token][value=?]', token.value
124 assert_select 'input[name=new_password]'
120 assert_select 'input[name=new_password]'
125 assert_select 'input[name=new_password_confirmation]'
121 assert_select 'input[name=new_password_confirmation]'
@@ -202,7 +198,6 class AccountTest < Redmine::IntegrationTest
202
198
203 get '/account/register'
199 get '/account/register'
204 assert_response :success
200 assert_response :success
205 assert_template 'account/register'
206
201
207 post '/account/register',
202 post '/account/register',
208 :user => {:login => "newuser", :language => "en",
203 :user => {:login => "newuser", :language => "en",
@@ -211,7 +206,6 class AccountTest < Redmine::IntegrationTest
211 assert_redirected_to '/my/account'
206 assert_redirected_to '/my/account'
212 follow_redirect!
207 follow_redirect!
213 assert_response :success
208 assert_response :success
214 assert_template 'my/account'
215
209
216 user = User.find_by_login('newuser')
210 user = User.find_by_login('newuser')
217 assert_not_nil user
211 assert_not_nil user
@@ -275,7 +269,6 class AccountTest < Redmine::IntegrationTest
275
269
276 post '/login', :username => 'foo', :password => 'bar'
270 post '/login', :username => 'foo', :password => 'bar'
277 assert_response :success
271 assert_response :success
278 assert_template 'account/register'
279 assert_select 'input[name=?][value=""]', 'user[firstname]'
272 assert_select 'input[name=?][value=""]', 'user[firstname]'
280 assert_select 'input[name=?][value=Smith]', 'user[lastname]'
273 assert_select 'input[name=?][value=Smith]', 'user[lastname]'
281 assert_select 'input[name=?]', 'user[login]', 0
274 assert_select 'input[name=?]', 'user[login]', 0
@@ -30,7 +30,7 class AdminTest < Redmine::IntegrationTest
30 log_user("admin", "admin")
30 log_user("admin", "admin")
31 get "/users/new"
31 get "/users/new"
32 assert_response :success
32 assert_response :success
33 assert_template "users/new"
33
34 post "/users",
34 post "/users",
35 :user => { :login => "psmith", :firstname => "Paul",
35 :user => { :login => "psmith", :firstname => "Paul",
36 :lastname => "Smith", :mail => "psmith@somenet.foo",
36 :lastname => "Smith", :mail => "psmith@somenet.foo",
@@ -129,7 +129,7 class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base
129
129
130 get '/users/current', {}, {'X-Redmine-API-Key' => user.api_key, 'X-Redmine-Switch-User' => su.login}
130 get '/users/current', {}, {'X-Redmine-API-Key' => user.api_key, 'X-Redmine-Switch-User' => su.login}
131 assert_response :success
131 assert_response :success
132 assert_equal su, assigns(:user)
132 assert_select 'h2', :text => su.name
133 assert_equal su, User.current
133 assert_equal su, User.current
134 end
134 end
135
135
@@ -152,7 +152,7 class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base
152
152
153 get '/users/current', {}, {'X-Redmine-API-Key' => user.api_key, 'X-Redmine-Switch-User' => su.login}
153 get '/users/current', {}, {'X-Redmine-API-Key' => user.api_key, 'X-Redmine-Switch-User' => su.login}
154 assert_response :success
154 assert_response :success
155 assert_equal user, assigns(:user)
155 assert_select 'h2', :text => user.name
156 assert_equal user, User.current
156 assert_equal user, User.current
157 end
157 end
158 end
158 end
@@ -46,8 +46,7 class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
46
46
47 test "GET /issues.xml should contain metadata" do
47 test "GET /issues.xml should contain metadata" do
48 get '/issues.xml'
48 get '/issues.xml'
49 assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]',
49 assert_select 'issues[type=array][total_count][limit="25"][offset="0"]'
50 assigns(:issue_count).to_s
51 end
50 end
52
51
53 test "GET /issues.xml with nometa param should not contain metadata" do
52 test "GET /issues.xml with nometa param should not contain metadata" do
@@ -62,9 +61,7 class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
62
61
63 test "GET /issues.xml with offset and limit" do
62 test "GET /issues.xml with offset and limit" do
64 get '/issues.xml?offset=2&limit=3'
63 get '/issues.xml?offset=2&limit=3'
65
64 assert_select 'issues[type=array][total_count][limit="3"][offset="2"]'
66 assert_equal 3, assigns(:limit)
67 assert_equal 2, assigns(:offset)
68 assert_select 'issues issue', 3
65 assert_select 'issues issue', 3
69 end
66 end
70
67
@@ -25,8 +25,8 class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
25
25
26 assert_response :success
26 assert_response :success
27 assert_equal 'application/xml', @response.content_type
27 assert_equal 'application/xml', @response.content_type
28 assert_equal 3, assigns(:roles).size
29
28
29 assert_select 'roles role', 3
30 assert_select 'roles[type=array] role id', :text => '2' do
30 assert_select 'roles[type=array] role id', :text => '2' do
31 assert_select '~ name', :text => 'Developer'
31 assert_select '~ name', :text => 'Developer'
32 end
32 end
@@ -37,11 +37,11 class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
37
37
38 assert_response :success
38 assert_response :success
39 assert_equal 'application/json', @response.content_type
39 assert_equal 'application/json', @response.content_type
40 assert_equal 3, assigns(:roles).size
41
40
42 json = ActiveSupport::JSON.decode(response.body)
41 json = ActiveSupport::JSON.decode(response.body)
43 assert_kind_of Hash, json
42 assert_kind_of Hash, json
44 assert_kind_of Array, json['roles']
43 assert_kind_of Array, json['roles']
44 assert_equal 3, json['roles'].size
45 assert_include({'id' => 2, 'name' => 'Developer'}, json['roles'])
45 assert_include({'id' => 2, 'name' => 'Developer'}, json['roles'])
46 end
46 end
47
47
@@ -48,26 +48,26 class Redmine::ApiTest::SearchTest < Redmine::ApiTest::Base
48 get '/search.xml', :q => '', :all_words => ''
48 get '/search.xml', :q => '', :all_words => ''
49
49
50 assert_response :success
50 assert_response :success
51 assert_equal 0, assigns(:results).size
51 assert_select 'result', 0
52 end
52 end
53
53
54 test "GET /search.xml with query strings should return results" do
54 test "GET /search.xml with query strings should return results" do
55 get '/search.xml', :q => 'recipe subproject commit', :all_words => ''
55 issue = Issue.generate!(:subject => 'searchapi')
56
57 get '/search.xml', :q => 'searchapi', :all_words => ''
56
58
57 assert_response :success
59 assert_response :success
58 assert_not_empty(assigns(:results))
59
60
60 assert_select 'results[type=array]' do
61 assert_select 'results[type=array]' do
61 assert_select 'result', :count => assigns(:results).count
62 assert_select 'result', 1
62 assigns(:results).size.times.each do |i|
63
63 assert_select 'result' do
64 assert_select 'result' do
64 assert_select 'id', :text => assigns(:results)[i].id.to_s
65 assert_select 'id', :text => issue.id.to_s
65 assert_select 'title', :text => assigns(:results)[i].event_title
66 assert_select 'title', :text => "Bug ##{issue.id} (New): searchapi"
66 assert_select 'type', :text => assigns(:results)[i].event_type
67 assert_select 'type', :text => 'issue'
67 assert_select 'url', :text => url_for(assigns(:results)[i].event_url(:only_path => false))
68 assert_select 'url', :text => "http://www.example.com/issues/#{issue.id}"
68 assert_select 'description', :text => assigns(:results)[i].event_description
69 assert_select 'description', :text => ''
69 assert_select 'datetime'
70 assert_select 'datetime'
70 end
71 end
71 end
72 end
72 end
73 end
73 end
@@ -26,7 +26,7 class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
26 assert_response :success
26 assert_response :success
27 assert_equal 'application/xml', response.content_type
27 assert_equal 'application/xml', response.content_type
28 assert_select 'users' do
28 assert_select 'users' do
29 assert_select 'user', assigns(:users).size
29 assert_select 'user', User.active.count
30 end
30 end
31 end
31 end
32
32
@@ -37,7 +37,7 class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
37 assert_equal 'application/json', response.content_type
37 assert_equal 'application/json', response.content_type
38 json = ActiveSupport::JSON.decode(response.body)
38 json = ActiveSupport::JSON.decode(response.body)
39 assert json.key?('users')
39 assert json.key?('users')
40 assert_equal assigns(:users).size, json['users'].size
40 assert_equal User.active.count, json['users'].size
41 end
41 end
42
42
43 test "GET /users/:id.xml should return the user" do
43 test "GET /users/:id.xml should return the user" do
@@ -40,7 +40,6 class IssuesTest < Redmine::IntegrationTest
40
40
41 get '/projects/ecookbook/issues/new'
41 get '/projects/ecookbook/issues/new'
42 assert_response :success
42 assert_response :success
43 assert_template 'issues/new'
44
43
45 issue = new_record(Issue) do
44 issue = new_record(Issue) do
46 post '/projects/ecookbook/issues',
45 post '/projects/ecookbook/issues',
@@ -58,7 +57,6 class IssuesTest < Redmine::IntegrationTest
58 # check redirection
57 # check redirection
59 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
58 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
60 follow_redirect!
59 follow_redirect!
61 assert_equal issue, assigns(:issue)
62
60
63 # check issue attributes
61 # check issue attributes
64 assert_equal 'jsmith', issue.author.login
62 assert_equal 'jsmith', issue.author.login
@@ -25,7 +25,7 class ProjectsTest < Redmine::IntegrationTest
25 log_user("admin", "admin")
25 log_user("admin", "admin")
26 get "/admin/projects"
26 get "/admin/projects"
27 assert_response :success
27 assert_response :success
28 assert_template "admin/projects"
28
29 post "/projects/1/archive"
29 post "/projects/1/archive"
30 assert_redirected_to "/admin/projects"
30 assert_redirected_to "/admin/projects"
31 assert !Project.find(1).active?
31 assert !Project.find(1).active?
@@ -113,21 +113,21 class SudoModeTest < Redmine::IntegrationTest
113 assert_response :success
113 assert_response :success
114 assert_select 'h2', 'Confirm your password to continue'
114 assert_select 'h2', 'Confirm your password to continue'
115 assert_select 'form[action="/roles"]'
115 assert_select 'form[action="/roles"]'
116 assert assigns(:sudo_form).errors.blank?
116 assert_select '#flash_error', 0
117
117
118 post '/roles', role: { name: 'new role', issues_visibility: 'all' }
118 post '/roles', role: { name: 'new role', issues_visibility: 'all' }
119 assert_response :success
119 assert_response :success
120 assert_select 'h2', 'Confirm your password to continue'
120 assert_select 'h2', 'Confirm your password to continue'
121 assert_select 'form[action="/roles"]'
121 assert_select 'form[action="/roles"]'
122 assert_match /"new role"/, response.body
122 assert_select 'input[type=hidden][name=?][value=?]', 'role[name]', 'new role'
123 assert assigns(:sudo_form).errors.blank?
123 assert_select '#flash_error', 0
124
124
125 post '/roles', role: { name: 'new role', issues_visibility: 'all' }, sudo_password: 'wrong'
125 post '/roles', role: { name: 'new role', issues_visibility: 'all' }, sudo_password: 'wrong'
126 assert_response :success
126 assert_response :success
127 assert_select 'h2', 'Confirm your password to continue'
127 assert_select 'h2', 'Confirm your password to continue'
128 assert_select 'form[action="/roles"]'
128 assert_select 'form[action="/roles"]'
129 assert_match /"new role"/, response.body
129 assert_select 'input[type=hidden][name=?][value=?]', 'role[name]', 'new role'
130 assert assigns(:sudo_form).errors[:password].present?
130 assert_select '#flash_error'
131
131
132 assert_difference 'Role.count' do
132 assert_difference 'Role.count' do
133 post '/roles', role: { name: 'new role', issues_visibility: 'all', assignable: '1', permissions: %w(view_calendar) }, sudo_password: 'admin'
133 post '/roles', role: { name: 'new role', issues_visibility: 'all', assignable: '1', permissions: %w(view_calendar) }, sudo_password: 'admin'
@@ -144,16 +144,16 class SudoModeTest < Redmine::IntegrationTest
144 assert_response :success
144 assert_response :success
145 assert_select 'h2', 'Confirm your password to continue'
145 assert_select 'h2', 'Confirm your password to continue'
146 assert_select 'form[action="/my/account"]'
146 assert_select 'form[action="/my/account"]'
147 assert_match /"newmail@test\.com"/, response.body
147 assert_select 'input[type=hidden][name=?][value=?]', 'user[mail]', 'newmail@test.com'
148 assert assigns(:sudo_form).errors.blank?
148 assert_select '#flash_error', 0
149
149
150 # wrong password
150 # wrong password
151 post '/my/account', user: { mail: 'newmail@test.com' }, sudo_password: 'wrong'
151 post '/my/account', user: { mail: 'newmail@test.com' }, sudo_password: 'wrong'
152 assert_response :success
152 assert_response :success
153 assert_select 'h2', 'Confirm your password to continue'
153 assert_select 'h2', 'Confirm your password to continue'
154 assert_select 'form[action="/my/account"]'
154 assert_select 'form[action="/my/account"]'
155 assert_match /"newmail@test\.com"/, response.body
155 assert_select 'input[type=hidden][name=?][value=?]', 'user[mail]', 'newmail@test.com'
156 assert assigns(:sudo_form).errors[:password].present?
156 assert_select '#flash_error'
157
157
158 # correct password
158 # correct password
159 post '/my/account', user: { mail: 'newmail@test.com' }, sudo_password: 'jsmith'
159 post '/my/account', user: { mail: 'newmail@test.com' }, sudo_password: 'jsmith'
@@ -321,7 +321,7 module Redmine
321 get "/login"
321 get "/login"
322 assert_equal nil, session[:user_id]
322 assert_equal nil, session[:user_id]
323 assert_response :success
323 assert_response :success
324 assert_template "account/login"
324
325 post "/login", :username => login, :password => password
325 post "/login", :username => login, :password => password
326 assert_equal login, User.find(session[:user_id]).login
326 assert_equal login, User.find(session[:user_id]).login
327 end
327 end
General Comments 0
You need to be logged in to leave comments. Login now