Sha256: c03953e2989da36ddb7f7b3c72251348ea598b3800969ef1c7c5caa9b5ff113f

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

describe SessionsController, :omniauth do

  before do
    request.env['omniauth.auth'] = auth_mock
  end

  describe "#create" do

    it "creates a user" do
      expect {post :create, provider: :twitter}.to change{ User.count }.by(1)
    end

    it "creates a session" do
      expect(session[:user_id]).to be_nil
      post :create, provider: :twitter
      expect(session[:user_id]).not_to be_nil
    end

    it "redirects the user to the user profile" do
      post :create, provider: :twitter
      expect(response).to redirect_to edit_user_path(1)
    end

  end

  describe "#destroy" do

    before do
      post :create, provider: :twitter
    end

    it "resets the session" do
      expect(session[:user_id]).not_to be_nil
      delete :destroy
      expect(session[:user_id]).to be_nil
    end

    it "redirects to the home page" do
      delete :destroy
      expect(response).to redirect_to root_url
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_apps_testing-0.3.4 lib/generators/testing/configure/templates/spec/omniauth/controllers/sessions_controller_spec.rb
rails_apps_testing-0.3.3 lib/generators/testing/configure/templates/spec/omniauth/controllers/sessions_controller_spec.rb