diff --git a/.travis.yml b/.travis.yml index 4bbe45a7..485a1ebf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ gemfile: - gemfiles/ruby_1.9.3_rails_3.2.gemfile rvm: - "1.9.3" - - "2.2.2" + - "2.6.3" - ruby-head matrix: allow_failures: @@ -18,7 +18,7 @@ matrix: gemfile: gemfiles/rails_5_devise_4.gemfile - rvm: 1.9.3 gemfile: gemfiles/rails_4_devise_3.gemfile - - rvm: 2.2.2 + - rvm: 2.6.3 gemfile: gemfiles/ruby_1.9.3_rails_3.2.gemfile - rvm: ruby-head gemfile: gemfiles/rails_4_devise_3.gemfile diff --git a/README.md b/README.md index 842c4e48..3185fb39 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,7 @@ Simple Token Authentication [![Gem Version](https://badge.fury.io/rb/simple_token_authentication.svg)](http://badge.fury.io/rb/simple_token_authentication) [![Build Status](https://travis-ci.org/gonzalo-bulnes/simple_token_authentication.svg?branch=master)](https://travis-ci.org/gonzalo-bulnes/simple_token_authentication) [![Code Climate](https://codeclimate.com/github/gonzalo-bulnes/simple_token_authentication.svg)](https://codeclimate.com/github/gonzalo-bulnes/simple_token_authentication) -[![Dependency Status](https://gemnasium.com/gonzalo-bulnes/simple_token_authentication.svg)](https://gemnasium.com/gonzalo-bulnes/simple_token_authentication) -[![security](https://hakiri.io/github/gonzalo-bulnes/simple_token_authentication/master.svg)](https://hakiri.io/github/gonzalo-bulnes/simple_token_authentication/master) +[![Security](https://hakiri.io/github/gonzalo-bulnes/simple_token_authentication/master.svg)](https://hakiri.io/github/gonzalo-bulnes/simple_token_authentication/master) [![Inline docs](http://inch-ci.org/github/gonzalo-bulnes/simple_token_authentication.svg?branch=master)](http://inch-ci.org/github/gonzalo-bulnes/simple_token_authentication) Token authentication support has been removed from [Devise][devise] for security reasons. In [this gist][original-gist], Devise's [José Valim][josevalim] explains how token authentication should be performed in order to remain safe. diff --git a/lib/simple_token_authentication/adapters/mongoid_adapter.rb b/lib/simple_token_authentication/adapters/mongoid_adapter.rb index 1d7ef6ea..0d2599b2 100644 --- a/lib/simple_token_authentication/adapters/mongoid_adapter.rb +++ b/lib/simple_token_authentication/adapters/mongoid_adapter.rb @@ -1,13 +1,20 @@ -require 'mongoid' -require 'simple_token_authentication/adapter' +if Module.const_defined?('ActiveModel') && + ActiveModel.const_defined?('Serializers') && + ActiveModel::Serializers.const_defined?('Xml') + # As far as I know Mongoid doesn't support Rails 6 + # Please let me know if this isn't true when you read it! -module SimpleTokenAuthentication - module Adapters - class MongoidAdapter - extend SimpleTokenAuthentication::Adapter + require 'mongoid' + require 'simple_token_authentication/adapter' - def self.base_class - ::Mongoid::Document + module SimpleTokenAuthentication + module Adapters + class MongoidAdapter + extend SimpleTokenAuthentication::Adapter + + def self.base_class + ::Mongoid::Document + end end end end diff --git a/spec/lib/simple_token_authentication/adapters/mongoid_adapter_spec.rb b/spec/lib/simple_token_authentication/adapters/mongoid_adapter_spec.rb index 35c1d48c..0d9c299c 100644 --- a/spec/lib/simple_token_authentication/adapters/mongoid_adapter_spec.rb +++ b/spec/lib/simple_token_authentication/adapters/mongoid_adapter_spec.rb @@ -1,21 +1,28 @@ -require 'spec_helper' -require 'simple_token_authentication/adapters/mongoid_adapter' +if Module.const_defined?('ActiveModel') && + ActiveModel.const_defined?('Serializers') && + ActiveModel::Serializers.const_defined?('Xml') + # As far as I know Mongoid doesn't support Rails 6 + # Please let me know if this isn't true when you read it! -describe 'SimpleTokenAuthentication::Adapters::MongoidAdapter' do + require 'spec_helper' + require 'simple_token_authentication/adapters/mongoid_adapter' - before(:each) do - stub_const('Mongoid', Module.new) - stub_const('Mongoid::Document', double()) + describe 'SimpleTokenAuthentication::Adapters::MongoidAdapter' do - @subject = SimpleTokenAuthentication::Adapters::MongoidAdapter - end + before(:each) do + stub_const('Mongoid', Module.new) + stub_const('Mongoid::Document', double()) + + @subject = SimpleTokenAuthentication::Adapters::MongoidAdapter + end - it_behaves_like 'an adapter' + it_behaves_like 'an adapter' - describe '.base_class' do + describe '.base_class' do - it 'is Mongoid::Document', private: true do - expect(@subject.base_class).to eq Mongoid::Document + it 'is Mongoid::Document', private: true do + expect(@subject.base_class).to eq Mongoid::Document + end end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index aa31a447..5518ab57 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,6 @@ require 'action_controller' require 'active_record' -require 'mongoid' require 'active_support' require 'simple_token_authentication'