From 2d2d6a2e9c205bf1acfb0c40e497c1d66d842bd2 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 30 Dec 2015 19:58:15 +0000 Subject: [PATCH] Fixed weights controller test --- app/controllers/weights_controller.rb | 10 ++-------- test/controllers/weights_controller_test.rb | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/app/controllers/weights_controller.rb b/app/controllers/weights_controller.rb index 90bb885..9304c31 100644 --- a/app/controllers/weights_controller.rb +++ b/app/controllers/weights_controller.rb @@ -24,7 +24,7 @@ class WeightsController < ApplicationController # GET /weights/1/edit def edit - @tournament = @weight.tournament + @tournament = Tournament.find(@weight.tournament_id) @mats = @tournament.mats end @@ -33,9 +33,6 @@ class WeightsController < ApplicationController def create @weight = Weight.new(weight_params) @tournament = Tournament.find(weight_params[:tournament_id]) - if current_user != @tournament.user - redirect_to root_path - end respond_to do |format| if @weight.save 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.json def update - @tournament = @weight.tournament - if current_user != @tournament.user - redirect_to root_path - end + @tournament = Tournament.find(@weight.tournament_id) respond_to do |format| if @weight.update(weight_params) format.html { redirect_to @tournament, notice: 'Weight was successfully updated.' } diff --git a/test/controllers/weights_controller_test.rb b/test/controllers/weights_controller_test.rb index 93c2c3c..f1c9518 100644 --- a/test/controllers/weights_controller_test.rb +++ b/test/controllers/weights_controller_test.rb @@ -18,7 +18,7 @@ class WeightsControllerTest < ActionController::TestCase end 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 def destroy