diff --git a/app/controllers/recipes_controller.rb b/app/controllers/recipes_controller.rb index ef47f65..97269b3 100644 --- a/app/controllers/recipes_controller.rb +++ b/app/controllers/recipes_controller.rb @@ -31,7 +31,8 @@ def new def create @recipe = Recipe.new(recipe_params) - @recipe.user = current_user + + # @recipe.user_id = current_user if @recipe.save flash[:success] = "Your recipe was created successfully!" redirect_to recipes_path @@ -94,17 +95,17 @@ def set_user # name: , summary: , description: , prep_times: , servings_made: def recipe_params - params.require(:recipe).permit(:name) + # raise recipe_params.inspect - # params.require(:recipe).permit(:id, :user_id, :name, :summary, :description, - # :prep_times, :servings_made, - # :picture, :chef_id, - # style_ids: [], - # ingredients_attributes: [:id, :name, :_destroy], - # # directions_attributes: [:id, :name, :step, :_destroy], - # feed_ids: [], - # calorie_ids: [], - # preptime_ids: []) + params.require(:recipe).permit(:id, :user_id, :name, :summary, :description, + :prep_times, :servings_made, + :picture, :chef_id, + style_ids: [], + ingredients_attributes: [:id, :name, :_destroy], + directions_attributes: [:id, :name, :step, :_destroy], + feed_ids: [], + calorie_ids: [], + preptime_ids: []) end def set_recipe diff --git a/app/views/recipes/index.html.erb b/app/views/recipes/index.html.erb index 93984c0..80e31a9 100644 --- a/app/views/recipes/index.html.erb +++ b/app/views/recipes/index.html.erb @@ -18,7 +18,7 @@
- <%= render partial: 'gravatar_section', locals: { user: recipe.user } %> +
diff --git a/test/controllers/recipes_controller_test.rb b/test/controllers/recipes_controller_test.rb index 670af27..12d7d93 100644 --- a/test/controllers/recipes_controller_test.rb +++ b/test/controllers/recipes_controller_test.rb @@ -3,18 +3,20 @@ # class RecipesControllerTest < ActionController::TestCase class RecipesControllerTest < ActionDispatch::IntegrationTest setup do - # sign_in could be @user or users(:one) if we have fixtures - @user = users(:one) + @user = User.new(username: "MYSTRING", email: "Myemail@email.com", admin: true) sign_in @user - # @recipe = recipes(:one) end - - + test "should get index" do + get '/recipes' + assert_response :success + end + test "should create recipe" do assert_difference('Recipe.count') do - post recipes_url, params: { recipe: {name: 'Test Here' } } + post recipes_url, params: { recipe: { name: "SOMEONE", summary: "Something Else", + description: "Something Else", prep_times: "90", servings_made: "3", user_id: "1"} } end assert_redirected_to recipe_path(Recipe.last)