mirror of
https://github.com/redmine/redmine.git
synced 2025-11-08 06:15:59 +01:00
Use Rails 5 syntax for functional tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@16585 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -65,7 +65,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
def test_show_should_show_visible_custom_fields_only
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :show, :id => @issue.id
|
||||
get :show, :params => {
|
||||
:id => @issue.id
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
assert_select '.value', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
|
||||
@@ -79,7 +81,12 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
def test_show_should_show_visible_custom_fields_only_in_api
|
||||
@users_to_test.each do |user, fields|
|
||||
with_settings :rest_api_enabled => '1' do
|
||||
get :show, :id => @issue.id, :format => 'xml', :include => 'custom_fields', :key => user.api_key
|
||||
get :show, :params => {
|
||||
:id => @issue.id,
|
||||
:format => 'xml',
|
||||
:include => 'custom_fields',
|
||||
:key => user.api_key
|
||||
}
|
||||
end
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
@@ -98,7 +105,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :show, :id => @issue.id
|
||||
get :show, :params => {
|
||||
:id => @issue.id
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
assert_select 'ul.details i', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name} change"
|
||||
@@ -116,7 +125,12 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
with_settings :rest_api_enabled => '1' do
|
||||
get :show, :id => @issue.id, :format => 'xml', :include => 'journals', :key => user.api_key
|
||||
get :show, :params => {
|
||||
:id => @issue.id,
|
||||
:format => 'xml',
|
||||
:include => 'journals',
|
||||
:key => user.api_key
|
||||
}
|
||||
end
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
@@ -133,7 +147,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :edit, :id => @issue.id
|
||||
get :edit, :params => {
|
||||
:id => @issue.id
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
assert_select 'input[value=?]', "Value#{i}", 1, "User #{user.id} was not able to edit #{field.name}"
|
||||
@@ -149,12 +165,16 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
put :update, :id => @issue.id,
|
||||
:issue => {:custom_field_values => {
|
||||
@field1.id.to_s => "User#{user.id}Value0",
|
||||
@field2.id.to_s => "User#{user.id}Value1",
|
||||
@field3.id.to_s => "User#{user.id}Value2",
|
||||
}}
|
||||
put :update, :params => {
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => "User#{user.id}Value0",
|
||||
@field2.id.to_s => "User#{user.id}Value1",
|
||||
@field3.id.to_s => "User#{user.id}Value2",
|
||||
}
|
||||
}
|
||||
}
|
||||
@issue.reload
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
@@ -169,7 +189,9 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
def test_index_should_show_visible_custom_fields_only
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :index, :c => (["subject"] + @fields.map{|f| "cf_#{f.id}"})
|
||||
get :index, :params => {
|
||||
:c => (["subject"] + @fields.map{|f| "cf_#{f.id}"})
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
assert_select 'td', {:text => "Value#{i}", :count => 1}, "User #{user.id} was not able to view #{field.name}"
|
||||
@@ -183,7 +205,10 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
def test_index_as_csv_should_show_visible_custom_fields_only
|
||||
@users_to_test.each do |user, fields|
|
||||
@request.session[:user_id] = user.id
|
||||
get :index, :c => (["subject"] + @fields.map{|f| "cf_#{f.id}"}), :format => 'csv'
|
||||
get :index, :params => {
|
||||
:c => (["subject"] + @fields.map{|f| "cf_#{f.id}"}),
|
||||
:format => 'csv'
|
||||
}
|
||||
@fields.each_with_index do |field, i|
|
||||
if fields.include?(field)
|
||||
assert_include "Value#{i}", response.body, "User #{user.id} was not able to view #{field.name} in CSV"
|
||||
@@ -206,20 +231,29 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
Issue.generate!(:project => p1, :tracker_id => 1, :custom_field_values => {@field2.id => 'ValueC'})
|
||||
|
||||
@request.session[:user_id] = user.id
|
||||
get :index, :c => ["subject", "cf_#{@field2.id}"]
|
||||
get :index, :params => {
|
||||
:c => ["subject", "cf_#{@field2.id}"]
|
||||
}
|
||||
assert_select 'td', :text => 'ValueA'
|
||||
assert_select 'td', :text => 'ValueB', :count => 0
|
||||
assert_select 'td', :text => 'ValueC'
|
||||
|
||||
get :index, :sort => "cf_#{@field2.id}"
|
||||
get :index, :params => {
|
||||
:sort => "cf_#{@field2.id}"
|
||||
}
|
||||
# ValueB is not visible to user and ignored while sorting
|
||||
assert_equal %w(ValueB ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
||||
|
||||
get :index, :set_filter => '1', "cf_#{@field2.id}" => '*', :sort => "cf_#{@field2.id}"
|
||||
get :index, :params => {
|
||||
:set_filter => '1', "cf_#{@field2.id}" => '*',
|
||||
:sort => "cf_#{@field2.id}"
|
||||
}
|
||||
assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
||||
|
||||
CustomField.update_all(:field_format => 'list')
|
||||
get :index, :group => "cf_#{@field2.id}"
|
||||
get :index, :params => {
|
||||
:group => "cf_#{@field2.id}"
|
||||
}
|
||||
assert_equal %w(ValueA ValueC), issues_in_list.map{|i| i.custom_field_value(@field2)}
|
||||
end
|
||||
|
||||
@@ -231,15 +265,19 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :bcc_recipients => '1' do
|
||||
assert_difference 'Issue.count' do
|
||||
post :create,
|
||||
:project_id => 1,
|
||||
:issue => {
|
||||
:tracker_id => 1,
|
||||
:status_id => 1,
|
||||
:subject => 'New issue',
|
||||
:priority_id => 5,
|
||||
:custom_field_values => {@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'},
|
||||
:watcher_user_ids => users_to_test.keys.map(&:id)
|
||||
post :create, :params => {
|
||||
:project_id => 1,
|
||||
:issue => {
|
||||
:tracker_id => 1,
|
||||
:status_id => 1,
|
||||
:subject => 'New issue',
|
||||
:priority_id => 5,
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => 'Value0', @field2.id.to_s => 'Value1', @field3.id.to_s => 'Value2'
|
||||
},
|
||||
:watcher_user_ids => users_to_test.keys.map(&:id)
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
@@ -270,10 +308,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :bcc_recipients => '1' do
|
||||
put :update,
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
|
||||
put :update, :params => {
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field1.id.to_s => 'NewValue0', @field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
@@ -303,10 +345,14 @@ class IssuesCustomFieldsVisibilityTest < Redmine::ControllerTest
|
||||
ActionMailer::Base.deliveries.clear
|
||||
@request.session[:user_id] = 1
|
||||
with_settings :bcc_recipients => '1' do
|
||||
put :update,
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'}
|
||||
put :update, :params => {
|
||||
:id => @issue.id,
|
||||
:issue => {
|
||||
:custom_field_values => {
|
||||
@field2.id.to_s => 'NewValue1', @field3.id.to_s => 'NewValue2'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
assert_response 302
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user