Skip to content

Commit

Permalink
saving status before doing a git fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirv committed Jun 15, 2017
1 parent c71ca8a commit c067c4d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
23 changes: 12 additions & 11 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/recipes/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="col-md-2">
<section class="chef_info_center">

<%= render partial: 'gravatar_section', locals: { user: recipe.user } %>


</section>
</div>
Expand Down
14 changes: 8 additions & 6 deletions test/controllers/recipes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]", 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)
Expand Down

0 comments on commit c067c4d

Please sign in to comment.