From 9fc50fa4b9febb567ce24967d97ad7b29bfec403 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 8 Apr 2015 15:32:20 +0200 Subject: [PATCH] Changed behavior to return the User instead of just only its id. --- lib/auto_wizzard.rb | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/auto_wizzard.rb b/lib/auto_wizzard.rb index b359b2ef3..a0e7ab971 100644 --- a/lib/auto_wizzard.rb +++ b/lib/auto_wizzard.rb @@ -10,9 +10,9 @@ there is an example file 'contrib/auto_wizzard_example.json' returns - the id of the first created User if a 'auto_wizzard.json' file was found and processed, containing at least one entry in Users + the first created User if a 'auto_wizzard.json' file was found and processed, containing at least one entry in Users - 1 if a 'auto_wizzard.json' file was found and processed, containing no Users + the User with id 1 (NULL) if a 'auto_wizzard.json' file was found and processed, containing no Users nil if no 'auto_wizzard.json' file was found @@ -28,7 +28,7 @@ returns auto_wizzard_hash = JSON.parse(auto_wizzard_file) - admin_user_id = 1 + admin_user = User.find( 1 ) # create Users if auto_wizzard_hash['Users'] @@ -45,8 +45,8 @@ returns :active => true, :roles => roles, :groups => groups, - :updated_by_id => admin_user_id, - :created_by_id => admin_user_id + :updated_by_id => admin_user.id, + :created_by_id => admin_user.id } ) @@ -55,10 +55,9 @@ returns ) # use first created user as admin - next if admin_user_id != 1 - - admin_user_id = created_user.id + next if admin_user.id != 1 + admin_user = created_user } end @@ -79,8 +78,8 @@ returns email_address_data_symbolized = email_address_data_symbolized.merge( { - :updated_by_id => admin_user_id, - :created_by_id => admin_user_id + :updated_by_id => admin_user.id, + :created_by_id => admin_user.id } ) @@ -90,6 +89,6 @@ returns } end - admin_user_id + admin_user end end \ No newline at end of file