mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-18 21:56:55 -04:00
select garden/crop based on params - BROKEN TESTSwq
This commit is contained in:
@@ -8,10 +8,10 @@
|
||||
|
||||
.control-group
|
||||
= f.label 'What did you plant?', :class => 'control-label'
|
||||
.controls= collection_select(:planting, :crop_id, Crop.all(:order => :system_name), :id, :system_name)
|
||||
.controls= collection_select(:planting, :crop_id, Crop.all(:order => :system_name), :id, :system_name, :selected => params[:crop_id])
|
||||
.control-group
|
||||
= f.label 'Where did you plant it?', :class => 'control-label'
|
||||
.controls= collection_select(:planting, :garden_id, Garden.where(:user_id => current_user), :id, :name)
|
||||
.controls= collection_select(:planting, :garden_id, Garden.where(:user_id => current_user), :id, :name, :selected => params[:garden_id])
|
||||
.control-group
|
||||
= f.label 'When?', :class => 'control-label'
|
||||
.controls= f.datetime_select :planted_at, options = { :include_blank => true }, html_options = { :class => "span1" }
|
||||
|
||||
@@ -23,13 +23,43 @@ describe "plantings/new" do
|
||||
:password => "irrelevant")
|
||||
@user.confirm!
|
||||
sign_in @user
|
||||
render
|
||||
|
||||
# create gardens and crops to populate dropdowns
|
||||
@garden1 = Garden.create!(
|
||||
:id => 1,
|
||||
:user_id => @user.id,
|
||||
:name => 'Garden1'
|
||||
)
|
||||
@garden2 = Garden.create!(
|
||||
:id => 2,
|
||||
:user_id => @user.id,
|
||||
:name => 'Garden2'
|
||||
)
|
||||
|
||||
@crop1 = Crop.create!(
|
||||
:id => 1,
|
||||
:system_name => 'Tomato',
|
||||
:en_wikipedia_url => 'http://blah'
|
||||
)
|
||||
@crop2 = Crop.create!(
|
||||
:id => 2,
|
||||
:system_name => 'Corn',
|
||||
:en_wikipedia_url => 'http://blah'
|
||||
)
|
||||
@crop3 = Crop.create!(
|
||||
:id => 3,
|
||||
:system_name => 'Chard',
|
||||
:en_wikipedia_url => 'http://blah'
|
||||
)
|
||||
|
||||
# params to test default choice of crop and garden
|
||||
# XXX this is very wrong! but we are still trying to figure out
|
||||
# how to do it the right way. commiting as is, for now.
|
||||
render :template => 'plantings/new',
|
||||
:params => { :crop_id => 2, :garden_id => 2 }
|
||||
end
|
||||
|
||||
it "renders new planting form" do
|
||||
render
|
||||
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => plantings_path, :method => "post" do
|
||||
assert_select "select#planting_garden_id", :name => "planting[garden_id]"
|
||||
assert_select "select#planting_crop_id", :name => "planting[crop_id]"
|
||||
@@ -37,5 +67,15 @@ describe "plantings/new" do
|
||||
assert_select "textarea#planting_description", :name => "planting[description]"
|
||||
end
|
||||
end
|
||||
|
||||
it "selects a crop given in a param" do
|
||||
assert_select "select#planting_crop_id",
|
||||
:html => /option value="2" selected="selected"/
|
||||
end
|
||||
|
||||
it "selects a garden given in a param" do
|
||||
assert_select "select#planting_garden_id",
|
||||
:html => /option value="2" selected="selected"/
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user