fixed tests

This commit is contained in:
zmagod 2017-08-29 12:04:00 +02:00
parent c54dd9473e
commit ec86691659
2 changed files with 4 additions and 3 deletions

View file

@ -8,7 +8,7 @@ module ClientApi
before_action :find_user_team, only: :leave_team
def leave_team
if user_cant_leave
if user_cant_leave?
unsuccess_response
else
begin
@ -28,7 +28,7 @@ module ClientApi
@user_team = UserTeam.where(team: @team, user: current_user).first
end
def user_cant_leave
def user_cant_leave?
return unless @user_team && @team
@user_team.admin? &&
@team.user_teams.where(role: 2).count <= 1

View file

@ -158,7 +158,8 @@ describe User, type: :model do
end
let(:user_two) { create :user, email: 'user2@asdf.com' }
it 'in a specific format' do
it 'in a specific format: {id: .., name: .., members: .., role: ' \
'.., current_team: .., can_be_leaved: ..}' do
create :user_team, team: team, user: user_one
expected_result = {
id: team.id,