Test stopping of Matches

This commit is contained in:
Daniel Schädler 2019-05-10 11:46:19 +02:00
parent e04d3c1c2e
commit 525c17841c
1 changed files with 21 additions and 0 deletions

View File

@ -5,6 +5,8 @@ require 'rails_helper'
RSpec.describe MatchesController, type: :controller do
before do
@match = create(:match, state: :not_started)
@tournament = create(:group_stage_tournament, stage_count: 3)
@running_playoff_match = @tournament.stages.find { |s| s.level == 3 }.matches.first
@match.match_scores = create_pair(:match_score)
end
@ -65,6 +67,25 @@ RSpec.describe MatchesController, type: :controller do
end
end
context 'as another owner' do
let(:finished) do
{
state: 'finished'
}
end
before(:each) do
apply_authentication_headers_for @running_playoff_match.owner
end
it 'stops the match' do
put :update, params: { id: @running_playoff_match.to_param }.merge(finished)
@running_playoff_match.reload
expect(response).to be_successful
expect(@running_playoff_match.state).to eq(finished[:state])
end
end
context 'as another user' do
context 'with valid params' do
before(:each) do