Removed #generate_with_protected helper methods.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9471 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
95f9246a46
commit
2e3bf71e9a
|
@ -21,7 +21,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_with_a_valid_api_token
|
def test_with_a_valid_api_token
|
||||||
@user = User.generate_with_protected!
|
@user = User.generate!
|
||||||
@token = Token.create!(:user => @user, :action => 'api')
|
@token = Token.create!(:user => @user, :action => 'api')
|
||||||
|
|
||||||
get "/news.xml?key=#{@token.value}"
|
get "/news.xml?key=#{@token.value}"
|
||||||
|
@ -34,7 +34,9 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_with_valid_username_password_http_authentication
|
def test_with_valid_username_password_http_authentication
|
||||||
@user = User.generate_with_protected!(:password => 'my_password', :password_confirmation => 'my_password')
|
@user = User.generate! do |user|
|
||||||
|
user.password = 'my_password'
|
||||||
|
end
|
||||||
|
|
||||||
get "/news.xml", nil, credentials(@user.login, 'my_password')
|
get "/news.xml", nil, credentials(@user.login, 'my_password')
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
@ -46,7 +48,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_with_valid_token_http_authentication
|
def test_with_valid_token_http_authentication
|
||||||
@user = User.generate_with_protected!
|
@user = User.generate!
|
||||||
@token = Token.create!(:user => @user, :action => 'api')
|
@token = Token.create!(:user => @user, :action => 'api')
|
||||||
|
|
||||||
get "/news.xml", nil, credentials(@token.value, 'X')
|
get "/news.xml", nil, credentials(@token.value, 'X')
|
||||||
|
|
|
@ -1,18 +1,4 @@
|
||||||
module ObjectHelpers
|
module ObjectHelpers
|
||||||
# TODO: Remove these three once everyone has ported their code to use the
|
|
||||||
# new object_daddy version with protected attribute support
|
|
||||||
def User.generate_with_protected(attributes={})
|
|
||||||
User.generate(attributes)
|
|
||||||
end
|
|
||||||
|
|
||||||
def User.generate_with_protected!(attributes={})
|
|
||||||
User.generate!(attributes)
|
|
||||||
end
|
|
||||||
|
|
||||||
def User.spawn_with_protected(attributes={})
|
|
||||||
User.spawn(attributes)
|
|
||||||
end
|
|
||||||
|
|
||||||
def User.add_to_project(user, project, roles)
|
def User.add_to_project(user, project, roles)
|
||||||
roles = [roles] unless roles.is_a?(Array)
|
roles = [roles] unless roles.is_a?(Array)
|
||||||
Member.create!(:principal => user, :project => project, :roles => roles)
|
Member.create!(:principal => user, :project => project, :roles => roles)
|
||||||
|
|
|
@ -725,7 +725,7 @@ class IssueTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_recipients_should_include_the_assigned_group_members
|
def test_recipients_should_include_the_assigned_group_members
|
||||||
group_member = User.generate_with_protected!
|
group_member = User.generate!
|
||||||
group = Group.generate!
|
group = Group.generate!
|
||||||
group.users << group_member
|
group.users << group_member
|
||||||
|
|
||||||
|
@ -1212,8 +1212,8 @@ class IssueTest < ActiveSupport::TestCase
|
||||||
context "Issue#recipients" do
|
context "Issue#recipients" do
|
||||||
setup do
|
setup do
|
||||||
@project = Project.find(1)
|
@project = Project.find(1)
|
||||||
@author = User.generate_with_protected!
|
@author = User.generate!
|
||||||
@assignee = User.generate_with_protected!
|
@assignee = User.generate!
|
||||||
@issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
|
@issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -769,8 +769,8 @@ class QueryTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "include users of subprojects" do
|
should "include users of subprojects" do
|
||||||
user1 = User.generate_with_protected!
|
user1 = User.generate!
|
||||||
user2 = User.generate_with_protected!
|
user2 = User.generate!
|
||||||
project = Project.find(1)
|
project = Project.find(1)
|
||||||
Member.create!(:principal => user1, :project => project.children.visible.first, :role_ids => [1])
|
Member.create!(:principal => user1, :project => project.children.visible.first, :role_ids => [1])
|
||||||
@query.project = project
|
@query.project = project
|
||||||
|
|
|
@ -35,8 +35,8 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'object_daddy creation' do
|
test 'object_daddy creation' do
|
||||||
User.generate_with_protected!(:firstname => 'Testing connection')
|
User.generate!(:firstname => 'Testing connection')
|
||||||
User.generate_with_protected!(:firstname => 'Testing connection')
|
User.generate!(:firstname => 'Testing connection')
|
||||||
assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'})
|
assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -88,11 +88,11 @@ class UserTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
context "User#before_create" do
|
context "User#before_create" do
|
||||||
should "set the mail_notification to the default Setting" do
|
should "set the mail_notification to the default Setting" do
|
||||||
@user1 = User.generate_with_protected!
|
@user1 = User.generate!
|
||||||
assert_equal 'only_my_events', @user1.mail_notification
|
assert_equal 'only_my_events', @user1.mail_notification
|
||||||
|
|
||||||
with_settings :default_notification_option => 'all' do
|
with_settings :default_notification_option => 'all' do
|
||||||
@user2 = User.generate_with_protected!
|
@user2 = User.generate!
|
||||||
assert_equal 'all', @user2.mail_notification
|
assert_equal 'all', @user2.mail_notification
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -619,7 +619,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
context "User#api_key" do
|
context "User#api_key" do
|
||||||
should "generate a new one if the user doesn't have one" do
|
should "generate a new one if the user doesn't have one" do
|
||||||
user = User.generate_with_protected!(:api_token => nil)
|
user = User.generate!(:api_token => nil)
|
||||||
assert_nil user.api_token
|
assert_nil user.api_token
|
||||||
|
|
||||||
key = user.api_key
|
key = user.api_key
|
||||||
|
@ -629,7 +629,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the existing api token value" do
|
should "return the existing api token value" do
|
||||||
user = User.generate_with_protected!
|
user = User.generate!
|
||||||
token = Token.create!(:action => 'api')
|
token = Token.create!(:action => 'api')
|
||||||
user.api_token = token
|
user.api_token = token
|
||||||
assert user.save
|
assert user.save
|
||||||
|
@ -644,7 +644,8 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return nil if the key is found for an inactive user" do
|
should "return nil if the key is found for an inactive user" do
|
||||||
user = User.generate_with_protected!(:status => User::STATUS_LOCKED)
|
user = User.generate!
|
||||||
|
user.status = User::STATUS_LOCKED
|
||||||
token = Token.create!(:action => 'api')
|
token = Token.create!(:action => 'api')
|
||||||
user.api_token = token
|
user.api_token = token
|
||||||
user.save
|
user.save
|
||||||
|
@ -653,7 +654,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the user if the key is found for an active user" do
|
should "return the user if the key is found for an active user" do
|
||||||
user = User.generate_with_protected!(:status => User::STATUS_ACTIVE)
|
user = User.generate!
|
||||||
token = Token.create!(:action => 'api')
|
token = Token.create!(:action => 'api')
|
||||||
user.api_token = token
|
user.api_token = token
|
||||||
user.save
|
user.save
|
||||||
|
@ -781,12 +782,12 @@ class UserTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
context "#change_password_allowed?" do
|
context "#change_password_allowed?" do
|
||||||
should "be allowed if no auth source is set" do
|
should "be allowed if no auth source is set" do
|
||||||
user = User.generate_with_protected!
|
user = User.generate!
|
||||||
assert user.change_password_allowed?
|
assert user.change_password_allowed?
|
||||||
end
|
end
|
||||||
|
|
||||||
should "delegate to the auth source" do
|
should "delegate to the auth source" do
|
||||||
user = User.generate_with_protected!
|
user = User.generate!
|
||||||
|
|
||||||
allowed_auth_source = AuthSource.generate!
|
allowed_auth_source = AuthSource.generate!
|
||||||
def allowed_auth_source.allow_password_changes?; true; end
|
def allowed_auth_source.allow_password_changes?; true; end
|
||||||
|
@ -898,8 +899,8 @@ class UserTest < ActiveSupport::TestCase
|
||||||
context "Issues" do
|
context "Issues" do
|
||||||
setup do
|
setup do
|
||||||
@project = Project.find(1)
|
@project = Project.find(1)
|
||||||
@author = User.generate_with_protected!
|
@author = User.generate!
|
||||||
@assignee = User.generate_with_protected!
|
@assignee = User.generate!
|
||||||
@issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
|
@issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -914,7 +915,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be false for a user with :only_my_events and isn't an author, creator, or assignee" do
|
should "be false for a user with :only_my_events and isn't an author, creator, or assignee" do
|
||||||
@user = User.generate_with_protected!(:mail_notification => 'only_my_events')
|
@user = User.generate!(:mail_notification => 'only_my_events')
|
||||||
Member.create!(:user => @user, :project => @project, :role_ids => [1])
|
Member.create!(:user => @user, :project => @project, :role_ids => [1])
|
||||||
assert ! @user.notify_about?(@issue)
|
assert ! @user.notify_about?(@issue)
|
||||||
end
|
end
|
||||||
|
@ -960,7 +961,7 @@ class UserTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "be false for a user with :selected and is not the author or assignee" do
|
should "be false for a user with :selected and is not the author or assignee" do
|
||||||
@user = User.generate_with_protected!(:mail_notification => 'selected')
|
@user = User.generate!(:mail_notification => 'selected')
|
||||||
Member.create!(:user => @user, :project => @project, :role_ids => [1])
|
Member.create!(:user => @user, :project => @project, :role_ids => [1])
|
||||||
assert ! @user.notify_about?(@issue)
|
assert ! @user.notify_about?(@issue)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue