mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-14 05:05:55 +08:00
33 lines
1.1 KiB
Ruby
33 lines
1.1 KiB
Ruby
|
require 'rails_helper'
|
||
|
|
||
|
describe ClientApi::Users::UserTeamsController, type: :controller do
|
||
|
describe 'DELETE #leave_team' do
|
||
|
login_user
|
||
|
before do
|
||
|
@user_one = User.first
|
||
|
@user_two = FactoryGirl.create(:user, email: 'sec_user@asdf.com')
|
||
|
@team = FactoryGirl.create :team
|
||
|
FactoryGirl.create :user_team, team: @team, user: @user_one, role: 2
|
||
|
end
|
||
|
|
||
|
it 'Returns HTTP success if user can leave the team' do
|
||
|
FactoryGirl.create :user_team, team: @team, user: @user_two, role: 2
|
||
|
delete :leave_team, params: { team: @team.id }, format: :json
|
||
|
expect(response).to be_success
|
||
|
expect(response).to have_http_status(200)
|
||
|
end
|
||
|
|
||
|
it 'Returns HTTP unprocessable_entity if user can\'t leave the team' do
|
||
|
delete :leave_team, params: { team: @team.id }, format: :json
|
||
|
expect(response).to_not be_success
|
||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||
|
end
|
||
|
|
||
|
it 'Returns HTTP unprocessable_entity if no params given' do
|
||
|
delete :leave_team, format: :json
|
||
|
expect(response).to_not be_success
|
||
|
expect(response).to have_http_status(:unprocessable_entity)
|
||
|
end
|
||
|
end
|
||
|
end
|