-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from notmarkmiranda/138-uncomplete-game-can-b…
…e-edited [138] Uncomplete game can be edited
- Loading branch information
Showing
6 changed files
with
171 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<div class="row justify-content-center"> | ||
<div class="col-md-4"> | ||
<div class="card border-primary"> | ||
<h4 class="card-header border-primary">Edit Game</h4> | ||
<div class="card-body"> | ||
<%= form_for @game do |f| %> | ||
<div class="form-group"> | ||
<%= f.label :date, 'Date' %> | ||
<%= f.date_field :date, class: 'form-control' %> | ||
</div> | ||
<div class="form-group"> | ||
<%= f.label :buy_in, 'Buy In Amount' %> | ||
<%= f.number_field :buy_in, class: 'form-control' %> | ||
</div> | ||
<%= f.hidden_field 'season_id', value: @game.season.id %> | ||
<%= f.submit 'Update Game', class: 'btn btn-outline-primary btn-block' %> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'rails_helper' | ||
|
||
describe 'Admin can edit a game' do | ||
let(:game) { create(:game, buy_in: 15, date: Date.today, completed: false) } | ||
let(:user) { game.league.user } | ||
|
||
describe 'for an admin' do | ||
|
||
describe 'for an uncomplete game' do | ||
before do | ||
stub_current_user user | ||
|
||
visit game_path(game) | ||
|
||
expect(page).to have_content "Buy In: $15" | ||
expect(page).to have_content "Date: #{Date.today.strftime('%B %-e, %Y')}" | ||
end | ||
|
||
before do | ||
click_link 'Edit Game' | ||
end | ||
|
||
it 'should update the buy in on a game' do | ||
fill_in 'Buy In Amount', with: '100' | ||
click_button 'Update Game' | ||
|
||
expect(page).to have_content "Buy In: $100" | ||
expect(page).not_to have_content "Buy In: $15" | ||
end | ||
|
||
it 'should update the date on a game' do | ||
fill_in 'Date', with: Date.tomorrow | ||
click_button 'Update Game' | ||
|
||
expect(page).to have_content "Date: #{Date.tomorrow.strftime('%B %-e, %Y')}" | ||
expect(page).not_to have_content "Date: #{Date.today.strftime('%B %-e, %Y')}" | ||
end | ||
end | ||
|
||
describe 'for a complete game' do | ||
before do | ||
game.update(completed: true) | ||
visit game_path(game) | ||
end | ||
|
||
it 'should not have a link to edit game' do | ||
expect(page).to have_content("Date: #{Date.today.strftime('%B %-e, %Y')}") | ||
expect(page).not_to have_link("Edit Game") | ||
end | ||
end | ||
end | ||
|
||
describe 'for a regular user' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters