mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-24 08:52:14 -04:00
Added description field to gardens
This commit is contained in:
@@ -2,7 +2,7 @@ class Garden < ActiveRecord::Base
|
||||
extend FriendlyId
|
||||
friendly_id :garden_slug, use: :slugged
|
||||
|
||||
attr_accessible :name, :slug, :owner_id
|
||||
attr_accessible :name, :slug, :owner_id, :description
|
||||
belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id'
|
||||
has_many :plantings, :order => 'created_at DESC'
|
||||
has_many :crops, :through => :plantings
|
||||
|
||||
@@ -9,5 +9,8 @@
|
||||
.control_group
|
||||
= f.label "Garden name: ", :class => 'control-label'
|
||||
.controls= f.text_field :name
|
||||
.control-group
|
||||
= f.label 'Description', :class => 'control-label'
|
||||
.controls= f.text_area :description, :rows => 6
|
||||
.form-actions
|
||||
= f.submit 'Save', :class => 'btn'
|
||||
|
||||
@@ -2,12 +2,7 @@
|
||||
|
||||
- if member_signed_in?
|
||||
- if current_member == @garden.owner
|
||||
= form_for @garden, :html => {:class => "form-horizontal"} do |f|
|
||||
.control-group
|
||||
= f.label :name, :class => "control-label"
|
||||
.controls= f.text_field :name
|
||||
.form-actions
|
||||
= f.submit "Save", :class => 'btn'
|
||||
= render "form"
|
||||
- else
|
||||
.alert You aren't allowed to edit this garden.
|
||||
- else
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
= link_to 'New', new_garden_path, :class => 'btn'
|
||||
|
||||
.span9
|
||||
%div
|
||||
:markdown
|
||||
#{@garden.description}
|
||||
|
||||
- if current_member == @garden.owner
|
||||
%p= link_to "Plant something", new_planting_path(:garden_id => @garden.id), :class => 'btn btn-large btn-primary'
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
%div{:class => ['tab-pane', first_garden ? 'active' : ''], :id => "garden#{g.id}"}
|
||||
- first_garden = false
|
||||
|
||||
%div
|
||||
:markdown
|
||||
#{g.description}
|
||||
|
||||
%h3 What's planted here?
|
||||
- g.featured_plantings.each do |p|
|
||||
= render :partial => "plantings/thumbnail", :locals => { :planting => p, :hide_description => true }
|
||||
|
||||
5
db/migrate/20130118031942_add_description_to_gardens.rb
Normal file
5
db/migrate/20130118031942_add_description_to_gardens.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddDescriptionToGardens < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :gardens, :description, :text
|
||||
end
|
||||
end
|
||||
11
db/schema.rb
11
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130113095802) do
|
||||
ActiveRecord::Schema.define(:version => 20130118031942) do
|
||||
|
||||
create_table "crops", :force => true do |t|
|
||||
t.string "system_name", :null => false
|
||||
@@ -25,11 +25,12 @@ ActiveRecord::Schema.define(:version => 20130113095802) do
|
||||
add_index "crops", ["system_name"], :name => "index_crops_on_system_name"
|
||||
|
||||
create_table "gardens", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.string "name", :null => false
|
||||
t.integer "owner_id"
|
||||
t.string "slug", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "slug", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.text "description"
|
||||
end
|
||||
|
||||
add_index "gardens", ["owner_id"], :name => "index_gardens_on_user_id"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :garden do
|
||||
name 'Springfield Community Garden'
|
||||
description "This is a **totally** cool garden"
|
||||
owner
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,10 @@ describe Garden do
|
||||
@garden.garden_slug.should == "member1-springfield-community-garden"
|
||||
end
|
||||
|
||||
it "should have a description" do
|
||||
@garden.description.should == "This is a **totally** cool garden"
|
||||
end
|
||||
|
||||
it "should have an owner" do
|
||||
@garden.owner.should be_an_instance_of Member
|
||||
end
|
||||
|
||||
@@ -23,6 +23,7 @@ describe "gardens/edit" do
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => gardens_path(@garden), :method => "post" do
|
||||
assert_select "input#garden_name", :name => "garden[name]"
|
||||
assert_select "textarea#garden_description", :name => "garden[description]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,6 +11,7 @@ describe "gardens/new" do
|
||||
# Run the generator again with the --webrat flag if you want to use webrat matchers
|
||||
assert_select "form", :action => gardens_path, :method => "post" do
|
||||
assert_select "input#garden_name", :name => "garden[name]"
|
||||
assert_select "textarea#garden_description", :name => "garden[description]"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,14 @@ describe "gardens/show" do
|
||||
render
|
||||
end
|
||||
|
||||
it 'should show the description' do
|
||||
rendered.should contain "totally cool garden"
|
||||
end
|
||||
|
||||
it 'renders markdown in the description' do
|
||||
assert_select "strong", "totally"
|
||||
end
|
||||
|
||||
it 'should show plantings on the garden page' do
|
||||
rendered.should contain @planting.crop.system_name
|
||||
end
|
||||
|
||||
@@ -24,6 +24,14 @@ describe "members/show" do
|
||||
assert_select "li.active>a", :text => "Garden"
|
||||
end
|
||||
|
||||
it 'shows the garden description' do
|
||||
rendered.should contain "totally cool garden"
|
||||
end
|
||||
|
||||
it 'renders markdown in the garden description' do
|
||||
assert_select "strong", "totally"
|
||||
end
|
||||
|
||||
it "shows the plantings in the garden" do
|
||||
rendered.should contain @planting.crop.system_name
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user