Sha256: 9298844d2d3304538b264c84638fc76208f1671ac9964ca14791c0f3536db114
Contents?: true
Size: 1.65 KB
Versions: 14
Compression:
Stored size: 1.65 KB
Contents
require 'rails_helper' describe Dummy::Sessions, type: :request do @without_authentication = true before :all do @without_authentication = true User.make! end let(:user) { User.last } context :sign_in do it "should set a user token on login" do post '/api/v1/sessions', params: { login: user.email, password: 'abc12345', token: true } response.should be_successful json['id'].to_i.should == user.id json['email'].should == user.email json['authentication_token'].should be_truthy end it "should not set a token if the login fails" do post '/api/v1/sessions', params: { login: user.email, password: 'bad password', token: true } response.should_not be_successful json['error'].should be_truthy json['error']['type'].should == 'unauthenticated' user.authentication_token.should be_nil end end context :sign_out do it "should reset a user's auth token" do user.authentication_token = "1234567890" user.save! delete "/api/v1/sessions", params: { api_key: "1234567890" } response.should be_successful user.reload user.authentication_token.should be_nil end it "signing out an already signed-out user should look fine, right?" do user.authentication_token = "1234567890" user.save! delete "/api/v1/sessions", params: { api_key: "1234567890" } response.should be_successful user.reload user.authentication_token.should be_nil delete "/api/v1/sessions", params: { api_key: "1234567890" } response.should be_successful user.reload user.authentication_token.should be_nil end end end
Version data entries
14 entries across 14 versions & 1 rubygems