about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-28 00:06:52 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-03-28 00:06:52 +0200
commitff2cbc07530d87132af09900b4d0c9ada9d3e716 (patch)
treea821b80cd89de35c6cc99b256b04975723c4e4dd /spec
parentc38ad208c361cc77e2fa305a0e929f35363c0fcd (diff)
Remember me enabled by default
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/auth/sessions_controller_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/controllers/auth/sessions_controller_spec.rb b/spec/controllers/auth/sessions_controller_spec.rb
new file mode 100644
index 000000000..004a44fba
--- /dev/null
+++ b/spec/controllers/auth/sessions_controller_spec.rb
@@ -0,0 +1,31 @@
+require 'rails_helper'
+
+RSpec.describe Auth::SessionsController, type: :controller do
+  describe 'GET #new' do
+    before do
+      request.env["devise.mapping"] = Devise.mappings[:user]
+    end
+
+    it 'returns http success' do
+      get :new
+      expect(response).to have_http_status(:success)
+    end
+  end
+
+  describe 'POST #create' do
+    let(:user) { Fabricate(:user, email: 'foo@bar.com', password: 'abcdefgh') }
+
+    before do
+      request.env["devise.mapping"] = Devise.mappings[:user]
+      post :create, user: { email: user.email, password: user.password }
+    end
+
+    it 'redirects to home page' do
+      expect(response).to redirect_to(root_path)
+    end
+
+    it 'logs the user in' do
+      expect(controller.current_user).to eq user
+    end
+  end
+end