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
|
||||
|
||||
def test_with_a_valid_api_token
|
||||
@user = User.generate_with_protected!
|
||||
@user = User.generate!
|
||||
@token = Token.create!(:user => @user, :action => 'api')
|
||||
|
||||
get "/news.xml?key=#{@token.value}"
|
||||
|
@ -34,7 +34,9 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
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')
|
||||
assert_response :unauthorized
|
||||
|
@ -46,7 +48,7 @@ class ApiTest::DisabledRestApiTest < ActionController::IntegrationTest
|
|||
end
|
||||
|
||||
def test_with_valid_token_http_authentication
|
||||
@user = User.generate_with_protected!
|
||||
@user = User.generate!
|
||||
@token = Token.create!(:user => @user, :action => 'api')
|
||||
|
||||
get "/news.xml", nil, credentials(@token.value, 'X')
|
||||
|
|
|
@ -1,18 +1,4 @@
|
|||
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)
|
||||
roles = [roles] unless roles.is_a?(Array)
|
||||
Member.create!(:principal => user, :project => project, :roles => roles)
|
||||
|
|
|
@ -725,7 +725,7 @@ class IssueTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_recipients_should_include_the_assigned_group_members
|
||||
group_member = User.generate_with_protected!
|
||||
group_member = User.generate!
|
||||
group = Group.generate!
|
||||
group.users << group_member
|
||||
|
||||
|
@ -1212,8 +1212,8 @@ class IssueTest < ActiveSupport::TestCase
|
|||
context "Issue#recipients" do
|
||||
setup do
|
||||
@project = Project.find(1)
|
||||
@author = User.generate_with_protected!
|
||||
@assignee = User.generate_with_protected!
|
||||
@author = User.generate!
|
||||
@assignee = User.generate!
|
||||
@issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
|
||||
end
|
||||
|
||||
|
|
|
@ -769,8 +769,8 @@ class QueryTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should "include users of subprojects" do
|
||||
user1 = User.generate_with_protected!
|
||||
user2 = User.generate_with_protected!
|
||||
user1 = User.generate!
|
||||
user2 = User.generate!
|
||||
project = Project.find(1)
|
||||
Member.create!(:principal => user1, :project => project.children.visible.first, :role_ids => [1])
|
||||
@query.project = project
|
||||
|
|
|
@ -35,8 +35,8 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
test 'object_daddy creation' do
|
||||
User.generate_with_protected!(:firstname => 'Testing connection')
|
||||
User.generate_with_protected!(:firstname => 'Testing connection')
|
||||
User.generate!(:firstname => 'Testing connection')
|
||||
User.generate!(:firstname => 'Testing connection')
|
||||
assert_equal 2, User.count(:all, :conditions => {:firstname => 'Testing connection'})
|
||||
end
|
||||
|
||||
|
@ -88,11 +88,11 @@ class UserTest < ActiveSupport::TestCase
|
|||
|
||||
context "User#before_create" 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
|
||||
|
||||
with_settings :default_notification_option => 'all' do
|
||||
@user2 = User.generate_with_protected!
|
||||
@user2 = User.generate!
|
||||
assert_equal 'all', @user2.mail_notification
|
||||
end
|
||||
end
|
||||
|
@ -619,7 +619,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
|
||||
context "User#api_key" 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
|
||||
|
||||
key = user.api_key
|
||||
|
@ -629,7 +629,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
should "return the existing api token value" do
|
||||
user = User.generate_with_protected!
|
||||
user = User.generate!
|
||||
token = Token.create!(:action => 'api')
|
||||
user.api_token = token
|
||||
assert user.save
|
||||
|
@ -644,7 +644,8 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
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')
|
||||
user.api_token = token
|
||||
user.save
|
||||
|
@ -653,7 +654,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
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')
|
||||
user.api_token = token
|
||||
user.save
|
||||
|
@ -781,12 +782,12 @@ class UserTest < ActiveSupport::TestCase
|
|||
|
||||
context "#change_password_allowed?" do
|
||||
should "be allowed if no auth source is set" do
|
||||
user = User.generate_with_protected!
|
||||
user = User.generate!
|
||||
assert user.change_password_allowed?
|
||||
end
|
||||
|
||||
should "delegate to the auth source" do
|
||||
user = User.generate_with_protected!
|
||||
user = User.generate!
|
||||
|
||||
allowed_auth_source = AuthSource.generate!
|
||||
def allowed_auth_source.allow_password_changes?; true; end
|
||||
|
@ -898,8 +899,8 @@ class UserTest < ActiveSupport::TestCase
|
|||
context "Issues" do
|
||||
setup do
|
||||
@project = Project.find(1)
|
||||
@author = User.generate_with_protected!
|
||||
@assignee = User.generate_with_protected!
|
||||
@author = User.generate!
|
||||
@assignee = User.generate!
|
||||
@issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
|
||||
end
|
||||
|
||||
|
@ -914,7 +915,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
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])
|
||||
assert ! @user.notify_about?(@issue)
|
||||
end
|
||||
|
@ -960,7 +961,7 @@ class UserTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
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])
|
||||
assert ! @user.notify_about?(@issue)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue