Skip to content

Commit

Permalink
added creation test to recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirv committed Jun 16, 2017
1 parent 49bb5f5 commit 2794016
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
2 changes: 0 additions & 2 deletions app/models/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ class Recipe < ActiveRecord::Base
has_many :reviews
has_many :comments, as: :commentable

# has_many :recipe_feeds


# searchkick
accepts_nested_attributes_for :ingredients,
Expand Down
42 changes: 29 additions & 13 deletions test/controllers/recipes_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'test_helper'

# class RecipesControllerTest < ActionController::TestCase
class RecipesControllerTest < ActionDispatch::IntegrationTest
setup do
@user = User.new(username: "MYSTRING", email: "[email protected]", admin: true)
Expand Down Expand Up @@ -31,18 +30,35 @@ class RecipesControllerTest < ActionDispatch::IntegrationTest

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

patch recipe_url(@recipe), recipe: {
name: "This is a name",
summary: @recipe.summary,
description: @recipe.description,
prep_times: @recipe.prep_times,
servings_made: @recipe.servings_made,
feeds: 3,
user_id: 1,
calories: 15
}
@recipe = recipes(:one)
patch recipe_url(@recipe), recipe: {
name: "This is a name",
summary: @recipe.summary,
description: @recipe.description,
prep_times: @recipe.prep_times,
servings_made: @recipe.servings_made,
feeds: 3,
user_id: 1,
calories: 15
}
assert_redirected_to recipe_url(@recipe)
end

test "should create recipe" do
sign_in @user
@recipe = recipes(:one)
assert_difference('Recipe.count') do
post recipes_url, recipe: {
name: "This is a name",
summary: @recipe.summary,
description: @recipe.description,
prep_times: @recipe.prep_times,
servings_made: @recipe.servings_made,
feeds: 3,
user_id: 1,
calories: 15
}
end
assert_redirected_to recipes_path
end
end

0 comments on commit 2794016

Please sign in to comment.