Sha256: 7eb95c851e3059cd7e81fae35daecc3ebd35a7add1fe3e7dd25c85cf0fed8944

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'

describe GoogleAuthentication::ActsAsGoogleUser do

  class DefaultUser < ActiveRecord::Base
    set_table_name :users
    acts_as_google_user
  end

  class RememberableUser < ActiveRecord::Base
    set_table_name :users
    acts_as_google_user :rememberable
  end

  class ForbiddenUser < ActiveRecord::Base
    set_table_name :users
    acts_as_google_user :database_authenticable, :recoverable
  end

  # all kind of users should include :omniauthable module
  shared_examples_for "All Users" do
    it "should have omniauthable module" do
      subject.class.devise_modules.should include(:omniauthable)
    end
  end

  describe DefaultUser do

    subject { DefaultUser.new }

    it_should_behave_like "All Users"

    it "should respond to a class method finder" do
      subject.class.respond_to?(:find_or_create_by_omniauth_uid).should be_true
    end

    it "should have only omniauthable module" do
      subject.class.devise_modules.should eql [:omniauthable]
    end
  end

  describe "Users with different devise modules" do

    describe RememberableUser do

      subject { RememberableUser.new }

      it_should_behave_like "All Users"

      it "should have rememberable module" do
        subject.class.devise_modules.should include :rememberable
      end
    end

    describe ForbiddenUser do
      subject { ForbiddenUser.new }

      it_should_behave_like "All Users"

      it "should not include forbidden modules" do
        subject.class.devise_modules.should eql [:omniauthable]
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
google_authentication-0.1.1 spec/models/acts_as_google_user_spec.rb
google_authentication-0.1.0 spec/models/acts_as_google_user_spec.rb