- <%= f.label "Final Score" %> Also put pin time here if applicable. If default or forfeit, leave blank. Example: 7-2, 17-2, or 2:34
- <%= f.text_field :score %>
-
<%= f.submit onclick: "return confirm('Is the name of the winner ' + document.getElementById('match_winner_id').options[document.getElementById('match_winner_id').selectedIndex].text + '?')", :class=>"btn btn-success" %>
-
-
-<% end %>
-
-
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/matches/_matchstats.html.erb b/app/views/matches/_matchstats.html.erb
new file mode 100644
index 0000000..25e29f5
--- /dev/null
+++ b/app/views/matches/_matchstats.html.erb
@@ -0,0 +1,232 @@
+<%= form_for(@match) do |f| %>
+ <% if @match.errors.any? %>
+
+
<%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:
+
+
+ <% @match.errors.full_messages.each do |msg| %>
+
<%= msg %>
+ <% end %>
+
+
+ <% end %>
+
Bout <%= @match.bout_number %>
+
+
+
+
Name: <%= @w1.name %>
+ School: <%= @w1.school.name %>
+ Last Match: <%= if @w1.last_match != nil then time_ago_in_words(@w1.last_match.updated_at) else "N/A" end%>
+
Name: <%= @w2.name %>
+ School: <%= @w2.school.name %>
+ Last Match: <%= if @w2.last_match != nil then time_ago_in_words(@w2.last_match.updated_at) else "N/A" end%>
+ <%= f.label "Final Score" %> Also put pin time here if applicable. If default or forfeit, leave blank. Example: 7-2, 17-2, or 2:34
+ <%= f.text_field :score %>
+
+ <%= f.submit onclick: "return confirm('Is the name of the winner ' + document.getElementById('match_winner_id').options[document.getElementById('match_winner_id').selectedIndex].text + '?')", :class=>"btn btn-success" %>
+
+
+<% end %>
+
+
\ No newline at end of file
diff --git a/app/views/matches/edit.html.erb b/app/views/matches/edit.html.erb
index ac81e15..2d34363 100644
--- a/app/views/matches/edit.html.erb
+++ b/app/views/matches/edit.html.erb
@@ -1,2 +1 @@
-
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 253dc52..cdfcdb9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -69,6 +69,8 @@ Wrestling::Application.routes.draw do
match "/delayed_job" => DelayedJobWeb, :anchor => false, :via => [:get, :post]
+ get "/matches/:id/stat" => "matches#stat", :as => :stat_match_path
+
# Example of regular route:
# get 'products/:id' => 'catalog#view'
diff --git a/test/controllers/matches_controller_test.rb b/test/controllers/matches_controller_test.rb
index 2c5c2d3..4428c79 100644
--- a/test/controllers/matches_controller_test.rb
+++ b/test/controllers/matches_controller_test.rb
@@ -21,6 +21,15 @@ class MatchesControllerTest < ActionController::TestCase
def get_edit
get :edit, params: { id: @match.id }
end
+
+ def post_update_from_match_stat
+ get :stat, params: { id: @match.id }
+ patch :update, params: { id: @match.id, match: {tournament_id: 1, mat_id: 1} }
+ end
+
+ def get_stat
+ get :stat, params: { id: @match.id }
+ end
def sign_in_owner
sign_in users(:one)
@@ -73,6 +82,17 @@ class MatchesControllerTest < ActionController::TestCase
redirect
end
+ test "logged school delegate should not get stat match page if not owner" do
+ sign_in_school_delegate
+ get_stat
+ redirect
+ end
+
+ test "non logged in user should not get stat match page" do
+ get_stat
+ redirect
+ end
+
test "non logged in user should get post update match" do
post_update
assert_redirected_to '/static_pages/not_allowed'
@@ -95,6 +115,12 @@ class MatchesControllerTest < ActionController::TestCase
get_edit
success
end
+
+ test "logged in tournament delegate should get stat match page" do
+ sign_in_tournament_delegate
+ get_stat
+ success
+ end
test "logged in tournament delegate should post update match" do
sign_in_tournament_delegate
@@ -107,4 +133,10 @@ class MatchesControllerTest < ActionController::TestCase
post_update_from_match_edit
assert_redirected_to "/tournaments/#{@tournament.id}/matches"
end
+
+ test "should redirect to all matches when posting a match update from match stat" do
+ sign_in_owner
+ post_update_from_match_stat
+ assert_redirected_to "/tournaments/#{@tournament.id}/matches"
+ end
end