Skip to content

Commit

Permalink
model tests good, controller update/create still erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirv committed Jun 15, 2017
1 parent c067c4d commit d2b5854
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
12 changes: 6 additions & 6 deletions app/models/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class Recipe < ActiveRecord::Base
# validates :directions, presence: true
# validates :ingredients, presence: true
# validates :feeds, presence: true
# validates :servings_made, presence: true
# validates :prep_times, presence: true
validates :servings_made, presence: true
validates :prep_times, presence: true
validates :name, presence: true, length: { minimum: 5, maximum: 100}
# validates :summary, presence: true, length: { minimum: 10, maximum: 150}
# validates :description, presence: true, length: { minimum: 5, maximum: 1000}
# mount_uploader :picture, PictureUploader
# validate :picture_size
validates :summary, presence: true, length: { minimum: 10, maximum: 150}
validates :description, presence: true, length: { minimum: 5, maximum: 1000}
mount_uploader :picture, PictureUploader
validate :picture_size

def thumbs_up_total
self.likes.where(like: true).size
Expand Down
29 changes: 28 additions & 1 deletion test/controllers/recipes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,36 @@ class RecipesControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end

test "should get new" do
get new_recipe_url
assert_response :success
end

test "should show recipe" do
@recipe = recipes(:one)
get recipe_url(@recipe)
assert_response :success
end

test "should get edit" do
@recipe = recipes(:one)
get edit_recipe_url(@recipe)
assert_response :success
end

test "should update recipe" do
@recipe = recipes(:one)

patch recipe_url(@recipe), params: { recipe: {id: @recipe.id,
name: @recipe.name, summary: @recipe.summary,
description: @recipe.description, prep_times: @recipe.prep_times,
servings_made: @recipe.servings_made} }
assert_redirected_to recipe_url(@recipe)
end

test "should create recipe" do
assert_difference('Recipe.count') do

# puts "\n\n Body Response #{@body.response} \n\n"
post recipes_url, params: { recipe: { name: "SOMEONE", summary: "Something Else",
description: "Something Else", prep_times: "90", servings_made: "3", user_id: "1"} }
end
Expand Down

0 comments on commit d2b5854

Please sign in to comment.