lib/rspeckled/plugins/authentication.rb in rspeckled-0.0.40 vs lib/rspeckled/plugins/authentication.rb in rspeckled-0.0.41

- old
+ new

@@ -28,14 +28,26 @@ options[:method] || :current_user else :"current_#{underscored_class_name}" end + class_instance_overrides = if options.is_a?(Hash) && options[:class_instance_overrides] + options[:class_instance_overrides] + else + {} + end + + class_instance_traits = if options.is_a?(Hash) && options[:class_instance_traits] + options[:class_instance_traits] + else + {} + end + instance = if options.is_a?(Hash) && options[:strategy] == :instance - klass.new + klass.new(class_instance_overrides) else - FactoryBot.create(underscored_class_name.to_sym) + FactoryBot.create(underscored_class_name.to_sym, *class_instance_traits, class_instance_overrides) end inferred_auth_method = if options.is_a?(Hash) && options[:authentication_method] options[:authentication_method] else @@ -79,10 +91,10 @@ else [ { 'iss' => 'rspeckled', 'own' => instance['account_id'] || instance['id'], - 'sub' => example.file_path, + 'sub' => instance.class.name, 'aud' => 'rspec', 'exp' => 1.day.from_now.utc.to_i, 'nbf' => 1.day.ago.utc.to_i, 'iat' => Time.now.utc.to_i, 'jti' => SecureRandom.uuid,