gitlabhq/spec/requests/api/session_spec.rb

50 lines
1.3 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe Gitlab::API do
include ApiHelpers
let(:user) { create(:user) }
describe "POST /session" do
context "when valid password" do
it "should return private token" do
post api("/session"), email: user.email, password: '123456'
response.status.should == 201
json_response['email'].should == user.email
json_response['private_token'].should == user.private_token
end
end
context "when invalid password" do
it "should return authentication error" do
post api("/session"), email: user.email, password: '123'
2012-09-20 17:38:08 +02:00
response.status.should == 401
json_response['email'].should be_nil
json_response['private_token'].should be_nil
end
end
context "when empty password" do
it "should return authentication error" do
post api("/session"), email: user.email
2012-09-20 17:38:08 +02:00
response.status.should == 401
json_response['email'].should be_nil
json_response['private_token'].should be_nil
end
end
context "when empty name" do
it "should return authentication error" do
post api("/session"), password: user.password
response.status.should == 401
json_response['email'].should be_nil
json_response['private_token'].should be_nil
end
end
end
end