Sha256: 92ace6acdfc32b4d481d3faf8e7ba0e11f0e314a9d5926d8377e6f9a6e8b1e4d

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'rails_helper'

module SocialFramework
  RSpec.describe Users::SessionsController, type: :controller do
    include Devise::TestHelpers
    routes {SocialFramework::Engine.routes}

    describe "Authentication with login or username" do
      it "Authentication when login equals username" do
        user = create(:user)
        
        request.env["devise.mapping"] = Devise.mappings[:user]
        post :create, user: {
          login: "user", password: "password"
        }

        expect(response).to have_http_status(302)
      end

      it "Authentication when login equals email" do
        user = create(:user)
        
        request.env["devise.mapping"] = Devise.mappings[:user]
        post :create, user: {
          login: "user@email.com", password: "password"
        }

        expect(response).to have_http_status(302)
      end

      it "Logout" do
        user = create(:user)
        request.env["devise.mapping"] = Devise.mappings[:user]
        post :create, user: {
          login: "user@email.com", password: "password"
        }
        delete :destroy
        expect(response).to have_http_status(302)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
social_framework-1.0.1 spec/controllers/social_framework/sessions_controller_spec.rb