1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-09 07:39:06 +00:00

Fixed weights controller test

This commit is contained in:
2015-12-30 19:58:15 +00:00
parent 9fb1615120
commit 2d2d6a2e9c
2 changed files with 3 additions and 9 deletions

View File

@@ -24,7 +24,7 @@ class WeightsController < ApplicationController
# GET /weights/1/edit # GET /weights/1/edit
def edit def edit
@tournament = @weight.tournament @tournament = Tournament.find(@weight.tournament_id)
@mats = @tournament.mats @mats = @tournament.mats
end end
@@ -33,9 +33,6 @@ class WeightsController < ApplicationController
def create def create
@weight = Weight.new(weight_params) @weight = Weight.new(weight_params)
@tournament = Tournament.find(weight_params[:tournament_id]) @tournament = Tournament.find(weight_params[:tournament_id])
if current_user != @tournament.user
redirect_to root_path
end
respond_to do |format| respond_to do |format|
if @weight.save if @weight.save
format.html { redirect_to @tournament, notice: 'Weight was successfully created.' } format.html { redirect_to @tournament, notice: 'Weight was successfully created.' }
@@ -50,10 +47,7 @@ class WeightsController < ApplicationController
# PATCH/PUT /weights/1 # PATCH/PUT /weights/1
# PATCH/PUT /weights/1.json # PATCH/PUT /weights/1.json
def update def update
@tournament = @weight.tournament @tournament = Tournament.find(@weight.tournament_id)
if current_user != @tournament.user
redirect_to root_path
end
respond_to do |format| respond_to do |format|
if @weight.update(weight_params) if @weight.update(weight_params)
format.html { redirect_to @tournament, notice: 'Weight was successfully updated.' } format.html { redirect_to @tournament, notice: 'Weight was successfully updated.' }

View File

@@ -18,7 +18,7 @@ class WeightsControllerTest < ActionController::TestCase
end end
def post_update def post_update
patch :update, id: @weight.id, weight: {name: @weight.max, tournament_id: @weight.tournament_id} patch :update, id: @weight.id, weight: {max: @weight.max, tournament_id: @weight.tournament_id}
end end
def destroy def destroy