create new users on account's shard
closes #CORE-901 Change-Id: I3bc1ac9bd4a99feb317bc2033874b41c3fd7f126 Reviewed-on: https://gerrit.instructure.com/138758 Reviewed-by: Cody Cutrer <cody@instructure.com> Tested-by: Jenkins Product-Review: James Williams <jamesw@instructure.com> QA-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
c3bbcdebde
commit
33c7ecc1ab
|
@ -2385,7 +2385,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
@user ||= @pseudonym && @pseudonym.user
|
||||
@user ||= User.new
|
||||
@user ||= @context.shard.activate { User.new }
|
||||
|
||||
force_validations = value_to_boolean(params[:force_validations])
|
||||
manage_user_logins = @context.grants_right?(@current_user, session, :manage_user_logins)
|
||||
|
|
|
@ -834,6 +834,20 @@ describe "Users API", type: :request do
|
|||
create_user_skip_cc_confirm(@site_admin)
|
||||
end
|
||||
|
||||
context "sharding" do
|
||||
specs_require_sharding
|
||||
it "should allow creating users on cross-shard accounts" do
|
||||
@other_account = @shard1.activate { Account.create! }
|
||||
json = api_call(:post, "/api/v1/accounts/#{@other_account.id}/users",
|
||||
{ :controller => 'users', :action => 'create', :format => 'json', :account_id => @other_account.id.to_s },
|
||||
{ :user => { :name => "Test User" }, :pseudonym => { :unique_id => "test@example.com", :password => "password123"} }
|
||||
)
|
||||
new_user = User.find(json['id'])
|
||||
expect(new_user.shard).to eq @shard1
|
||||
expect(new_user.pseudonym.account).to eq @other_account
|
||||
end
|
||||
end
|
||||
|
||||
it "respects authentication_provider_id" do
|
||||
ap = Account.site_admin.authentication_providers.create!(auth_type: 'facebook')
|
||||
api_call(:post, "/api/v1/accounts/#{Account.site_admin.id}/users",
|
||||
|
|
Loading…
Reference in New Issue