From ec8669165941d142d4024095e5116787262e2859 Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 29 Aug 2017 12:04:00 +0200 Subject: [PATCH] fixed tests --- app/controllers/client_api/users/user_teams_controller.rb | 4 ++-- spec/models/user_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/client_api/users/user_teams_controller.rb b/app/controllers/client_api/users/user_teams_controller.rb index 6fe8f56c5..de1a39f8f 100644 --- a/app/controllers/client_api/users/user_teams_controller.rb +++ b/app/controllers/client_api/users/user_teams_controller.rb @@ -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 diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 42ede5b3e..8a118e209 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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,