mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-22 23:14:28 -04:00
Set planting owner automatically in controller
This commit is contained in:
1 parent
475a402133
commit
ff2a3cf8b2
2 files changed
+6
No files matched your search
@@ -58,6 +58,7 @@ class PlantingsController < ApplicationController
|
||||
# POST /plantings
|
||||
# POST /plantings.json
|
||||
def create
|
||||
params[:planting][:owner_id] = current_member.id
|
||||
params[:planted_at] = parse_date(params[:planted_at])
|
||||
@planting = Planting.new(params[:planting])
|
||||
|
||||
|
||||
@@ -49,6 +49,11 @@ describe PlantingsController do
|
||||
assigns(:planting).planted_at.should == Date.today
|
||||
end
|
||||
|
||||
it "sets the owner automatically" do
|
||||
post :create, { :planting => valid_attributes }
|
||||
assigns(:planting).owner.should eq subject.current_member
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user