forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented issue zammad#1251 - Config option to have uniq email addr…
…esses for users.
- Loading branch information
Showing
9 changed files
with
207 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class UserEmailMultipleUse < ActiveRecord::Migration | ||
def up | ||
|
||
# return if it's a new setup | ||
return if !Setting.find_by(name: 'system_init_done') | ||
|
||
Setting.create_if_not_exists( | ||
title: 'User email for muliple users', | ||
name: 'user_email_multiple_use', | ||
area: 'Model::User', | ||
description: 'Allow to use email address for muliple users.', | ||
options: { | ||
form: [ | ||
{ | ||
display: '', | ||
null: true, | ||
name: 'user_email_multiple_use', | ||
tag: 'boolean', | ||
options: { | ||
true => 'yes', | ||
false => 'no', | ||
}, | ||
}, | ||
], | ||
}, | ||
state: false, | ||
preferences: { | ||
permission: ['admin'], | ||
}, | ||
frontend: false | ||
) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
login: 'admin', | ||
firstname: 'Bob', | ||
lastname: 'Smith', | ||
email: '[email protected]', | ||
email: 'bob+active_stream@example.com', | ||
password: 'some_pass', | ||
active: true, | ||
roles: roles, | ||
|
@@ -23,7 +23,7 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
end | ||
|
||
test 'ticket+user' do | ||
ticket = Ticket.create( | ||
ticket = Ticket.create!( | ||
group_id: Group.lookup(name: 'Users').id, | ||
customer_id: @current_user.id, | ||
owner_id: User.lookup(login: '-').id, | ||
|
@@ -35,7 +35,7 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
) | ||
travel 2.seconds | ||
|
||
article = Ticket::Article.create( | ||
article = Ticket::Article.create!( | ||
ticket_id: ticket.id, | ||
updated_by_id: @current_user.id, | ||
created_by_id: @current_user.id, | ||
|
@@ -86,12 +86,12 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
assert(stream.empty?) | ||
|
||
# cleanup | ||
ticket.destroy | ||
ticket.destroy! | ||
travel_back | ||
end | ||
|
||
test 'organization' do | ||
organization = Organization.create( | ||
organization = Organization.create!( | ||
name: 'some name', | ||
updated_by_id: @current_user.id, | ||
created_by_id: @current_user.id, | ||
|
@@ -125,12 +125,12 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
assert(stream.empty?) | ||
|
||
# cleanup | ||
organization.destroy | ||
organization.destroy! | ||
travel_back | ||
end | ||
|
||
test 'user with update check false' do | ||
user = User.create( | ||
user = User.create!( | ||
login: '[email protected]', | ||
email: '[email protected]', | ||
firstname: 'Bob Smith II', | ||
|
@@ -157,12 +157,12 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
assert(stream.empty?) | ||
|
||
# cleanup | ||
user.destroy | ||
user.destroy! | ||
travel_back | ||
end | ||
|
||
test 'user with update check true' do | ||
user = User.create( | ||
user = User.create!( | ||
login: '[email protected]', | ||
email: '[email protected]', | ||
firstname: 'Bob Smith II', | ||
|
@@ -204,7 +204,7 @@ class ActivityStreamTest < ActiveSupport::TestCase | |
assert(stream.empty?) | ||
|
||
# cleanup | ||
user.destroy | ||
user.destroy! | ||
travel_back | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -155,12 +155,12 @@ class HistoryTest < ActiveSupport::TestCase | |
|
||
# use transaction | ||
ActiveRecord::Base.transaction do | ||
ticket = Ticket.create(test[:ticket_create][:ticket]) | ||
ticket = Ticket.create!(test[:ticket_create][:ticket]) | ||
test[:ticket_create][:article][:ticket_id] = ticket.id | ||
article = Ticket::Article.create(test[:ticket_create][:article]) | ||
article = Ticket::Article.create!(test[:ticket_create][:article]) | ||
|
||
assert_equal(ticket.class.to_s, 'Ticket') | ||
assert_equal(article.class.to_s, 'Ticket::Article') | ||
assert_equal(ticket.class, Ticket) | ||
assert_equal(article.class, Ticket::Article) | ||
|
||
# update ticket | ||
if test[:ticket_update][:ticket] | ||
|
@@ -185,25 +185,21 @@ class HistoryTest < ActiveSupport::TestCase | |
} | ||
|
||
# delete tickets | ||
tickets.each { |ticket| | ||
ticket_id = ticket.id | ||
ticket.destroy | ||
found = Ticket.where(id: ticket_id).first | ||
assert_not(found, 'Ticket destroyed') | ||
} | ||
tickets.each(&:destroy!) | ||
end | ||
|
||
test 'user' do | ||
name = rand(999_999) | ||
tests = [ | ||
|
||
# test 1 | ||
{ | ||
user_create: { | ||
user: { | ||
login: 'some_login_test', | ||
login: "some_login_test-#{name}", | ||
firstname: 'Bob', | ||
lastname: 'Smith', | ||
email: '[email protected]', | ||
email: "somebody-#{name}@example.com", | ||
active: true, | ||
updated_by_id: current_user.id, | ||
created_by_id: current_user.id, | ||
|
@@ -213,7 +209,7 @@ class HistoryTest < ActiveSupport::TestCase | |
user: { | ||
firstname: 'Bob', | ||
lastname: 'Master', | ||
email: '[email protected]', | ||
email: "master-#{name}@example.com", | ||
active: false, | ||
}, | ||
}, | ||
|
@@ -236,8 +232,8 @@ class HistoryTest < ActiveSupport::TestCase | |
history_object: 'User', | ||
history_type: 'updated', | ||
history_attribute: 'email', | ||
value_from: '[email protected]', | ||
value_to: '[email protected]', | ||
value_from: "somebody-#{name}@example.com", | ||
value_to: "master-#{name}@example.com", | ||
}, | ||
{ | ||
result: true, | ||
|
@@ -258,9 +254,8 @@ class HistoryTest < ActiveSupport::TestCase | |
|
||
# user transaction | ||
ActiveRecord::Base.transaction do | ||
user = User.create(test[:user_create][:user]) | ||
|
||
assert_equal(user.class.to_s, 'User') | ||
user = User.create!(test[:user_create][:user]) | ||
assert_equal(user.class, User) | ||
|
||
# update user | ||
if test[:user_update][:user] | ||
|
@@ -277,12 +272,7 @@ class HistoryTest < ActiveSupport::TestCase | |
} | ||
|
||
# delete user | ||
users.each { |user| | ||
user_id = user.id | ||
user.destroy | ||
found = User.where(id: user_id).first | ||
assert_not(found, 'User destroyed') | ||
} | ||
users.each(&:destroy!) | ||
end | ||
|
||
test 'organization' do | ||
|
@@ -328,9 +318,8 @@ class HistoryTest < ActiveSupport::TestCase | |
|
||
# user transaction | ||
ActiveRecord::Base.transaction do | ||
organization = Organization.create(test[:organization_create][:organization]) | ||
|
||
assert_equal(organization.class.to_s, 'Organization') | ||
organization = Organization.create!(test[:organization_create][:organization]) | ||
assert_equal(organization.class, Organization) | ||
|
||
# update organization | ||
if test[:organization_update][:organization] | ||
|
@@ -346,12 +335,7 @@ class HistoryTest < ActiveSupport::TestCase | |
} | ||
|
||
# delete user | ||
organizations.each { |organization| | ||
organization_id = organization.id | ||
organization.destroy | ||
found = Organization.where(id: organization_id).first | ||
assert_not(found, 'Organization destroyed') | ||
} | ||
organizations.each(&:destroy!) | ||
end | ||
|
||
def history_check(history_list, history_check) | ||
|
Oops, something went wrong.