@@ -64,12 +64,12 @@ def attribute_map
6464
6565 it "looks up the user by the configured default user key" do
6666 user = Model . new ( new_record : false )
67- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 67+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 6868 expect ( Model . authenticate_with_saml ( response , nil ) ) . to eq ( user )
6969 end
7070
7171 it "returns nil if it cannot find a user" do
72- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 72+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 7373 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
7474 end
7575
@@ -83,12 +83,12 @@ def attribute_map
8383
8484 it "looks up the user by the configured default user key" do
8585 user = Model . new ( new_record : false )
86- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 86+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 8787 expect ( Model . authenticate_with_saml ( response , nil ) ) . to eq ( user )
8888 end
8989
9090 it "returns nil if it cannot find a user" do
91- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 91+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 9292 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
9393 end
9494
@@ -98,7 +98,7 @@ def attribute_map
9898 end
9999
100100 it "creates and returns a new user with the name identifier and given attributes" do
101- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 101+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 102102 model = Model . authenticate_with_saml ( response , nil )
103103 expect ( model . email ) . to eq ( '[email protected] ' ) 104104 expect ( model . name ) . to eq ( 'A User' )
@@ -114,7 +114,7 @@ def attribute_map
114114
115115 context "when the proc returns true" do
116116 it "creates and returns a new user with the name identifier and given attributes" do
117- expect ( Model ) . to receive ( :where ) . with ( email : name_id ) . and_return ( [ ] )
117+ expect ( Model ) . to receive ( :where ) . with ( { email : name_id } ) . and_return ( [ ] )
118118 model = Model . authenticate_with_saml ( response , nil )
119119 expect ( model . email ) . to eq ( '[email protected] ' ) 120120 expect ( model . name ) . to eq ( 'A User' )
@@ -126,7 +126,7 @@ def attribute_map
126126 let ( :name_id ) { '[email protected] ' } 127127
128128 it "does not creates new user" do
129- expect ( Model ) . to receive ( :where ) . with ( email : name_id ) . and_return ( [ ] )
129+ expect ( Model ) . to receive ( :where ) . with ( { email : name_id } ) . and_return ( [ ] )
130130 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
131131 end
132132 end
@@ -139,7 +139,7 @@ def attribute_map
139139
140140 it "creates and returns a new user with the name identifier and given attributes" do
141141 user = Model . new ( email :
"[email protected] " , name :
"old name" , new_record :
false ) 142- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 142+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 143143 model = Model . authenticate_with_saml ( response , nil )
144144 expect ( model . email ) . to eq ( '[email protected] ' ) 145145 expect ( model . name ) . to eq ( 'A User' )
@@ -157,7 +157,7 @@ def attribute_map
157157
158158 context "when the proc returns true" do
159159 it "updates user with given attributes" do
160- expect ( Model ) . to receive ( :where ) . with ( email : name_id ) . and_return ( [ user ] )
160+ expect ( Model ) . to receive ( :where ) . with ( { email : name_id } ) . and_return ( [ user ] )
161161 model = Model . authenticate_with_saml ( response , nil )
162162 expect ( model . email ) . to eq ( '[email protected] ' ) 163163 expect ( model . name ) . to eq ( 'A User' )
@@ -169,7 +169,7 @@ def attribute_map
169169 let ( :name_id ) { '[email protected] ' } 170170
171171 it "does not update user" do
172- expect ( Model ) . to receive ( :where ) . with ( email : name_id ) . and_return ( [ user ] )
172+ expect ( Model ) . to receive ( :where ) . with ( { email : name_id } ) . and_return ( [ user ] )
173173 model = Model . authenticate_with_saml ( response , nil )
174174 expect ( model . email ) . to eq ( '[email protected] ' ) 175175 expect ( model . name ) . to eq ( 'old name' )
@@ -185,7 +185,7 @@ def attribute_map
185185 end
186186
187187 it "creates and returns a new user with the given attributes" do
188- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 188+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 189189 model = Model . authenticate_with_saml ( response , nil )
190190 expect ( model . email ) . to eq ( '[email protected] ' ) 191191 expect ( model . name ) . to eq ( 'A User' )
@@ -204,7 +204,7 @@ def attribute_map
204204 let ( :response ) { double ( :response , issuers : [ 'to_create_idp' ] , attributes : attributes , name_id : name_id ) }
205205
206206 it "creates and returns a new user with the name identifier and given attributes" do
207- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 207+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 208208 model = Model . authenticate_with_saml ( response , nil )
209209 expect ( model . email ) . to eq ( '[email protected] ' ) 210210 expect ( model . name ) . to eq ( 'A User' )
@@ -216,7 +216,7 @@ def attribute_map
216216 let ( :response ) { double ( :response , issuers : [ 'do_not_create_idp' ] , attributes : attributes , name_id : name_id ) }
217217
218218 it "does not creates new user" do
219- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 219+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 220220 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
221221 end
222222 end
@@ -228,13 +228,13 @@ def attribute_map
228228 end
229229
230230 it "returns nil if the user is not found" do
231- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 231+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 232232 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
233233 end
234234
235235 it "updates the attributes if the user is found" do
236236 user = Model . new ( email :
"[email protected] " , name :
"old name" , new_record :
false ) 237- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 237+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 238238 model = Model . authenticate_with_saml ( response , nil )
239239 expect ( model . email ) . to eq ( '[email protected] ' ) 240240 expect ( model . name ) . to eq ( 'A User' )
@@ -254,7 +254,7 @@ def attribute_map
254254 let ( :response ) { double ( :response , issuers : [ 'to_update_idp' ] , attributes : attributes , name_id : name_id ) }
255255
256256 it "updates user with given attributes" do
257- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 257+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 258258 model = Model . authenticate_with_saml ( response , nil )
259259 expect ( model . email ) . to eq ( '[email protected] ' ) 260260 expect ( model . name ) . to eq ( 'A User' )
@@ -266,7 +266,7 @@ def attribute_map
266266 let ( :response ) { double ( :response , issuers : [ 'do_not_update_idp' ] , attributes : attributes , name_id : name_id ) }
267267
268268 it "does not update user" do
269- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 269+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 270270 model = Model . authenticate_with_saml ( response , nil )
271271 expect ( model . email ) . to eq ( '[email protected] ' ) 272272 expect ( model . name ) . to eq ( 'old name' )
@@ -282,7 +282,7 @@ def attribute_map
282282
283283 it "looks up the user with a downcased value" do
284284 user = Model . new ( new_record : false )
285- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 285+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 286286 expect ( Model . authenticate_with_saml ( response , nil ) ) . to eq ( user )
287287 end
288288 end
@@ -320,7 +320,7 @@ def attribute_map
320320 end
321321
322322 it "returns the user" do
323- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 323+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 324324 expect ( Model . authenticate_with_saml ( response , nil ) ) . to eq ( user )
325325 end
326326 end
@@ -331,7 +331,7 @@ def attribute_map
331331 end
332332
333333 it "returns nil" do
334- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 334+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 335335 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
336336 end
337337 end
@@ -354,7 +354,7 @@ def attribute_map
354354 end
355355
356356 it "returns the user" do
357- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 357+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 358358 expect ( Model . authenticate_with_saml ( response , nil ) ) . to eq ( user )
359359 end
360360 end
@@ -365,7 +365,7 @@ def attribute_map
365365 end
366366
367367 it "returns nil" do
368- expect ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ user ] ) 368+ expect ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ user ] ) 369369 expect ( Model . authenticate_with_saml ( response , nil ) ) . to be_nil
370370 end
371371 end
@@ -412,7 +412,7 @@ def attribute_map
412412 end
413413
414414 def configure_hook ( &block )
415- allow ( Model ) . to receive ( :where ) . with ( email :
'[email protected] ' ) . and_return ( [ ] ) 415+ allow ( Model ) . to receive ( :where ) . with ( { email :
'[email protected] ' } ) . and_return ( [ ] ) 416416 allow ( Devise ) . to receive ( :saml_default_user_key ) . and_return ( :email )
417417 allow ( Devise ) . to receive ( :saml_create_user ) . and_return ( true )
418418 allow ( Devise ) . to receive ( :saml_update_resource_hook ) . and_return ( block )
@@ -423,7 +423,7 @@ def configure_hook(&block)
423423 let ( :name_id ) { 'SomeUsername' }
424424
425425 it "can replicate the default behaviour for a new user in a custom locator" do
426- allow ( Model ) . to receive ( :where ) . with ( email : attributes [ 'saml-email-format' ] ) . and_return ( [ ] )
426+ allow ( Model ) . to receive ( :where ) . with ( { email : attributes [ 'saml-email-format' ] } ) . and_return ( [ ] )
427427
428428 configure_hook do |model , saml_response , auth_value |
429429 Devise . saml_default_resource_locator . call ( model , saml_response , auth_value )
@@ -439,7 +439,7 @@ def configure_hook(&block)
439439 user = Model . new ( email : attributes [ 'saml-email-format' ] , name : attributes [ 'saml-name-format' ] )
440440 user . save!
441441
442- allow ( Model ) . to receive ( :where ) . with ( email : attributes [ 'saml-email-format' ] ) . and_return ( [ user ] )
442+ allow ( Model ) . to receive ( :where ) . with ( { email : attributes [ 'saml-email-format' ] } ) . and_return ( [ user ] )
443443
444444 configure_hook do |model , saml_response , auth_value |
445445 Devise . saml_default_resource_locator . call ( model , saml_response , auth_value )
@@ -453,7 +453,7 @@ def configure_hook(&block)
453453 end
454454
455455 it "can change the default behaviour for a new user from the saml response" do
456- allow ( Model ) . to receive ( :where ) . with ( foo : attributes [ 'saml-email-format' ] , bar : name_id ) . and_return ( [ ] )
456+ allow ( Model ) . to receive ( :where ) . with ( { foo : attributes [ 'saml-email-format' ] , bar : name_id } ) . and_return ( [ ] )
457457
458458 configure_hook do |model , saml_response , auth_value |
459459 name_id = saml_response . raw_response . name_id
@@ -470,7 +470,7 @@ def configure_hook(&block)
470470 user = Model . new ( email : attributes [ 'saml-email-format' ] , name : attributes [ 'saml-name-format' ] )
471471 user . save!
472472
473- allow ( Model ) . to receive ( :where ) . with ( foo : attributes [ 'saml-email-format' ] , bar : name_id ) . and_return ( [ user ] )
473+ allow ( Model ) . to receive ( :where ) . with ( { foo : attributes [ 'saml-email-format' ] , bar : name_id } ) . and_return ( [ user ] )
474474
475475 configure_hook do |model , saml_response , auth_value |
476476 name_id = saml_response . raw_response . name_id
0 commit comments