diff --git a/Appraisals b/Appraisals deleted file mode 100644 index 646795d..0000000 --- a/Appraisals +++ /dev/null @@ -1,19 +0,0 @@ - -appraise "rails7.2" do - gem "rails", "~> 7.2" - gem "mongoid", "~> 9" - gem "sqlite3" -end - -appraise "rails8.0" do - gem "rails", "~> 8.0.0" - gem "mongoid", "~> 9" - gem "sqlite3" -end - -appraise "rails8.1" do - gem "rails", "~> 8.1.0" - gem "mongoid", "~> 9" - gem "sqlite3" -end - diff --git a/lib/tiddle/strategy.rb b/lib/tiddle/strategy.rb index 69e99bd..8a7fb18 100644 --- a/lib/tiddle/strategy.rb +++ b/lib/tiddle/strategy.rb @@ -53,7 +53,11 @@ def model_name end def authentication_keys - mapping.to.authentication_keys + if mapping.to.authentication_keys.is_a?(Hash) + mapping.to.authentication_keys.keys + else + mapping.to.authentication_keys + end end def touch_token(token) diff --git a/spec/strategy_spec.rb b/spec/strategy_spec.rb index 87e20a2..9418153 100644 --- a/spec/strategy_spec.rb +++ b/spec/strategy_spec.rb @@ -181,6 +181,35 @@ end end + describe "when authentication_keys is a hash" do + before do + Devise.setup do |config| + config.authentication_keys = { email: true } + end + + @user = User.create!( + email: "test@example.com", + password: "12345678" + ) + @token = Tiddle.create_and_return_token(@user, FakeRequest.new) + end + + after do + Devise.setup do |config| + config.authentication_keys = [:email] + end + end + + it "allows to access endpoints which require authentication with valid \ + nick name and token" do + get( + secrets_path, + headers: { "X-USER-EMAIL" => "test@example.com", "X-USER-TOKEN" => @token } + ) + expect(response.status).to eq 200 + end + end + context "when token has expires_in set up" do before do @user = User.create!(email: "test@example.com", password: "12345678") diff --git a/spec/support/backend.rb b/spec/support/backend.rb index 48ae73c..1a0c556 100644 --- a/spec/support/backend.rb +++ b/spec/support/backend.rb @@ -23,11 +23,7 @@ def migrate! # Do initial migration path = File.expand_path("../rails_app_active_record/db/migrate/", File.dirname(__FILE__)) - schema_migration = ::ActiveRecord::SchemaMigration.new( - ActiveRecord::Tasks::DatabaseTasks.migration_connection_pool - ) - - ::ActiveRecord::MigrationContext.new(path, schema_migration).migrate + ActiveRecord::MigrationContext.new(path).migrate end end diff --git a/tiddle.gemspec b/tiddle.gemspec index 3d6f06b..44a6d74 100644 --- a/tiddle.gemspec +++ b/tiddle.gemspec @@ -23,9 +23,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake", "~> 13" spec.add_development_dependency "rspec-rails" spec.add_development_dependency "simplecov" - spec.add_development_dependency "appraisal" spec.add_development_dependency "rubocop" - spec.add_development_dependency "database_cleaner" spec.add_development_dependency "database_cleaner-active_record" spec.add_development_dependency "database_cleaner-mongoid" end