summaryrefslogtreecommitdiff
path: root/spec/controllers/sessions_controller_spec.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-03-04 10:37:33 -0700
committermo khan <mo@mokhan.ca>2015-03-04 10:37:33 -0700
commit79460595c8d1a3517944c7f63909b57873fc0d51 (patch)
tree058563166745b03921dce6629963750d334292c3 /spec/controllers/sessions_controller_spec.rb
parent79e8bd92a4f67eaefa3e19981ab44cbbf04093da (diff)
add a happy day scenario test.
Diffstat (limited to 'spec/controllers/sessions_controller_spec.rb')
-rw-r--r--spec/controllers/sessions_controller_spec.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
new file mode 100644
index 0000000..be81527
--- /dev/null
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+
+RSpec.describe SessionsController, type: :controller do
+ describe "GET #new" do
+ it "returns http success" do
+ get :new
+ expect(response).to have_http_status(:success)
+ end
+
+ it "loads a new user" do
+ get :new
+ expect(assigns(:user)).to be_new_record
+ end
+ end
+
+ describe "GET #create" do
+ context "when credentials are valid" do
+ let(:user) { create(:user) }
+
+ before { get :create, username: user.username, password: 'password' }
+
+ it "creates a new session for the user" do
+ expect(session[:x]).to eql(user.id)
+ end
+
+ it "redirects the user to the dashboard" do
+ expect(response).to redirect_to(agents_path)
+ end
+ end
+ end
+
+ describe "GET #destroy" do
+ it "returns http success" do
+ get :destroy
+ expect(response).to have_http_status(:success)
+ end
+ end
+end