"
+ end
+ output.html_safe
+ end
+ end
+end
diff --git a/app/helpers/harvests_helper.rb b/app/helpers/harvests_helper.rb
index b5f335db9..b5f695a9d 100644
--- a/app/helpers/harvests_helper.rb
+++ b/app/helpers/harvests_helper.rb
@@ -18,11 +18,11 @@ module HarvestsHelper
def display_human_quantity(harvest)
if ! harvest.quantity.blank? && harvest.quantity > 0
if harvest.unit == 'individual' # just the number
- number_to_human(harvest.quantity, :strip_insignificant_zeros => true)
+ number_to_human(harvest.quantity, strip_insignificant_zeros: true)
elsif ! harvest.unit.blank? # pluralize anything else
- return pluralize(number_to_human(harvest.quantity, :strip_insignificant_zeros => true), harvest.unit)
+ return pluralize(number_to_human(harvest.quantity, strip_insignificant_zeros: true), harvest.unit)
else
- return "#{number_to_human(harvest.quantity, :strip_insignificant_zeros => true)} #{harvest.unit}"
+ return "#{number_to_human(harvest.quantity, strip_insignificant_zeros: true)} #{harvest.unit}"
end
else
return nil
@@ -31,10 +31,18 @@ module HarvestsHelper
def display_weight(harvest)
if ! harvest.weight_quantity.blank? && harvest.weight_quantity > 0
- return "#{number_to_human(harvest.weight_quantity, :strip_insignificant_zeros => true)} #{harvest.weight_unit}"
+ return "#{number_to_human(harvest.weight_quantity, strip_insignificant_zeros: true)} #{harvest.weight_unit}"
else
return nil
end
end
+ def display_harvest_description(harvest)
+ if harvest.description.empty?
+ "No description provided."
+ else
+ harvest.description
+ end
+ end
+
end
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index dab53df95..bb3695851 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -2,15 +2,10 @@ module NotificationsHelper
def reply_link(notification)
if notification.post
# comment on the post in question
- new_comment_url(:post_id => notification.post.id)
+ new_comment_url(post_id: notification.post.id)
else
# by default, reply link sends a PM in return
- new_notification_url(
- :recipient_id => notification.sender.id,
- :subject => notification.subject =~ /^Re: / ?
- notification.subject :
- "Re: " + notification.subject
- )
+ reply_notification_url(notification)
end
end
end
diff --git a/app/helpers/plantings_helper.rb b/app/helpers/plantings_helper.rb
new file mode 100644
index 000000000..fb6e2e7dc
--- /dev/null
+++ b/app/helpers/plantings_helper.rb
@@ -0,0 +1,45 @@
+module PlantingsHelper
+
+ def display_days_before_maturity(planting)
+ if planting.finished?
+ 0
+ elsif !planting.finished_at.nil?
+ ((p = planting.finished_at - DateTime.now).to_i) <= 0 ? 0 : p.to_i
+ elsif planting.days_before_maturity.nil?
+ "unknown"
+ else
+ ((p = (planting.planted_at + planting.days_before_maturity) - DateTime.now).to_i <= 0) ? 0 : p.to_i
+ end
+ end
+
+ def display_finished(planting)
+ if !planting.finished_at.nil?
+ planting.finished_at
+ elsif planting.finished
+ "Yes (no date specified)"
+ else
+ "(no date specified)"
+ end
+ end
+
+ def display_planted_from(planting)
+ !planting.planted_from.blank? ? planting.planted_from : "not specified"
+ end
+
+ def display_planting_quantity(planting)
+ !planting.quantity.blank? ? planting.quantity : "not specified"
+ end
+
+ def display_planting(planting)
+ if planting.quantity.to_i > 0 && planting.planted_from.present?
+ return "#{planting.owner} planted #{pluralize(planting.quantity, planting.planted_from)}."
+ elsif planting.quantity.to_i > 0
+ return "#{planting.owner} planted #{pluralize(planting.quantity, 'unit')}."
+ elsif planting.planted_from.present?
+ return "#{planting.owner} planted #{planting.planted_from.pluralize}."
+ else
+ return "#{planting.owner}."
+ end
+ end
+
+end
diff --git a/app/helpers/seeds_helper.rb b/app/helpers/seeds_helper.rb
new file mode 100644
index 000000000..2d4f5a299
--- /dev/null
+++ b/app/helpers/seeds_helper.rb
@@ -0,0 +1,11 @@
+module SeedsHelper
+
+ def display_seed_description(seed)
+ if seed.description.nil?
+ "no description provided."
+ else
+ truncate(seed.description, length: 130, separator: ' ', omission: '... ') { link_to "Read more", seed_path(seed) }
+ end
+ end
+
+end
\ No newline at end of file
diff --git a/app/mailers/notifier.rb b/app/mailers/notifier.rb
index 53bae3092..e7f1a9e8b 100644
--- a/app/mailers/notifier.rb
+++ b/app/mailers/notifier.rb
@@ -2,12 +2,23 @@ class Notifier < ActionMailer::Base
include NotificationsHelper
default from: "Growstuff "
+ def verifier()
+ if ENV['RAILS_SECRET_TOKEN']
+ return ActiveSupport::MessageVerifier.new(ENV['RAILS_SECRET_TOKEN'])
+ else
+ raise "RAILS_SECRET_TOKEN environment variable not set - have you created config/application.yml?"
+ end
+ end
+
def notify(notification)
@notification = notification
@reply_link = reply_link(@notification)
- mail(:to => @notification.recipient.email,
- :subject => @notification.subject)
+ # Encrypting
+ @signed_message = verifier.generate ({ member_id: @notification.recipient.id, type: :send_notification_email })
+
+ mail(to: @notification.recipient.email,
+ subject: @notification.subject)
end
def planting_reminder(member)
@@ -16,25 +27,28 @@ class Notifier < ActionMailer::Base
@plantings = @member.plantings.first(5)
@harvests = @member.harvests.first(5)
+ # Encrypting
+ @signed_message = verifier.generate ({ member_id: @member.id, type: :send_planting_reminder })
+
if @member.send_planting_reminder
- mail(:to => @member.email,
- :subject => "What have you planted lately?")
+ mail(to: @member.email,
+ subject: "What have you planted lately?")
end
end
def new_crop_request(member, request)
@member, @request = member, request
- mail(:to => @member.email, :subject => "#{@request.requester.login_name} has requested #{@request.name} as a new crop")
+ mail(to: @member.email, subject: "#{@request.requester.login_name} has requested #{@request.name} as a new crop")
end
def crop_request_approved(member, crop)
@member, @crop = member, crop
- mail(:to => @member.email, :subject => "#{crop.name.capitalize} has been approved")
+ mail(to: @member.email, subject: "#{crop.name.capitalize} has been approved")
end
def crop_request_rejected(member, crop)
@member, @crop = member, crop
- mail(:to => @member.email, :subject => "#{crop.name.capitalize} has been rejected")
+ mail(to: @member.email, subject: "#{crop.name.capitalize} has been rejected")
end
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 1997ddf49..96b4ea69e 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -24,7 +24,7 @@ class Ability
# nobody should be able to view unapproved crops unless they
# are wranglers or admins
cannot :read, Crop
- can :read, Crop, :approval_status => "approved"
+ can :read, Crop, approval_status: "approved"
# scientific names should only be viewable if associated crop is approved
cannot :read, ScientificName
can :read, ScientificName do |sn|
@@ -38,14 +38,15 @@ class Ability
if member
# members can see even rejected or pending crops if they requested it
- can :read, Crop, :requester_id => member.id
+ can :read, Crop, requester_id: member.id
# managing your own user settings
- can :update, Member, :id => member.id
+ can :update, Member, id: member.id
# can read/delete notifications that were sent to them
- can :read, Notification, :recipient_id => member.id
- can :destroy, Notification, :recipient_id => member.id
+ can :read, Notification, recipient_id: member.id
+ can :destroy, Notification, recipient_id: member.id
+ can :reply, Notification, recipient_id: member.id
# can send a private message to anyone but themselves
# note: sadly, we can't test for this from the view, but it works
# for the model/controller
@@ -67,58 +68,58 @@ class Ability
# can create & destroy their own authentications against other sites.
can :create, Authentication
- can :destroy, Authentication, :member_id => member.id
+ can :destroy, Authentication, member_id: member.id
# anyone can create a post, or comment on a post,
# but only the author can edit/destroy it.
can :create, Post
- can :update, Post, :author_id => member.id
- can :destroy, Post, :author_id => member.id
+ can :update, Post, author_id: member.id
+ can :destroy, Post, author_id: member.id
can :create, Comment
- can :update, Comment, :author_id => member.id
- can :destroy, Comment, :author_id => member.id
+ can :update, Comment, author_id: member.id
+ can :destroy, Comment, author_id: member.id
# same deal for gardens and plantings
can :create, Garden
- can :update, Garden, :owner_id => member.id
- can :destroy, Garden, :owner_id => member.id
+ can :update, Garden, owner_id: member.id
+ can :destroy, Garden, owner_id: member.id
can :create, Planting
- can :update, Planting, :garden => { :owner_id => member.id }
- can :destroy, Planting, :garden => { :owner_id => member.id }
+ can :update, Planting, garden: { owner_id: member.id }
+ can :destroy, Planting, garden: { owner_id: member.id }
can :create, Harvest
- can :update, Harvest, :owner_id => member.id
- can :destroy, Harvest, :owner_id => member.id
+ can :update, Harvest, owner_id: member.id
+ can :destroy, Harvest, owner_id: member.id
can :create, Photo
- can :update, Photo, :owner_id => member.id
- can :destroy, Photo, :owner_id => member.id
+ can :update, Photo, owner_id: member.id
+ can :destroy, Photo, owner_id: member.id
can :create, Seed
- can :update, Seed, :owner_id => member.id
- can :destroy, Seed, :owner_id => member.id
+ can :update, Seed, owner_id: member.id
+ can :destroy, Seed, owner_id: member.id
# orders/shop/etc
can :create, Order
- can :read, Order, :member_id => member.id
- can :complete, Order, :member_id => member.id, :completed_at => nil
- can :checkout, Order, :member_id => member.id, :completed_at => nil
- can :cancel, Order, :member_id => member.id, :completed_at => nil
- can :destroy, Order, :member_id => member.id, :completed_at => nil
+ can :read, Order, member_id: member.id
+ can :complete, Order, member_id: member.id, completed_at: nil
+ can :checkout, Order, member_id: member.id, completed_at: nil
+ can :cancel, Order, member_id: member.id, completed_at: nil
+ can :destroy, Order, member_id: member.id, completed_at: nil
can :create, OrderItem
# for now, let's not let people mess with individual order items
- cannot :read, OrderItem, :order => { :member_id => member.id }
- cannot :update, OrderItem, :order => { :member_id => member.id, :completed_at => nil }
- cannot :destroy, OrderItem, :order => { :member_id => member.id, :completed_at => nil }
+ cannot :read, OrderItem, order: { member_id: member.id }
+ cannot :update, OrderItem, order: { member_id: member.id, completed_at: nil }
+ cannot :destroy, OrderItem, order: { member_id: member.id, completed_at: nil }
# following/unfollowing permissions
can :create, Follow
- cannot :create, Follow, :followed_id => member.id # can't follow yourself
+ cannot :create, Follow, followed_id: member.id # can't follow yourself
can :destroy, Follow
- cannot :destroy, Follow, :followed_id => member.id # can't unfollow yourself
+ cannot :destroy, Follow, followed_id: member.id # can't unfollow yourself
if member.has_role? :admin
diff --git a/app/models/account.rb b/app/models/account.rb
index 547fc57bf..bfbf60e5d 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -2,8 +2,8 @@ class Account < ActiveRecord::Base
belongs_to :member
belongs_to :account_type
- validates :member_id, :uniqueness => {
- :message => 'already has account details associated with it'
+ validates :member_id, uniqueness: {
+ message: 'already has account details associated with it'
}
before_create do |account|
diff --git a/app/models/alternate_name.rb b/app/models/alternate_name.rb
index cb6f79e9d..30923bfac 100644
--- a/app/models/alternate_name.rb
+++ b/app/models/alternate_name.rb
@@ -1,5 +1,5 @@
class AlternateName < ActiveRecord::Base
- after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop }
+ after_commit { |an| an.crop.__elasticsearch__.index_document if an.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" }
belongs_to :crop
- belongs_to :creator, :class_name => 'Member'
+ belongs_to :creator, class_name: 'Member'
end
diff --git a/app/models/comment.rb b/app/models/comment.rb
index f7da18842..e649eb2b4 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -1,5 +1,5 @@
class Comment < ActiveRecord::Base
- belongs_to :author, :class_name => 'Member'
+ belongs_to :author, class_name: 'Member'
belongs_to :post
default_scope { order("created_at DESC") }
@@ -11,11 +11,11 @@ class Comment < ActiveRecord::Base
# don't send notifications to yourself
if recipient != sender
Notification.create(
- :recipient_id => recipient,
- :sender_id => sender,
- :subject => "#{self.author} commented on #{self.post.subject}",
- :body => self.body,
- :post_id => self.post.id
+ recipient_id: recipient,
+ sender_id: sender,
+ subject: "#{self.author} commented on #{self.post.subject}",
+ body: self.body,
+ post_id: self.post.id
)
end
end
diff --git a/app/models/crop.rb b/app/models/crop.rb
index 1f514f3ce..ec7dc7d0d 100644
--- a/app/models/crop.rb
+++ b/app/models/crop.rb
@@ -4,41 +4,42 @@ class Crop < ActiveRecord::Base
has_many :scientific_names, after_add: :update_index, after_remove: :update_index
accepts_nested_attributes_for :scientific_names,
- :allow_destroy => true,
- :reject_if => :all_blank
+ allow_destroy: true,
+ reject_if: :all_blank
- has_many :alternate_names, after_add: :update_index, after_remove: :update_index
+ has_many :alternate_names, after_add: :update_index, after_remove: :update_index, dependent: :destroy
has_many :plantings
- has_many :photos, :through => :plantings
+ has_many :photos, through: :plantings
has_many :seeds
has_many :harvests
- has_many :plant_parts, -> { uniq }, :through => :harvests
- belongs_to :creator, :class_name => 'Member'
- belongs_to :requester, :class_name => 'Member'
+ has_many :plant_parts, -> { uniq }, through: :harvests
+ belongs_to :creator, class_name: 'Member'
+ belongs_to :requester, class_name: 'Member'
- belongs_to :parent, :class_name => 'Crop'
- has_many :varieties, :class_name => 'Crop', :foreign_key => 'parent_id'
+ belongs_to :parent, class_name: 'Crop'
+ has_many :varieties, class_name: 'Crop', foreign_key: 'parent_id'
has_and_belongs_to_many :posts
before_destroy {|crop| crop.posts.clear}
default_scope { order("lower(name) asc") }
- scope :recent, -> { where(:approval_status => "approved").reorder("created_at desc") }
- scope :toplevel, -> { where(:approval_status => "approved", :parent_id => nil) }
- scope :popular, -> { where(:approval_status => "approved").reorder("plantings_count desc, lower(name) asc") }
- scope :randomized, -> { where(:approval_status => "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql
- scope :pending_approval, -> { where(:approval_status => "pending") }
- scope :rejected, -> { where(:approval_status => "rejected") }
+ scope :recent, -> { where(approval_status: "approved").reorder("created_at desc") }
+ scope :toplevel, -> { where(approval_status: "approved", parent_id: nil) }
+ scope :popular, -> { where(approval_status: "approved").reorder("plantings_count desc, lower(name) asc") }
+ scope :randomized, -> { where(approval_status: "approved").reorder('random()') } # ok on sqlite and psql, but not on mysql
+ scope :pending_approval, -> { where(approval_status: "pending") }
+ scope :approved, -> { where(approval_status: "approved") }
+ scope :rejected, -> { where(approval_status: "rejected") }
## Wikipedia urls are only necessary when approving a crop
validates :en_wikipedia_url,
- :format => {
- :with => /\Ahttps?:\/\/en\.wikipedia\.org\/wiki/,
- :message => 'is not a valid English Wikipedia URL'
+ format: {
+ with: /\Ahttps?:\/\/en\.wikipedia\.org\/wiki/,
+ message: 'is not a valid English Wikipedia URL'
},
- :if => :approved?
+ if: :approved?
## Reasons are only necessary when rejecting
- validates :reason_for_rejection, :presence => true, :if => :rejected?
+ validates :reason_for_rejection, presence: true, if: :rejected?
## This validation addresses a race condition
validate :approval_status_cannot_be_changed_again
@@ -76,6 +77,7 @@ class Crop < ActiveRecord::Base
mappings dynamic: 'false' do
indexes :id, type: 'long'
indexes :name, type: 'string', analyzer: 'gs_edgeNGram_analyzer'
+ indexes :approval_status, type: 'string'
indexes :scientific_names do
indexes :scientific_name,
type: 'string',
@@ -92,7 +94,7 @@ class Crop < ActiveRecord::Base
def as_indexed_json(options={})
self.as_json(
- only: [:id, :name],
+ only: [:id, :name, :approval_status],
include: {
scientific_names: { only: :scientific_name },
alternate_names: { only: :name }
@@ -114,7 +116,7 @@ class Crop < ActiveRecord::Base
end
def default_scientific_name
- if scientific_names.count > 0
+ if scientific_names.size > 0
return scientific_names.first.scientific_name
else
return nil
@@ -175,7 +177,7 @@ class Crop < ActiveRecord::Base
def interesting?
min_plantings = 3 # needs this many plantings to be interesting
min_photos = 3 # needs this many photos to be interesting
- return false unless photos.count >= min_photos
+ return false unless photos.size >= min_photos
return false unless plantings_count >= min_plantings
return true
end
@@ -205,8 +207,8 @@ class Crop < ActiveRecord::Base
def Crop.interesting
howmany = 12 # max number to find
interesting_crops = Array.new
- Crop.randomized.each do |c|
- break if interesting_crops.length == howmany
+ Crop.includes(:photos).randomized.each do |c|
+ break if interesting_crops.size == howmany
next unless c.interesting?
interesting_crops.push(c)
end
@@ -229,14 +231,14 @@ class Crop < ActiveRecord::Base
crop = Crop.find_or_create_by(name: name)
crop.update_attributes(
- :en_wikipedia_url => en_wikipedia_url,
- :creator_id => cropbot.id
+ en_wikipedia_url: en_wikipedia_url,
+ creator_id: cropbot.id
)
if parent
parent = Crop.find_by_name(parent)
if parent
- crop.update_attributes(:parent_id => parent.id)
+ crop.update_attributes(parent_id: parent.id)
else
logger.warn("Warning: parent crop #{parent} not found")
end
@@ -262,13 +264,13 @@ class Crop < ActiveRecord::Base
raise "cropbot account not found: run rake db:seed" unless cropbot
names_to_add.each do |n|
- if self.scientific_names.exists?(:scientific_name => n)
+ if self.scientific_names.exists?(scientific_name: n)
logger.warn("Warning: skipping duplicate scientific name #{n} for #{self}")
else
self.scientific_names.create(
- :scientific_name => n,
- :creator_id => cropbot.id
+ scientific_name: n,
+ creator_id: cropbot.id
)
end
end
@@ -284,12 +286,12 @@ class Crop < ActiveRecord::Base
names_to_add = alternate_names.split(%r{,\s*})
names_to_add.each do |n|
- if self.alternate_names.exists?(:name => n)
+ if self.alternate_names.exists?(name: n)
logger.warn("Warning: skipping duplicate alternate name #{n} for #{self}")
else
self.alternate_names.create(
- :name => n,
- :creator_id => cropbot.id
+ name: n,
+ creator_id: cropbot.id
)
end
end
@@ -297,6 +299,14 @@ class Crop < ActiveRecord::Base
end
end
+ def rejection_explanation
+ if reason_for_rejection == "other"
+ return rejection_notes
+ else
+ return reason_for_rejection
+ end
+ end
+
# Crop.search(string)
def self.search(query)
if ENV['GROWSTUFF_ELASTICSEARCH'] == "true"
@@ -307,15 +317,34 @@ class Crop < ActiveRecord::Base
query: {
multi_match: {
query: "#{search_str}",
+ analyzer: "standard",
fields: ["name", "scientific_names.scientific_name", "alternate_names.name"]
}
},
+ filter: {
+ term: {approval_status: "approved"}
+ },
size: 50
}
)
return response.records.to_a
else
- where("name ILIKE ?", "%#{query}%").load
+ # if we don't have elasticsearch, just do a basic SQL query.
+ # also, make sure it's an actual array not an activerecord
+ # collection, so it matches what we get from elasticsearch and we can
+ # manipulate it in the same ways (eg. deleting elements without deleting
+ # the whole record from the db)
+ matches = Crop.approved.where("name ILIKE ?", "%#{query}%").to_a
+
+ # we want to make sure that exact matches come first, even if not
+ # using elasticsearch (eg. in development)
+ exact_match = Crop.approved.find_by_name(query)
+ if exact_match
+ matches.delete(exact_match)
+ matches.unshift(exact_match)
+ end
+
+ return matches
end
end
diff --git a/app/models/follow.rb b/app/models/follow.rb
index d7028c8ed..997352ebf 100644
--- a/app/models/follow.rb
+++ b/app/models/follow.rb
@@ -1,14 +1,14 @@
class Follow < ActiveRecord::Base
belongs_to :follower, class_name: "Member"
belongs_to :followed, class_name: "Member"
- validates :follower_id, uniqueness: { :scope => :followed_id }
+ validates :follower_id, uniqueness: { scope: :followed_id }
after_create do
Notification.create(
- :recipient_id => self.followed_id,
- :sender_id => self.follower_id,
- :subject => "#{self.follower.login_name} is now following you",
- :body => "#{self.follower.login_name} just followed you on #{ENV["GROWSTUFF_SITE_NAME"]}. "
+ recipient_id: self.followed_id,
+ sender_id: self.follower_id,
+ subject: "#{self.follower.login_name} is now following you",
+ body: "#{self.follower.login_name} just followed you on #{ENV["GROWSTUFF_SITE_NAME"]}. "
)
end
diff --git a/app/models/forum.rb b/app/models/forum.rb
index fd4a79509..0e2e2615d 100644
--- a/app/models/forum.rb
+++ b/app/models/forum.rb
@@ -3,7 +3,7 @@ class Forum < ActiveRecord::Base
friendly_id :name, use: [:slugged, :finders]
has_many :posts
- belongs_to :owner, :class_name => "Member"
+ belongs_to :owner, class_name: "Member"
def to_s
return name
diff --git a/app/models/garden.rb b/app/models/garden.rb
index 0514f2a96..448d7d60e 100644
--- a/app/models/garden.rb
+++ b/app/models/garden.rb
@@ -3,9 +3,9 @@ class Garden < ActiveRecord::Base
extend FriendlyId
friendly_id :garden_slug, use: [:slugged, :finders]
- belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id'
- has_many :plantings, -> { order(created_at: :desc) }, :dependent => :destroy
- has_many :crops, :through => :plantings
+ belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id'
+ has_many :plantings, -> { order(created_at: :desc) }, dependent: :destroy
+ has_many :crops, through: :plantings
has_and_belongs_to_many :photos
@@ -25,19 +25,23 @@ class Garden < ActiveRecord::Base
after_save :mark_inactive_garden_plantings_as_finished
default_scope { order("lower(name) asc") }
- scope :active, -> { where(:active => true) }
- scope :inactive, -> { where(:active => false) }
+ scope :active, -> { where(active: true) }
+ scope :inactive, -> { where(active: false) }
+
+ validates :location,
+ length: { maximum: 255 }
validates :name,
- :format => {
- :with => /\S/
- }
+ format: {
+ with: /\S/
+ },
+ length: { maximum: 255 }
validates :area,
- :numericality => {
- :only_integer => false,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: false,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
AREA_UNITS_VALUES = {
"square metres" => "square metre",
@@ -45,10 +49,10 @@ class Garden < ActiveRecord::Base
"hectares" => "hectare",
"acres" => "acre"
}
- validates :area_unit, :inclusion => { :in => AREA_UNITS_VALUES.values,
- :message => "%{value} is not a valid area unit" },
- :allow_nil => true,
- :allow_blank => true
+ validates :area_unit, inclusion: { in: AREA_UNITS_VALUES.values,
+ message: "%{value} is not a valid area unit" },
+ allow_nil: true,
+ allow_blank: true
after_validation :cleanup_area
diff --git a/app/models/harvest.rb b/app/models/harvest.rb
index 4339a30fa..8a1fea37b 100644
--- a/app/models/harvest.rb
+++ b/app/models/harvest.rb
@@ -4,7 +4,7 @@ class Harvest < ActiveRecord::Base
friendly_id :harvest_slug, use: [:slugged, :finders]
belongs_to :crop
- belongs_to :owner, :class_name => 'Member'
+ belongs_to :owner, class_name: 'Member'
belongs_to :plant_part
has_and_belongs_to_many :photos
@@ -20,15 +20,17 @@ class Harvest < ActiveRecord::Base
default_scope { order('created_at DESC') }
- validates :crop, :approved => true
+ validates :crop, approved: true
- validates :crop, :presence => {:message => "must be present and exist in our database"}
+ validates :crop, presence: {message: "must be present and exist in our database"}
+
+ validates :plant_part, presence: {message: "must be present and exist in our database"}
validates :quantity,
- :numericality => {
- :only_integer => false,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: false,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
UNITS_VALUES = {
"individual" => "individual",
@@ -42,24 +44,24 @@ class Harvest < ActiveRecord::Base
"baskets" => "basket",
"bushels" => "bushel"
}
- validates :unit, :inclusion => { :in => UNITS_VALUES.values,
- :message => "%{value} is not a valid unit" },
- :allow_nil => true,
- :allow_blank => true
+ validates :unit, inclusion: { in: UNITS_VALUES.values,
+ message: "%{value} is not a valid unit" },
+ allow_nil: true,
+ allow_blank: true
validates :weight_quantity,
- :numericality => { :only_integer => false },
- :allow_nil => true
+ numericality: { only_integer: false },
+ allow_nil: true
WEIGHT_UNITS_VALUES = {
"kg" => "kg",
"lb" => "lb",
"oz" => "oz"
}
- validates :weight_unit, :inclusion => { :in => WEIGHT_UNITS_VALUES.values,
- :message => "%{value} is not a valid unit" },
- :allow_nil => true,
- :allow_blank => true
+ validates :weight_unit, inclusion: { in: WEIGHT_UNITS_VALUES.values,
+ message: "%{value} is not a valid unit" },
+ allow_nil: true,
+ allow_blank: true
after_validation :cleanup_quantities
@@ -70,7 +72,7 @@ class Harvest < ActiveRecord::Base
def set_si_weight
if self.weight_unit != nil
weight_string = "#{self.weight_quantity} #{self.weight_unit}"
- self.si_weight = Unit(weight_string).convert_to("kg").to_s("%0.3f").delete(" kg").to_f
+ self.si_weight = Unit.new(weight_string).convert_to("kg").to_s("%0.3f").delete(" kg").to_f
end
end
@@ -102,7 +104,7 @@ class Harvest < ActiveRecord::Base
# 2 buckets of apricots, weighing 10kg
string = ''
if self.quantity
- string += "#{number_to_human(self.quantity.to_s, :strip_insignificant_zeros => true)} "
+ string += "#{number_to_human(self.quantity.to_s, strip_insignificant_zeros: true)} "
if self.unit == 'individual'
string += 'individual '
else
@@ -123,7 +125,7 @@ class Harvest < ActiveRecord::Base
end
if self.weight_quantity
- string += " weighing #{number_to_human(self.weight_quantity, :strip_insignificant_zeros => true)} #{self.weight_unit}"
+ string += " weighing #{number_to_human(self.weight_quantity, strip_insignificant_zeros: true)} #{self.weight_unit}"
end
return string
diff --git a/app/models/member.rb b/app/models/member.rb
index 7b21312ce..f6afdc160 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -4,26 +4,26 @@ class Member < ActiveRecord::Base
friendly_id :login_name, use: [:slugged, :finders]
- has_many :posts, :foreign_key => 'author_id'
- has_many :comments, :foreign_key => 'author_id'
- has_many :forums, :foreign_key => 'owner_id'
+ has_many :posts, foreign_key: 'author_id'
+ has_many :comments, foreign_key: 'author_id'
+ has_many :forums, foreign_key: 'owner_id'
- has_many :gardens, :foreign_key => 'owner_id'
- has_many :plantings, :foreign_key => 'owner_id'
+ has_many :gardens, foreign_key: 'owner_id'
+ has_many :plantings, foreign_key: 'owner_id'
- has_many :seeds, :foreign_key => 'owner_id'
- has_many :harvests, :foreign_key => 'owner_id'
+ has_many :seeds, foreign_key: 'owner_id'
+ has_many :harvests, foreign_key: 'owner_id'
has_and_belongs_to_many :roles
- has_many :notifications, :foreign_key => 'recipient_id'
- has_many :sent_notifications, :foreign_key => 'sender_id'
+ has_many :notifications, foreign_key: 'recipient_id'
+ has_many :sent_notifications, foreign_key: 'sender_id'
has_many :authentications
has_many :orders
has_one :account
- has_one :account_type, :through => :account
+ has_one :account_type, through: :account
has_many :photos
@@ -35,13 +35,13 @@ class Member < ActiveRecord::Base
scope :located, -> { where("location <> '' and latitude IS NOT NULL and longitude IS NOT NULL") }
scope :recently_signed_in, -> { reorder('updated_at DESC') }
scope :recently_joined, -> { reorder("confirmed_at desc") }
- scope :wants_newsletter, -> { where(:newsletter => true) }
+ scope :wants_newsletter, -> { where(newsletter: true) }
- has_many :follows, :class_name => "Follow", :foreign_key => "follower_id"
- has_many :followed, :through => :follows
+ has_many :follows, class_name: "Follow", foreign_key: "follower_id"
+ has_many :followed, through: :follows
- has_many :inverse_follows, :class_name => "Follow", :foreign_key => "followed_id"
- has_many :followers, :through => :inverse_follows, :source => :follower
+ has_many :inverse_follows, class_name: "Follow", foreign_key: "followed_id"
+ has_many :followers, through: :inverse_follows, source: :follower
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
@@ -60,34 +60,34 @@ class Member < ActiveRecord::Base
attr_accessor :login
# Requires acceptance of the Terms of Service
- validates_acceptance_of :tos_agreement, :allow_nil => false,
- :accept => true
+ validates_acceptance_of :tos_agreement, allow_nil: false,
+ accept: true
validates :login_name,
- :length => {
- :minimum => 2,
- :maximum => 25,
- :message => "should be between 2 and 25 characters long"
+ length: {
+ minimum: 2,
+ maximum: 25,
+ message: "should be between 2 and 25 characters long"
},
- :exclusion => {
- :in => %w(growstuff admin moderator staff nearby),
- :message => "name is reserved"
+ exclusion: {
+ in: %w(growstuff admin moderator staff nearby),
+ message: "name is reserved"
},
- :format => {
- :with => /\A\w+\z/,
- :message => "may only include letters, numbers, or underscores"
+ format: {
+ with: /\A\w+\z/,
+ message: "may only include letters, numbers, or underscores"
},
- :uniqueness => {
- :case_sensitive => false
+ uniqueness: {
+ case_sensitive: false
}
# Give each new member a default garden
- after_create {|member| Garden.create(:name => "Garden", :owner_id => member.id) }
+ after_create {|member| Garden.create(name: "Garden", owner_id: member.id) }
# and an account record (for paid accounts etc)
# we use find_or_create to avoid accidentally creating a second one,
# which can happen sometimes especially with FactoryGirl associations
- after_create {|member| Account.find_or_create_by(:member_id => member.id) }
+ after_create {|member| Account.find_or_create_by(member_id: member.id) }
after_save :update_newsletter_subscription
@@ -95,7 +95,7 @@ class Member < ActiveRecord::Base
def self.find_first_by_auth_conditions(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
- where(conditions).where(["lower(login_name) = :value OR lower(email) = :value", { :value => login.downcase }]).first
+ where(conditions).where(["lower(login_name) = :value OR lower(email) = :value", { value: login.downcase }]).first
else
where(conditions).first
end
@@ -110,7 +110,7 @@ class Member < ActiveRecord::Base
end
def current_order
- orders.where(:completed_at => nil).first
+ orders.where(completed_at: nil).first
end
# when purchasing a product that gives you a paid account, this method
@@ -165,15 +165,15 @@ class Member < ActiveRecord::Base
result = false
if set
result = flickr.photosets.getPhotos(
- :photoset_id => set,
- :page => page_num,
- :per_page => 30
+ photoset_id: set,
+ page: page_num,
+ per_page: 30
)
else
result = flickr.people.getPhotos(
- :user_id => 'me',
- :page => page_num,
- :per_page => 30
+ user_id: 'me',
+ page: page_num,
+ per_page: 30
)
end
if result
@@ -204,7 +204,7 @@ class Member < ActiveRecord::Base
howmany = 12 # max number to find
interesting_members = Array.new
Member.confirmed.located.recently_signed_in.each do |m|
- break if interesting_members.length == howmany
+ break if interesting_members.size == howmany
if m.interesting?
interesting_members.push(m)
end
@@ -241,10 +241,10 @@ class Member < ActiveRecord::Base
return true if (Rails.env.test? && !testing)
gb = Gibbon::API.new
res = gb.lists.subscribe({
- :id => Gibbon::API.api_key,
- :email => { :email => email },
- :merge_vars => { :login_name => login_name },
- :double_optin => false # they already confirmed their email with us
+ id: Growstuff::Application.config.newsletter_list_id,
+ email: { email: email },
+ merge_vars: { login_name: login_name },
+ double_optin: false # they already confirmed their email with us
})
end
@@ -252,17 +252,17 @@ class Member < ActiveRecord::Base
return true if (Rails.env.test? && !testing)
gb = Gibbon::API.new
res = gb.lists.unsubscribe({
- :id => ENV['GROWSTUFF_MAILCHIMP_NEWSLETTER_ID'],
- :email => { :email => email }
+ id: Growstuff::Application.config.newsletter_list_id,
+ email: { email: email }
})
end
def already_following?(member)
- self.follows.exists?(:followed_id => member.id)
+ self.follows.exists?(followed_id: member.id)
end
def get_follow(member)
- self.follows.where(:followed_id => member.id).first if already_following?(member)
+ self.follows.where(followed_id: member.id).first if already_following?(member)
end
end
diff --git a/app/models/notification.rb b/app/models/notification.rb
index 304b86b03..0668167f4 100644
--- a/app/models/notification.rb
+++ b/app/models/notification.rb
@@ -1,16 +1,18 @@
class Notification < ActiveRecord::Base
- belongs_to :sender, :class_name => 'Member'
- belongs_to :recipient, :class_name => 'Member'
+ belongs_to :sender, class_name: 'Member'
+ belongs_to :recipient, class_name: 'Member'
belongs_to :post
+ validates :subject, length: { maximum: 255 }
+
default_scope { order('created_at DESC') }
- scope :unread, -> { where(:read => false) }
+ scope :unread, -> { where(read: false) }
before_create :replace_blank_subject
after_create :send_email
def self.unread_count
- self.unread.count
+ self.unread.size
end
def replace_blank_subject
diff --git a/app/models/order.rb b/app/models/order.rb
index e9f97034f..f3a4eaafb 100644
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -1,13 +1,13 @@
class Order < ActiveRecord::Base
belongs_to :member
- has_many :order_items, :dependent => :destroy
+ has_many :order_items, dependent: :destroy
default_scope { order('created_at DESC') }
- validates :referral_code, :format => {
- :with => /\A[a-zA-Z0-9 ]*\z/,
- :message => "may only include letters and numbers"
+ validates :referral_code, format: {
+ with: /\A[a-zA-Z0-9 ]*\z/,
+ message: "may only include letters and numbers"
}
before_save :standardize_referral_code
@@ -27,9 +27,9 @@ class Order < ActiveRecord::Base
items = []
order_items.each do |i|
items.push({
- :name => i.product.name,
- :quantity => i.quantity,
- :amount => i.price
+ name: i.product.name,
+ quantity: i.quantity,
+ amount: i.price
})
end
return items
@@ -87,7 +87,7 @@ class Order < ActiveRecord::Base
end
when "referral_code"
# coerce to uppercase
- return Order.where(:referral_code => args[:for].upcase)
+ return Order.where(referral_code: args[:for].upcase)
end
end
return []
diff --git a/app/models/order_item.rb b/app/models/order_item.rb
index 159876dd5..da26f3a42 100644
--- a/app/models/order_item.rb
+++ b/app/models/order_item.rb
@@ -4,7 +4,7 @@ class OrderItem < ActiveRecord::Base
validate :price_must_be_greater_than_minimum
- validates_uniqueness_of :order_id, :message => "may only have one item."
+ validates_uniqueness_of :order_id, message: "may only have one item."
def price_must_be_greater_than_minimum
@product = Product.find(product_id)
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 54cc94de3..1abef6047 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -1,5 +1,5 @@
class Photo < ActiveRecord::Base
- belongs_to :owner, :class_name => 'Member'
+ belongs_to :owner, class_name: 'Member'
has_and_belongs_to_many :plantings
has_and_belongs_to_many :harvests
@@ -23,16 +23,16 @@ class Photo < ActiveRecord::Base
# for easier stubbing and testing.
def flickr_metadata
flickr = owner.flickr
- info = flickr.photos.getInfo(:photo_id => flickr_photo_id)
+ info = flickr.photos.getInfo(photo_id: flickr_photo_id)
licenses = flickr.photos.licenses.getInfo()
license = licenses.find { |l| l.id == info.license }
return {
- :title => info.title || "Untitled",
- :license_name => license.name,
- :license_url => license.url,
- :thumbnail_url => FlickRaw.url_q(info),
- :fullsize_url => FlickRaw.url_z(info),
- :link_url => FlickRaw.url_photopage(info)
+ title: info.title || "Untitled",
+ license_name: license.name,
+ license_url: license.url,
+ thumbnail_url: FlickRaw.url_q(info),
+ fullsize_url: FlickRaw.url_z(info),
+ link_url: FlickRaw.url_photopage(info)
}
end
diff --git a/app/models/plant_part.rb b/app/models/plant_part.rb
index 33d2292fa..652bc894b 100644
--- a/app/models/plant_part.rb
+++ b/app/models/plant_part.rb
@@ -1,9 +1,9 @@
class PlantPart < ActiveRecord::Base
extend FriendlyId
- friendly_id :name, :use => [:slugged, :finders]
+ friendly_id :name, use: [:slugged, :finders]
has_many :harvests
- has_many :crops, -> { uniq }, :through => :harvests
+ has_many :crops, -> { uniq }, through: :harvests
def to_s
return name
diff --git a/app/models/planting.rb b/app/models/planting.rb
index 958ba625f..02028f909 100644
--- a/app/models/planting.rb
+++ b/app/models/planting.rb
@@ -3,8 +3,8 @@ class Planting < ActiveRecord::Base
friendly_id :planting_slug, use: [:slugged, :finders]
belongs_to :garden
- belongs_to :owner, :class_name => 'Member', :counter_cache => true
- belongs_to :crop, :counter_cache => true
+ belongs_to :owner, class_name: 'Member', counter_cache: true
+ belongs_to :crop, counter_cache: true
has_and_belongs_to_many :photos
@@ -18,33 +18,33 @@ class Planting < ActiveRecord::Base
end
default_scope { order("created_at desc") }
- scope :finished, -> { where(:finished => true) }
- scope :current, -> { where(:finished => false) }
+ scope :finished, -> { where(finished: true) }
+ scope :current, -> { where(finished: false) }
delegate :name,
:en_wikipedia_url,
:default_scientific_name,
:plantings_count,
- :to => :crop,
- :prefix => true
+ to: :crop,
+ prefix: true
default_scope { order("created_at desc") }
- validates :crop, :approved => true
+ validates :crop, approved: true
- validates :crop, :presence => {:message => "must be present and exist in our database"}
+ validates :crop, presence: {message: "must be present and exist in our database"}
validates :quantity,
- :numericality => {
- :only_integer => true,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
SUNNINESS_VALUES = %w(sun semi-shade shade)
- validates :sunniness, :inclusion => { :in => SUNNINESS_VALUES,
- :message => "%{value} is not a valid sunniness value" },
- :allow_nil => true,
- :allow_blank => true
+ validates :sunniness, inclusion: { in: SUNNINESS_VALUES,
+ message: "%{value} is not a valid sunniness value" },
+ allow_nil: true,
+ allow_blank: true
PLANTED_FROM_VALUES = [
'seed',
@@ -59,10 +59,10 @@ class Planting < ActiveRecord::Base
'graft',
'layering'
]
- validates :planted_from, :inclusion => { :in => PLANTED_FROM_VALUES,
- :message => "%{value} is not a valid planting method" },
- :allow_nil => true,
- :allow_blank => true
+ validates :planted_from, inclusion: { in: PLANTED_FROM_VALUES,
+ message: "%{value} is not a valid planting method" },
+ allow_nil: true,
+ allow_blank: true
validate :finished_must_be_after_planted
@@ -94,6 +94,41 @@ class Planting < ActiveRecord::Base
return photos.present?
end
+ def calculate_days_before_maturity(planting, crop)
+ p_crop = Planting.where(crop_id: crop).where.not(id: planting)
+ differences = p_crop.collect do |p|
+ if p.finished and !p.finished_at.nil?
+ (p.finished_at - p.planted_at).to_i
+ end
+ end
+
+ if differences.compact.empty?
+ nil
+ else
+ differences.compact.sum/differences.compact.size
+ end
+ end
+
+ def planted?(current_date = Date.current)
+ planted_at.present? && current_date.to_date >= planted_at
+ end
+
+ def percentage_grown(current_date = Date.current)
+ return nil unless days_before_maturity && planted?(current_date)
+
+ days = (current_date.to_date - planted_at.to_date).to_i
+
+ return 0 if current_date < planted_at
+ return 100 if days > days_before_maturity
+ percent = (days/days_before_maturity*100).to_i
+
+ if percent >= 100
+ percent = 100
+ end
+
+ percent
+ end
+
# return a list of interesting plantings, for the homepage etc.
# we can't do this via a scope (as far as we know) so sadly we have to
# do it this way.
@@ -101,8 +136,8 @@ class Planting < ActiveRecord::Base
interesting_plantings = Array.new
seen_owners = Hash.new(false) # keep track of which owners we've seen already
- Planting.all.each do |p|
- break if interesting_plantings.count == howmany # got enough yet?
+ Planting.includes(:photos).each do |p|
+ break if interesting_plantings.size == howmany # got enough yet?
if require_photo
next unless p.photos.present? # skip those without photos, if required
end
diff --git a/app/models/post.rb b/app/models/post.rb
index dce1273f2..cca21b575 100644
--- a/app/models/post.rb
+++ b/app/models/post.rb
@@ -2,21 +2,49 @@ class Post < ActiveRecord::Base
extend FriendlyId
include Likeable
friendly_id :author_date_subject, use: [:slugged, :finders]
- belongs_to :author, :class_name => 'Member'
+ belongs_to :author, class_name: 'Member'
belongs_to :forum
- has_many :comments, :dependent => :destroy
+ has_many :comments, dependent: :destroy
has_and_belongs_to_many :crops
before_destroy {|post| post.crops.clear}
after_save :update_crops_posts_association
# also has_many notifications, but kinda meaningless to get at them
# from this direction, so we won't set up an association for now.
+ after_create do
+ recipients = Array.new
+ sender = self.author.id
+ self.body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_REGEX) do |m|
+ # find member case-insensitively and add to list of recipients
+ member = Member.where('lower(login_name) = ?', $1.downcase).first
+ recipients << member if member and not recipients.include?(member)
+ end
+ self.body.scan(Haml::Filters::GrowstuffMarkdown::MEMBER_AT_REGEX) do |m|
+ # find member case-insensitively and add to list of recipients
+ member = Member.where('lower(login_name) = ?', $1[1..-1].downcase).first
+ recipients << member if member and not recipients.include?(member)
+ end
+ # don't send notifications to yourself
+ recipients.map{ |r| r.id }.each do |recipient|
+ if recipient != sender
+ Notification.create(
+ recipient_id: recipient,
+ sender_id: sender,
+ subject: "#{self.author} mentioned you in their post #{self.subject}",
+ body: self.body,
+ )
+ end
+ end
+ end
+
default_scope { order("created_at desc") }
validates :subject,
- :format => {
- :with => /\S/
- }
+ format: {
+ with: /\S/
+ },
+ length: { maximum: 255 }
+
def author_date_subject
# slugs are created before created_at is set
@@ -25,7 +53,7 @@ class Post < ActiveRecord::Base
end
def comment_count
- self.comments.count
+ self.comments.size
end
# return the timestamp of the most recent activity on this post
diff --git a/app/models/product.rb b/app/models/product.rb
index 68d483665..942e2603b 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -3,10 +3,10 @@ class Product < ActiveRecord::Base
belongs_to :account_type
validates :paid_months,
- :numericality => {
- :only_integer => true,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
def to_s
name
diff --git a/app/models/scientific_name.rb b/app/models/scientific_name.rb
index 7469b3946..2df6aa5e7 100644
--- a/app/models/scientific_name.rb
+++ b/app/models/scientific_name.rb
@@ -1,5 +1,5 @@
class ScientificName < ActiveRecord::Base
- after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop }
+ after_commit { |sn| sn.crop.__elasticsearch__.index_document if sn.crop && ENV['GROWSTUFF_ELASTICSEARCH'] == "true" }
belongs_to :crop
- belongs_to :creator, :class_name => 'Member'
+ belongs_to :creator, class_name: 'Member'
end
diff --git a/app/models/seed.rb b/app/models/seed.rb
index 9fa005907..b05528680 100644
--- a/app/models/seed.rb
+++ b/app/models/seed.rb
@@ -3,62 +3,62 @@ class Seed < ActiveRecord::Base
friendly_id :seed_slug, use: [:slugged, :finders]
belongs_to :crop
- belongs_to :owner, :class_name => 'Member', :foreign_key => 'owner_id'
+ belongs_to :owner, class_name: 'Member', foreign_key: 'owner_id'
default_scope { order("created_at desc") }
- validates :crop, :approved => true
+ validates :crop, approved: true
- validates :crop, :presence => {:message => "must be present and exist in our database"}
+ validates :crop, presence: {message: "must be present and exist in our database"}
validates :quantity,
- :numericality => {
- :only_integer => true,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
validates :days_until_maturity_min,
- :numericality => {
- :only_integer => true,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
validates :days_until_maturity_max,
- :numericality => {
- :only_integer => true,
- :greater_than_or_equal_to => 0 },
- :allow_nil => true
+ numericality: {
+ only_integer: true,
+ greater_than_or_equal_to: 0 },
+ allow_nil: true
scope :tradable, -> { where("tradable_to != 'nowhere'") }
TRADABLE_TO_VALUES = %w(nowhere locally nationally internationally)
- validates :tradable_to, :inclusion => { :in => TRADABLE_TO_VALUES,
- :message => "You may only trade seed nowhere, locally, nationally, or internationally" },
- :allow_nil => false,
- :allow_blank => false
+ validates :tradable_to, inclusion: { in: TRADABLE_TO_VALUES,
+ message: "You may only trade seed nowhere, locally, nationally, or internationally" },
+ allow_nil: false,
+ allow_blank: false
ORGANIC_VALUES = [
'certified organic',
'non-certified organic',
'conventional/non-organic',
'unknown']
- validates :organic, :inclusion => { :in => ORGANIC_VALUES,
- :message => "You must say whether the seeds are organic or not, or that you don't know" },
- :allow_nil => false,
- :allow_blank => false
+ validates :organic, inclusion: { in: ORGANIC_VALUES,
+ message: "You must say whether the seeds are organic or not, or that you don't know" },
+ allow_nil: false,
+ allow_blank: false
GMO_VALUES = [
'certified GMO-free',
'non-certified GMO-free',
'GMO',
'unknown']
- validates :gmo, :inclusion => { :in => GMO_VALUES,
- :message => "You must say whether the seeds are genetically modified or not, or that you don't know" },
- :allow_nil => false,
- :allow_blank => false
+ validates :gmo, inclusion: { in: GMO_VALUES,
+ message: "You must say whether the seeds are genetically modified or not, or that you don't know" },
+ allow_nil: false,
+ allow_blank: false
HEIRLOOM_VALUES = %w(heirloom hybrid unknown)
- validates :heirloom, :inclusion => { :in => HEIRLOOM_VALUES,
- :message => "You must say whether the seeds are heirloom, hybrid, or unknown" },
- :allow_nil => false,
- :allow_blank => false
+ validates :heirloom, inclusion: { in: HEIRLOOM_VALUES,
+ message: "You must say whether the seeds are heirloom, hybrid, or unknown" },
+ allow_nil: false,
+ allow_blank: false
def tradable?
if self.tradable_to == 'nowhere'
@@ -82,7 +82,7 @@ class Seed < ActiveRecord::Base
interesting_seeds = Array.new
Seed.tradable.each do |s|
- break if interesting_seeds.length == howmany
+ break if interesting_seeds.size == howmany
if s.interesting?
interesting_seeds.push(s)
end
diff --git a/app/views/about/contact.html.haml b/app/views/about/contact.html.haml
deleted file mode 100644
index 2398bea36..000000000
--- a/app/views/about/contact.html.haml
+++ /dev/null
@@ -1,17 +0,0 @@
--content_for :title, 'Contact'
-
-%dl
- %dt General contact email
- %dd= link_to 'info@growstuff.org', 'mailto:info@growstuff.org'
-%dl
- %dt
- Support and accounts enquiries (not covered by the
- =succeed ")" do
- =link_to 'FAQ', url_for(:controller => '/support')
- %dd= link_to 'support@growstuff.org', 'mailto:support@growstuff.org'
-%dl
- %dt Media/Press enquiries
- %dd= link_to 'media@growstuff.org', 'mailto:media@growstuff.org'
-%dl
- %dt Twitter
- %dd= link_to '@growstufforg', 'http://twitter.com/growstufforg'
diff --git a/app/views/account_types/_form.html.haml b/app/views/account_types/_form.html.haml
index 12fcda225..0863693fe 100644
--- a/app/views/account_types/_form.html.haml
+++ b/app/views/account_types/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @account_type do |f|
- if @account_type.errors.any?
#error_explanation
- %h2= "#{pluralize(@account_type.errors.count, "error")} prohibited this account_type from being saved:"
+ %h2= "#{pluralize(@account_type.errors.size, "error")} prohibited this account_type from being saved:"
%ul
- @account_type.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/accounts/_form.html.haml b/app/views/accounts/_form.html.haml
index 6e648d622..ce9e26eeb 100644
--- a/app/views/accounts/_form.html.haml
+++ b/app/views/accounts/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @account do |f|
- if @account.errors.any?
#error_explanation
- %h2= "#{pluralize(@account.errors.count, "error")} prohibited this account from being saved:"
+ %h2= "#{pluralize(@account.errors.size, "error")} prohibited this account from being saved:"
%ul
- @account.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/admin/orders/search.html.haml b/app/views/admin/orders/search.html.haml
index 022e97d87..d76715fa5 100644
--- a/app/views/admin/orders/search.html.haml
+++ b/app/views/admin/orders/search.html.haml
@@ -5,7 +5,7 @@
- unless @orders.empty?
%h2
Found
- = pluralize(@orders.count, "result")
+ = pluralize(@orders.size, "result")
%table.table.table-striped
%tr
@@ -28,7 +28,7 @@
%td
= order.referral_code
%td
- - if order.order_items.count > 0
+ - if order.order_items.size > 0
- order.order_items.each do |o|
= o.quantity
x
diff --git a/app/views/alternate_names/_form.html.haml b/app/views/alternate_names/_form.html.haml
index 7d6f9abd5..cb33660b5 100644
--- a/app/views/alternate_names/_form.html.haml
+++ b/app/views/alternate_names/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @alternate_name, :html => {:class => 'form-horizontal', :role => "form"} do |f|
- if @alternate_name.errors.any?
#error_explanation
- %h2= "#{pluralize(@alternate_name.errors.count, "error")} prohibited this alternate_name from being saved:"
+ %h2= "#{pluralize(@alternate_name.errors.size, "error")} prohibited this alternate_name from being saved:"
%ul
- @alternate_name.errors.full_messages.each do |msg|
%li= msg
@@ -16,10 +16,12 @@
= f.label :crop_id, :class => 'control-label col-md-2'
.col-md-8
= collection_select(:alternate_name, :crop_id, Crop.all, :id, :name, { :selected => @alternate_name.crop_id || @crop.id }, :class => 'form-control')
+
.form-group
= f.label :name, :class => 'control-label col-md-2'
.col-md-8
= f.text_field :name, :class => 'form-control'
+
.form-group
.form-actions.col-md-offset-2.col-md-8
- = f.submit 'Save', :class => 'btn btn-primary'
+ = f.submit 'Save', :class => 'btn btn-primary'
\ No newline at end of file
diff --git a/app/views/alternate_names/show.html.haml b/app/views/alternate_names/show.html.haml
index 67dfc9a37..4306ceb23 100644
--- a/app/views/alternate_names/show.html.haml
+++ b/app/views/alternate_names/show.html.haml
@@ -1,5 +1,14 @@
+= content_for :title, @alternate_name.name
+- content_for :opengraph do
+ = tag("meta", property: "og:title", content: @alternate_name.name)
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
+
%p#notice= notice
+= render :partial => 'crops/approval_status_message', :locals => { :crop => @alternate_name.crop }
+
%p
%b Alternate name:
= @alternate_name.name
@@ -9,5 +18,5 @@
- if can? :edit, @alternate_name
= link_to 'Edit', edit_alternate_name_path(@alternate_name), :class => 'btn btn-default btn-xs'
-\|
+ \|
= link_to 'Back', alternate_names_path
diff --git a/app/views/comments/_form.html.haml b/app/views/comments/_form.html.haml
index 5d13ec6b5..14af354aa 100644
--- a/app/views/comments/_form.html.haml
+++ b/app/views/comments/_form.html.haml
@@ -1,14 +1,14 @@
= form_for(@comment, :html => {:class => "form-horizontal", :role => "form"}) do |f|
- if @comment.errors.any?
#error_explanation
- %h2= "#{pluralize(@comment.errors.count, "error")} prohibited this comment from being saved:"
+ %h2= "#{pluralize(@comment.errors.size, "error")} prohibited this comment from being saved:"
%ul
- @comment.errors.full_messages.each do |msg|
%li= msg
.form-group
= f.label :body, "Your comment:"
- = f.text_area :body, :rows => 6, :class => 'form-control'
+ = f.text_area :body, :rows => 6, :class => 'form-control', :autofocus => 'autofocus'
%span.help-block
= render :partial => "shared/markdown_help"
.actions
diff --git a/app/views/comments/_single.html.haml b/app/views/comments/_single.html.haml
index ae9c503af..895002b1e 100644
--- a/app/views/comments/_single.html.haml
+++ b/app/views/comments/_single.html.haml
@@ -7,8 +7,11 @@
.comment-meta
Posted by
= link_to comment.author.login_name, member_path(comment.author)
- at
+ on
= comment.created_at
+ - if comment.updated_at > comment.created_at
+ and edited at
+ = comment.updated_at
.comment-body
:growstuff_markdown
diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml
index 540773b41..e04707fc7 100644
--- a/app/views/comments/index.html.haml
+++ b/app/views/comments/index.html.haml
@@ -1,7 +1,7 @@
= content_for :title, "Recent comments"
%div.pagination
- = page_entries_info @comments, :model => "comments"
+ = page_entries_info @comments
= will_paginate @comments
- @comments.each do |comment|
@@ -11,7 +11,7 @@
= render :partial => "single", :locals => { :comment => comment }
%div.pagination
- = page_entries_info @comments, :model => "comments"
+ = page_entries_info @comments
= will_paginate @comments
%p
diff --git a/app/views/comments/show.html.haml b/app/views/comments/show.html.haml
index a43473ffc..84cd72159 100644
--- a/app/views/comments/show.html.haml
+++ b/app/views/comments/show.html.haml
@@ -1,4 +1,12 @@
= content_for :title, @comment.post.subject
+- content_for :opengraph do
+ = tag("meta", property: "og:image", content: avatar_uri(@comment.post.author, 200))
+ = tag("meta", property: "og:image:user_generated", content: "true")
+ = tag("meta", property: "og:title", content: @comment.post.subject)
+ = tag("meta", property: "og:description", content: strip_tags(@comment.post.body).split(' ')[0..20].join(' '))
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
= render :partial => "posts/single", :locals => { :post => @comment.post }
diff --git a/app/views/crops/_approval_status_message.html.haml b/app/views/crops/_approval_status_message.html.haml
new file mode 100644
index 000000000..54ae162db
--- /dev/null
+++ b/app/views/crops/_approval_status_message.html.haml
@@ -0,0 +1,11 @@
+- if crop.pending?
+ .alert.alert-danger
+ %b This crop is currently pending approval.
+ %p This crop was requested by #{crop.requester} #{time_ago_in_words(crop.created_at)} ago.
+ - unless crop.request_notes.blank?
+ %p
+ Request notes: #{crop.request_notes}
+
+- if crop.rejected?
+ .alert.alert-danger
+ %b This crop was rejected for the following reason: #{crop.rejection_explanation}
diff --git a/app/views/crops/_find_seeds.html.haml b/app/views/crops/_find_seeds.html.haml
index 66990ed69..0e31f6916 100644
--- a/app/views/crops/_find_seeds.html.haml
+++ b/app/views/crops/_find_seeds.html.haml
@@ -10,7 +10,8 @@
= render :partial => 'members/location', :locals => { :member => seed.owner }
%p
= link_to "View all #{crop.name} seeds", seeds_by_crop_path(crop)
-- if current_member
- = link_to "List achiote seeds to trade", new_seed_path(:crop_id => crop.id)
-- else
- = render :partial => 'shared/signin_signup', :locals => { :to => 'list your seeds to trade' }
+- if crop.approved?
+ - if current_member
+ %p= link_to "List #{crop.name} seeds to trade", new_seed_path(:crop_id => crop.id)
+ - else
+ = render :partial => 'shared/signin_signup', :locals => { :to => 'list your seeds to trade' }
diff --git a/app/views/crops/_form.html.haml b/app/views/crops/_form.html.haml
index e7be7cd62..99fa8648e 100644
--- a/app/views/crops/_form.html.haml
+++ b/app/views/crops/_form.html.haml
@@ -1,91 +1,113 @@
= form_for @crop, :html => {:class => 'form-horizontal', :role => "form"} do |f|
- if @crop.errors.any?
#error_explanation
- %h3= "#{pluralize(@crop.errors.count, "error")} prohibited this crop from being saved:"
+ %h3= "#{pluralize(@crop.errors.size, "error")} prohibited this crop from being saved:"
%ul
- @crop.errors.full_messages.each do |msg|
%li= msg
+ -# Handy link to crop wrangling policy/style guide, shown to wranglers only
- if can? :wrangle, @crop
%p
%span.help-block
For detailed crop wrangling guidelines, please consult the
-
=link_to "crop wrangling guide", "http://wiki.growstuff.org/index.php/Crop_wrangling"
on the Growstuff wiki.
- .form-group
+ -# Everyone (wranglers and requesters) sees the basic info section
+ %h2 Basic information
+
+ .form-group#new_crop
= f.label :name, :class => 'control-label col-md-2'
.col-md-8
= f.text_field :name, :class => 'form-control'
- %span.help-block
- - if can? :wrangle, @crop
- Name in US English; singular; capitalize proper nouns only.
- - else
- Please provide the common name for the crop, in English, if you know it.
+ %span.help-block
+ The common name for the crop, in English (required).
+ - if can? :wrangle, @crop
+ Wranglers: please ensure this is singular, and capitalize
+ proper nouns only.
.form-group
= f.label :en_wikipedia_url, 'Wikipedia URL', :class => 'control-label col-md-2'
.col-md-8
- = f.text_field :en_wikipedia_url, :class => 'form-control'
- %span.help-block
- - if can? :wrangle, @crop
- Link to this crop's page on the English language Wikipedia.
- - else
- Please provide a link to the crop's page on the English language Wikipedia. Crops without Wikipedia pages cannot be added to our database at this time.
-
- - if can? :wrangle, @crop
+ = f.text_field :en_wikipedia_url, :class => 'form-control', :id => "en_wikipedia_url"
+ %span.help-block
+ Link to the crop's page on the English language Wikipedia (required).
+ -# Only crop wranglers see the crop hierarchy (for now)
+ - if can? :wrangle, @crop
.form-group
= f.label :parent_id, 'Parent crop', :class => 'control-label col-md-2'
.col-md-8
= collection_select(:crop, :parent_id, Crop.all, :id, :name, {:include_blank => true}, :class => 'form-control')
%span.help-block Optional. For setting up crop hierarchies for varieties etc.
- %p
- %span.help-block
- You may enter up to 3 scientific names for a crop. Most crops will have only one.
- = f.fields_for :scientific_names do |sn|
- .form-group
- = sn.label :scientific_name, "Scientific name", :class => 'control-label col-md-2'
- .col-md-8
- = sn.text_field :scientific_name, :class => 'form-control'
+
+ -# Everyone (wranglers and requesters) gets to add scientific names
+ %h2
+ Scientific names
+ = button_tag "+", :id => "add-sci_name-row", :type => "button"
+ = button_tag "-", :id => "remove-sci_name-row", :type => "button"
+
+ .form-group#scientific_names
+ - @crop.scientific_names.each.with_index do |sci, index|
+ .template.col-md-12{ :id => "sci_template[#{index+1}]" }
.col-md-2
- - if sn.object && sn.object.persisted?
- %label.checkbox
- = sn.check_box :_destroy
- = sn.label :_destroy, "Delete"
-
- - unless @crop.new_record?
- .form-group
- = f.label :approval_status, 'Approval Status', :class=> 'control-label col-md-2'
+ = label_tag :scientific_names, "Scientific name #{index+1}:", :class => 'control-label'
.col-md-8
- = f.select(:approval_status, @crop.approval_statuses, {}, {:class => 'form-control'})
+ = text_field_tag "sci_name[#{index+1}]", sci.scientific_name, :id => "sci_name[#{index+1}]", :class => 'form-control'
+ %span.help-block Scientific name of crop.
+ .col-md-2
- .form-group
- = f.label :reason_for_rejection, 'Reason for rejection', :class => 'control-label col-md-2'
+ %h2
+ Alternate names
+ = button_tag "+", :id => "add-alt_name-row", :type => "button"
+ = button_tag "-", :id => "remove-alt_name-row", :type => "button"
+
+ .form-group#alternate_names
+ - @crop.alternate_names.each.with_index do |alt, index|
+ .template.col-md-12{ :id => "alt_template[#{index+1}]" }
+ .col-md-2
+ = label_tag :alternate_names, "Alternate name #{index+1}:", :class => 'control-label'
.col-md-8
- = f.select(:reason_for_rejection, @crop.reasons_for_rejection, {:include_blank => true}, {:class => 'form-control'})
- %p
+ = text_field_tag "alt_name[#{index+1}]", alt.name, :id => "alt_name[#{index+1}]", :class => 'form-control'
+ %span.help-block Alternate name of crop.
+ .col-md-2
+
+ -# This is used for comments from crop requesters. We need to show it
+ -# to everyone, but we don't include it on new crops from wranglers.
+
+ - if (can? :wrangle, @crop and @crop.requester) or (cannot? :wrangle, @crop and @crop.new_record?)
+ %h2 Crop request notes
+ .form-group
+ = f.label :request_notes, 'Comments', :class => 'control-label col-md-2'
+ .col-md-8
+ = f.text_area :request_notes, :rows => 3, :class => 'form-control', :id => 'request_notes'
+
+ -# A final explanation of what's going to happen next, for crop requesters
+ - unless can? :wrangle, @crop
+ %p When you submit this form, your suggestion will be sent to our team of #{link_to 'volunteer crop wranglers', 'http://talk.growstuff.org/c/crop-wrangling'} for review. We'll let you know the outcome as soon as we can.
+
+ -# Now, for crop wranglers, let's have approval/rejection at the bottom of the page
+ - if can? :wrangle, @crop and @crop.requester
+ %h2 Approve or reject pending crops
+ .form-group
+ = f.label :approval_status, 'Approval status', :class=> 'control-label col-md-2'
+ .col-md-8
+ = f.select(:approval_status, @crop.approval_statuses, {}, {:class => 'form-control'})
+
+ .form-group
+ = f.label :reason_for_rejection, 'Reason for rejection', :class => 'control-label col-md-2'
+ .col-md-8
+ = f.select(:reason_for_rejection, @crop.reasons_for_rejection, {:include_blank => true}, {:class => 'form-control'})
+
+ .form-group
+ = f.label :rejection_notes, 'Rejection notes', :class => 'control-label col-md-2'
+ .col-md-8
+ = f.text_area :rejection_notes, :rows => 3, :class => 'form-control'
%span.help-block
Please provide additional notes why this crop request was rejected if the above reasons do not apply.
- .form-group
- = f.label :rejection_notes, 'Rejection Notes', :class => 'control-label col-md-2'
- .col-md-8= f.text_area :rejection_notes, :rows => 6, :class => 'form-control'
-
- - else
- %p
- %span.help-block
- Provide any additional information that might help us assess your request.
-
- .form-group
- = f.label :request_notes, 'Comments', :class => 'control-label col-md-2'
- .col-md-8= f.text_area :request_notes, :rows => 6, :class => 'form-control'
-
- %p
- %span.help-block
- When you submit this form, your suggestion will be sent to our team of #{link_to 'volunteer crop wranglers', 'http://talk.growstuff.org/c/crop-wrangling'} for review. We'll let you know the outcome as soon as we can.
.form-group
.form-actions.col-md-offset-2.col-md-8
diff --git a/app/views/crops/_harvests.html.haml b/app/views/crops/_harvests.html.haml
index 003e72bfa..8962a6d81 100644
--- a/app/views/crops/_harvests.html.haml
+++ b/app/views/crops/_harvests.html.haml
@@ -13,9 +13,9 @@
ago.
%p
= link_to "View all #{crop.name} harvests", harvests_by_crop_path(crop)
-- if current_member
- %p
- = link_to "Harvest #{crop.name}", new_harvest_path(:crop_id => crop.id)
-- else
- = render :partial => 'shared/signin_signup', :locals => { :to => "track your #{crop.name} harvests" }
+- if crop.approved?
+ - if current_member
+ %p= link_to "Harvest #{crop.name}", new_harvest_path(:crop_id => crop.id)
+ - else
+ = render :partial => 'shared/signin_signup', :locals => { :to => "track your #{crop.name} harvests" }
diff --git a/app/views/crops/_hierarchy.html.haml b/app/views/crops/_hierarchy.html.haml
index dd1e87be6..27d09f866 100644
--- a/app/views/crops/_hierarchy.html.haml
+++ b/app/views/crops/_hierarchy.html.haml
@@ -1,7 +1,11 @@
%ul
+ - @count ||= 0
+ - unless defined? max
+ - max = 0 # list all without "show all" toggle button
- display_crops.each do |c|
- %li.crop-hierarchy
+ %li.crop-hierarchy{:class => max != 0 && @count >= max ? ['hide', 'toggle'] : []}
= link_to c, c
+ - @count += 1
- if c.varieties.present?
- c.varieties.each do |v|
- = render :partial => 'hierarchy', :locals => { :display_crops => [ v ] }
+ = render :partial => 'hierarchy', :locals => { :display_crops => [ v ], :max => max }
diff --git a/app/views/crops/_plantings.html.haml b/app/views/crops/_plantings.html.haml
index 621a6d125..2f9d04483 100644
--- a/app/views/crops/_plantings.html.haml
+++ b/app/views/crops/_plantings.html.haml
@@ -6,16 +6,16 @@
%ul
- crop.plantings.take(3).each do |planting|
%li
- = link_to "#{planting.owner} planted #{planting.quantity} #{planting.planted_from}.", planting_path(planting)
+ = link_to display_planting(planting), planting_path(planting)
= render :partial => 'members/location', :locals => { :member => planting.owner }
%small
= distance_of_time_in_words(planting.created_at, Time.zone.now)
ago.
%p
= link_to "View all #{crop.name} plantings", plantings_by_crop_path(crop)
-- if current_member
- %p
- = link_to "Plant #{crop.name}", new_planting_path(:crop_id => crop.id)
-- else
- = render :partial => 'shared/signin_signup', :locals => { :to => "track your #{crop.name} plantings" }
+- if crop.approved?
+ - if current_member
+ %p= link_to "Plant #{crop.name}", new_planting_path(:crop_id => crop.id)
+ - else
+ = render :partial => 'shared/signin_signup', :locals => { :to => "track your #{crop.name} plantings" }
diff --git a/app/views/crops/_popover.html.haml b/app/views/crops/_popover.html.haml
index 0c40b6ec7..625e55297 100644
--- a/app/views/crops/_popover.html.haml
+++ b/app/views/crops/_popover.html.haml
@@ -1,6 +1,6 @@
%p
%small
- - if crop.scientific_names.count > 0
+ - if crop.scientific_names.size > 0
%i
= crop.scientific_names.first.scientific_name
%br/
diff --git a/app/views/crops/_thumbnail.html.haml b/app/views/crops/_thumbnail.html.haml
index 6fc8a723e..32cbbce9a 100644
--- a/app/views/crops/_thumbnail.html.haml
+++ b/app/views/crops/_thumbnail.html.haml
@@ -1,13 +1,14 @@
.thumbnail
.crop-thumbnail
- if crop
- = link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => crop.name, :class => 'img'), crop
- .cropinfo
- .cropname
- = link_to crop.name, crop
- - if crop.scientific_names.count > 0
- .scientificname
- = crop.scientific_names.first.scientific_name
- .plantingcount
- Planted
- = pluralize(crop.plantings.size, "time")
+ - cache cache_key_for(Crop, crop.id) do
+ = link_to image_tag((crop.default_photo ? crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => crop.name, :class => 'img'), crop
+ .cropinfo
+ .cropname
+ = link_to crop.name, crop
+ - if crop.scientific_names.size > 0
+ .scientificname
+ = crop.scientific_names.first.scientific_name
+ .plantingcount
+ Planted
+ = pluralize(crop.plantings.size, "time")
diff --git a/app/views/crops/_varieties.html.haml b/app/views/crops/_varieties.html.haml
index 8fec3e3a3..e2afb628e 100644
--- a/app/views/crops/_varieties.html.haml
+++ b/app/views/crops/_varieties.html.haml
@@ -1,15 +1,20 @@
-- if crop.parent
- %p
- = crop.name
- is a variety of
- = succeed "." do
- = link_to crop.parent, crop.parent
+.varieties
+ - if crop.parent
+ %p
+ = crop.name
+ is a variety of
+ = succeed "." do
+ = link_to crop.parent, crop.parent
-- unless crop.varieties.empty?
- %p
- Varieties of #{crop.name}:
+ - unless crop.varieties.empty?
+ %p
+ Varieties of #{crop.name}:
- = render :partial => 'hierarchy', :locals => { :display_crops => [ crop ] }
+ - max = 5
+ = render :partial => 'hierarchy', :locals => { :display_crops => [ crop ], :max => max }
+ - if max != 0 && @count > max
+ = button_tag "Show all #{@count-1} varieties", :class => 'btn btn-link toggle crop-hierarchy'
+ = button_tag "Show less varieties", :class => 'btn btn-link toggle crop-hierarchy hide'
-- if ! crop.parent and crop.varieties.empty?
- %p None known.
+ - if ! crop.parent and crop.varieties.empty?
+ %p None known.
diff --git a/app/views/crops/edit.html.haml b/app/views/crops/edit.html.haml
index dca7fb221..da8863252 100644
--- a/app/views/crops/edit.html.haml
+++ b/app/views/crops/edit.html.haml
@@ -1,10 +1,19 @@
-- content_for :title, "Review crop: #{@crop.name}"
+- content_for :title, "Edit crop: #{@crop.name}"
-%p
- Added by
- = @crop.creator
- = distance_of_time_in_words(@crop.created_at, Time.zone.now)
- ago.
+- if @crop.approval_status == "approved"
+ - if @crop.requester
+ %p Requested by #{link_to @crop.requester, @crop.requester} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
+ %p Approved by #{link_to @crop.creator, @crop.creator}.
+ - else
+ %p Added by #{link_to @crop.creator, @crop.creator} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
+- elsif @crop.approval_status == "pending"
+ .alert.alert-danger
+ %p Requested by #{link_to @crop.requester, @crop.requester} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
+ %p Status: #{@crop.approval_status}.
+- elsif @crop.approval_status == "rejected"
+ .alert.alert-danger
+ %p Requested by #{link_to @crop.requester, @crop.requester} #{distance_of_time_in_words(@crop.created_at, Time.zone.now)} ago.
+ %p Status: #{@crop.approval_status} by #{link_to @crop.creator, @crop.creator}.
= render 'form'
diff --git a/app/views/crops/index.csv.shaper b/app/views/crops/index.csv.shaper
index 9b245492f..116d1fa9b 100644
--- a/app/views/crops/index.csv.shaper
+++ b/app/views/crops/index.csv.shaper
@@ -49,7 +49,7 @@ csv.headers *all_headers
if c.scientific_names.any?
csv.cell :default_scientific_name, c.default_scientific_name
- csv.cell :scientific_name_count, c.scientific_names.count
+ csv.cell :scientific_name_count, c.scientific_names.size
end
if c.parent
@@ -58,8 +58,8 @@ csv.headers *all_headers
end
csv.cell :plantings_count, c.plantings_count || 0
- csv.cell :seeds_count, c.seeds.count
- csv.cell :harvests_count, c.harvests.count
+ csv.cell :seeds_count, c.seeds.size
+ csv.cell :harvests_count, c.harvests.size
# Sunniness
diff --git a/app/views/crops/index.html.haml b/app/views/crops/index.html.haml
index d1be6fa49..9c50b029c 100644
--- a/app/views/crops/index.html.haml
+++ b/app/views/crops/index.html.haml
@@ -1,5 +1,5 @@
-- content_for :title, "Browse crops"
-- content_for :subtitle, "#{@crops.size} total"
+- content_for :title, t('.title')
+- content_for :subtitle, t('.subtitle', crops_size: @crops.size)
- if can? :wrangle, Crop
= link_to 'Wrangle Crops', wrangle_crops_path, :class => 'btn btn-primary'
diff --git a/app/views/crops/search.html.haml b/app/views/crops/search.html.haml
index 9b57e1b7a..a00574cee 100644
--- a/app/views/crops/search.html.haml
+++ b/app/views/crops/search.html.haml
@@ -1,21 +1,21 @@
-- if @search
- - content_for :title, "Crops matching \"#{@search}\""
- - if @all_matches
- - content_for :subtitle, "#{@all_matches.size} total"
+- if @term
+ - content_for :title, "Crops matching \"#{@term}\""
+ - if @matches
+ - content_for :subtitle, "#{@matches.size} total"
- else
- content_for :title, "Crop search"
%div
= form_tag crops_search_path, :method => :get, :id => 'crop-search', :class => 'form-inline' do
.form-group
- = label_tag :search, "Search crops:", :class => 'sr-only'
- = text_field_tag 'search', nil, :class => 'search-query input-medium form-control', :placeholder => 'Search crops', :value => @search
+ = label_tag :term, "Search crops:", :class => 'sr-only'
+ = text_field_tag 'term', nil, :class => 'search-query input-medium form-control', :placeholder => 'Search crops', :value => @term
= submit_tag "Search", :class => 'btn btn-primary'
-- if @all_matches.empty?
+- if @matches.empty?
%h2 No results found
%p
- Sorry, we couldn't find any crops that matched your search for "#{@search}".
+ Sorry, we couldn't find any crops that matched your search for "#{@term}".
%p
Try
= link_to "browsing our crop database", crops_path
diff --git a/app/views/crops/show.html.haml b/app/views/crops/show.html.haml
index bda1804d2..288629464 100644
--- a/app/views/crops/show.html.haml
+++ b/app/views/crops/show.html.haml
@@ -1,17 +1,14 @@
- content_for :title, @crop.name
- content_for :subtitle, @crop.default_scientific_name
+- content_for :opengraph do
+ - @crop.photos.each do |photo|
+ = tag("meta", property: "og:image", content: photo.fullsize_url)
+ = tag("meta", property: "og:title", content: @crop.name)
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
-- if @crop.pending?
- .alert.alert-danger
- %b This crop is currently pending approval.
- %p This crop was requested by #{@crop.requester} #{time_ago_in_words(@crop.created_at)} ago.
- - unless @crop.request_notes.blank?
- %p
- Request notes: #{@crop.request_notes}
-
-- if @crop.rejected?
- .alert.alert-danger
- %b This crop was rejected for the following reason: #{@crop.reason_for_rejection == "other" ? @crop.rejection_notes : @crop.reason_for_rejection}.
+= render :partial => 'approval_status_message', :locals => { :crop => @crop }
- if @crop.approved?
- content_for :buttonbar do
@@ -23,7 +20,9 @@
- if can? :create, Seed
= link_to 'Add seeds to stash', new_seed_path(:params => { :crop_id => @crop.id }), :class => 'btn btn-default'
-
+ - if member_signed_in?
+ = display_seed_availability(@current_member, @crop)
+ = link_to "View your seeds", seeds_by_owner_path(:owner => current_member.slug)
.row
.col-md-9
@@ -62,13 +61,13 @@
= render :partial => "shared/signin_signup", :locals => { :to => "post your tips and experiences growing #{ @crop.name.pluralize }" }
- else
%div.pagination
- = page_entries_info @posts, :model => "posts"
+ = page_entries_info @posts
= will_paginate @posts, :params => {:anchor => "posts"}
- @posts.each do |post|
= render :partial => "posts/single", :locals => { :post => post, :subject => true }
%div.pagination
- = page_entries_info @posts, :model => "posts"
+ = page_entries_info @posts
= will_paginate @posts, :params => {:anchor => "posts"}
.col-md-3
diff --git a/app/views/crops/wrangle.html.haml b/app/views/crops/wrangle.html.haml
index 549a737a1..4c0448b01 100644
--- a/app/views/crops/wrangle.html.haml
+++ b/app/views/crops/wrangle.html.haml
@@ -34,7 +34,7 @@
%div.pagination
- = page_entries_info @crops, :model => "crops"
+ = page_entries_info @crops
= will_paginate @crops
%table{:class => "table table-striped", :id => @approval_status.blank? ? 'recently-added-crops' : "#{@approval_status}-crops"}
@@ -50,7 +50,7 @@
%th When
- @crops.each do |c|
%tr
- %td= link_to c.name, c
+ %td= link_to c.name, edit_crop_path(c)
%td= link_to c.en_wikipedia_url, c.en_wikipedia_url
%td
- c.scientific_names.each do |s|
@@ -64,7 +64,7 @@
ago.
%div.pagination
- = page_entries_info @crops, :model => "crops"
+ = page_entries_info @crops
= will_paginate @crops
diff --git a/app/views/devise/confirmations/new.html.haml b/app/views/devise/confirmations/new.html.haml
index c7ebdd604..03a021478 100644
--- a/app/views/devise/confirmations/new.html.haml
+++ b/app/views/devise/confirmations/new.html.haml
@@ -13,4 +13,6 @@
.form-actions.col-md-offset-2.col-md-8
= f.submit "Resend confirmation instructions", :class => 'btn btn-primary'
-= render "devise/shared/links"
+ .form-group
+ .col-md-offset-2.col-md-8
+ = render "devise/shared/links"
diff --git a/app/views/devise/mailer/confirmation_instructions.html.haml b/app/views/devise/mailer/confirmation_instructions.html.haml
index d910951f6..f8a275dba 100644
--- a/app/views/devise/mailer/confirmation_instructions.html.haml
+++ b/app/views/devise/mailer/confirmation_instructions.html.haml
@@ -25,7 +25,7 @@
%p
We'd also appreciate it if you'd read our
= succeed "," do
- = link_to 'Community Guidelines', url_for(:controller => '/policy', :action => 'community', :only_path => false)
+ = link_to 'Community Guidelines', "#{root_url}/policy/community"
and make sure you follow them. We want #{site_name} to be a
friendly, welcoming environment for everyone, and we hope you'll
help us keep it that way.
diff --git a/app/views/devise/passwords/new.html.haml b/app/views/devise/passwords/new.html.haml
index b32607760..2044264c8 100644
--- a/app/views/devise/passwords/new.html.haml
+++ b/app/views/devise/passwords/new.html.haml
@@ -11,4 +11,6 @@
.form-actions.col-md-offset-2.col-md-8
= f.submit "Send me reset password instructions", :class => 'btn btn-primary'
-= render "devise/shared/links"
+ .form-group
+ .col-md-offset-2.col-md-8
+ = render "devise/shared/links"
diff --git a/app/views/devise/registrations/_edit_email.html.haml b/app/views/devise/registrations/_edit_email.html.haml
index 1ea863e2a..a44fbc3c8 100644
--- a/app/views/devise/registrations/_edit_email.html.haml
+++ b/app/views/devise/registrations/_edit_email.html.haml
@@ -9,24 +9,28 @@
%span.help-block If you change your email address you will have to reconfirm.
.form-group
- .col-md-offset-2.col-md-8
- = f.check_box :show_email
- Show email publicly on your profile page.
+ .col-md-offset-2.col-md-8.checkbox
+ %label
+ = f.check_box :show_email
+ Show email publicly on your profile page.
.form-group
- .col-md-offset-2.col-md-8
- = f.check_box :send_notification_email
- Receive emailed copies of Inbox notifications (eg. private messages).
+ .col-md-offset-2.col-md-8.checkbox
+ %label
+ = f.check_box :send_notification_email
+ Receive emailed copies of Inbox notifications (eg. private messages).
.form-group
- .col-md-offset-2.col-md-8
- = f.check_box :send_planting_reminder
- Receive regular reminders to track your planting and harvesting.
+ .col-md-offset-2.col-md-8.checkbox
+ %label
+ = f.check_box :send_planting_reminder
+ Receive regular reminders to track your planting and harvesting.
.form-group
- .col-md-offset-2.col-md-8
- = f.check_box :newsletter
- Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter
+ .col-md-offset-2.col-md-8.checkbox
+ %label
+ = f.check_box :newsletter
+ Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter
.help-block
= render :partial => 'newsletter_blurb'
diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml
index 268fc3e45..3ec01a0ef 100644
--- a/app/views/devise/registrations/new.html.haml
+++ b/app/views/devise/registrations/new.html.haml
@@ -26,15 +26,17 @@
.col-md-8= f.password_field :password_confirmation, :class => 'form-control'
.form-group
- .col-md-offset-2.col-md-8
- = f.check_box :tos_agreement
- I agree to the
- = succeed "." do
- = link_to 'Terms of Service', url_for(:action => 'tos', :controller => '/policy')
+ .col-md-offset-2.col-md-8.checkbox
+ %label
+ = f.check_box :tos_agreement
+ I agree to the
+ = succeed "." do
+ = link_to 'Terms of Service', "#{root_url}/policy/tos"
.form-group
- .col-md-offset-2.col-md-8
- = f.check_box :newsletter, :checked => true
- Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter
+ .col-md-offset-2.col-md-8.checkbox
+ %label
+ = f.check_box :newsletter, :checked => true
+ Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']} newsletter
.help-inline
= render :partial => 'newsletter_blurb'
diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml
index 51d7b6845..4fdef08be 100644
--- a/app/views/devise/sessions/new.html.haml
+++ b/app/views/devise/sessions/new.html.haml
@@ -15,9 +15,10 @@
- if devise_mapping.rememberable?
.form-group
- .col-md-8.col-md-offset-2
- = f.check_box :remember_me
- Remember me
+ .col-md-8.col-md-offset-2.checkbox
+ %label
+ = f.check_box :remember_me
+ Remember me
.form-group
.form-actions.col-md-8.col-md-offset-2
diff --git a/app/views/devise/unlocks/new.html.haml b/app/views/devise/unlocks/new.html.haml
index 77d726806..1e612e9bf 100644
--- a/app/views/devise/unlocks/new.html.haml
+++ b/app/views/devise/unlocks/new.html.haml
@@ -11,4 +11,6 @@
.form-actions.col-md-offset-2.col-md-8
= f.submit "Resend unlock instructions", :class => 'btn btn-primary'
-= render "devise/shared/links"
+ .form-group
+ .col-md-offset-2.col-md-8
+ = render "devise/shared/links"
diff --git a/app/views/forums/_form.html.haml b/app/views/forums/_form.html.haml
index 8168f30cd..524e4c20e 100644
--- a/app/views/forums/_form.html.haml
+++ b/app/views/forums/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @forum, :html => { :class => 'form-horizontal', :role => "form" } do |f|
- if @forum.errors.any?
#error_explanation
- %h2= "#{pluralize(@forum.errors.count, "error")} prohibited this forum from being saved:"
+ %h2= "#{pluralize(@forum.errors.size, "error")} prohibited this forum from being saved:"
%ul
- @forum.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/forums/index.html.haml b/app/views/forums/index.html.haml
index 3737d3f6f..25649f937 100644
--- a/app/views/forums/index.html.haml
+++ b/app/views/forums/index.html.haml
@@ -1,4 +1,4 @@
-- content_for :title, "Forums"
+- content_for :title, t('.title')
- if can? :create, Forum
%p
@@ -7,7 +7,7 @@
- @forums.each do |forum|
%h2= forum
%p
- = pluralize(forum.posts.count, "post")
+ = pluralize(forum.posts.size, "post")
|
=link_to "Visit forum", forum
|
diff --git a/app/views/forums/show.html.haml b/app/views/forums/show.html.haml
index de839a651..ced31ae01 100644
--- a/app/views/forums/show.html.haml
+++ b/app/views/forums/show.html.haml
@@ -1,4 +1,11 @@
- content_for :title, @forum.name
+- content_for :opengraph do
+ - if @forum.description
+ = tag("meta", property: "og:description", content: strip_tags(@forum.description).split(' ')[0..20].join(' '))
+ = tag("meta", property: "og:title", content: @forum.name)
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
%p#notice= notice
@@ -19,7 +26,7 @@
Posts
=link_to "Post something", new_post_path(:forum_id => @forum.id), :class => 'btn btn-primary'
-- if @forum.posts.count > 0
+- if @forum.posts.size > 0
=render :partial => "posts/summary", :locals => { :posts => @forum.posts }
- else
No posts yet.
diff --git a/app/views/gardens/_form.html.haml b/app/views/gardens/_form.html.haml
index f5cd7c429..571af8aba 100644
--- a/app/views/gardens/_form.html.haml
+++ b/app/views/gardens/_form.html.haml
@@ -1,28 +1,31 @@
+= required_field_help_text
+
= form_for(@garden, :html => {:class => "form-horizontal", :role => "form"}) do |f|
- if @garden.errors.any?
#error_explanation
- %h2= "#{pluralize(@garden.errors.count, "error")} prohibited this garden from being saved:"
+ %h2= "#{pluralize(@garden.errors.size, "error")} prohibited this garden from being saved:"
%ul
- @garden.errors.full_messages.each do |msg|
%li= msg
- .form-group
+ .form-group.required
= f.label :name, :class => 'control-label col-md-2'
.col-md-8
- = f.text_field :name, :class => 'form-control'
+ = f.text_field :name, :class => 'form-control', :maxlength => 255, :required => "required"
.form-group
= f.label :description, :class => 'control-label col-md-2'
.col-md-8
= f.text_area :description, :rows => 6, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :location, :class => 'control-label col-md-2'
.col-md-8
- = f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control'
+ = f.text_field :location, :value => @garden.location || current_member.location, :class => 'form-control', :maxlength => 255
+ = render :partial => 'shared/form_optional'
%span.help-block
- If you have a location set in your profile, it will be used when
- you create a new garden.
+ = t('.location_helper')
- if current_member.location.blank?
=link_to "Set your location now.", edit_member_registration_path
- else
@@ -32,6 +35,7 @@
= f.label :area, :class => 'control-label col-md-2'
.col-md-2
= f.number_field :area, :class => 'input-small form-control'
+ = render :partial => 'shared/form_optional'
.col-md-2
= f.select(:area_unit, Garden::AREA_UNITS_VALUES, {:include_blank => false}, :class => 'form-control')
diff --git a/app/views/gardens/_thumbnail.html.haml b/app/views/gardens/_thumbnail.html.haml
new file mode 100644
index 000000000..e831dc986
--- /dev/null
+++ b/app/views/gardens/_thumbnail.html.haml
@@ -0,0 +1,36 @@
+.panel.panel-success
+ .panel-heading
+ %h3.panel-title
+ = link_to "#{garden.owner.login_name}'s garden", garden.owner
+ - if can? :edit, garden
+ %a.pull-right{:href => edit_garden_path(garden), :role => "button", :id => "edit_garden_glyphicon"}
+ %span.glyphicon.glyphicon-pencil{:title => "Edit"}
+ .panel-body{:id => "gardens_panel_body"}
+ .row
+ .col-md-4
+ = link_to image_tag((garden.default_photo ? garden.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => garden.name, :class => 'img'), garden
+ .col-md-8
+ %dl.dl-horizontal
+ %dt Name :
+ %dd= link_to garden.name, garden
+ %dt Location :
+ %dd
+ - if garden.location.blank?
+ not specified
+ - else
+ = link_to garden.location, place_path(garden.location, anchor: "gardens")
+ %dt Area :
+ %dd= garden.area.nil? ? "not specified" : pluralize(garden.area, garden.area_unit)
+ %dt Active? :
+ %dd= garden.active ? "Yes" : "No"
+ .col-md-12
+ %b
+ = "#{pluralize(garden.plantings.size, "Planting")} : "
+ = display_garden_plantings(garden.plantings.current)
+ - if garden.plantings.size > 2
+ %br
+ = link_to "See more plantings >>", garden_path(garden)
+ .panel-footer
+ %dt Description
+ %dd
+ = display_garden_description(garden)
diff --git a/app/views/gardens/index.html.haml b/app/views/gardens/index.html.haml
index 2da035865..0323d0be1 100644
--- a/app/views/gardens/index.html.haml
+++ b/app/views/gardens/index.html.haml
@@ -14,56 +14,19 @@
- else
= render :partial => 'shared/signin_signup', :locals => { :to => 'add a new garden' }
-- if @gardens.length > 0
-
- %div.pagination
- = page_entries_info @gardens, :model => "gardens"
- = will_paginate @gardens
-
- %table.table.table-striped
- %tr
- - unless @owner
- %th Owner
- %th Garden name
- %th Description
- %th Location
- %th Area
- %th Active?
- %th Plantings
- %th
+%div.pagination
+ = page_entries_info @gardens
+ = will_paginate @gardens
+.row
+ - if @gardens.size > 0
- @gardens.each do |garden|
- %tr
- - unless @owner
- %td= link_to garden.owner.login_name, garden.owner
- %td= link_to garden.name, garden
- %td= garden.description
- %td
- - if ! garden.location.blank?
- = link_to garden.location, place_path(garden.location)
- %td
- - if garden.area
- = pluralize(garden.area, garden.area_unit)
- %td= garden.active ? "Yes" : "No"
- %td
- - if garden.plantings.empty?
- None
- - else
- %ul
- - garden.plantings.each do |p|
- %li
- = p.quantity
- = link_to p.crop.name, p
- - if p.planted_at
- planted on
- = p.planted_at
-
- %td= link_to 'Details', garden, :class => 'btn btn-default btn-xs'
+ .col-md-6
+ =render :partial => 'gardens/thumbnail', :locals => {:garden => garden}
+ - else
+ %p There are no gardens to display.
- %div.pagination
- = page_entries_info @gardens, :model => "gardens"
- = will_paginate @gardens
-
-- else
- %p There are no gardens to display.
+%div.pagination
+ = page_entries_info @gardens
+ = will_paginate @gardens
diff --git a/app/views/gardens/show.html.haml b/app/views/gardens/show.html.haml
index 25c707fb3..fb5eeae12 100644
--- a/app/views/gardens/show.html.haml
+++ b/app/views/gardens/show.html.haml
@@ -1,8 +1,15 @@
=content_for :title, "#{@garden.owner}'s #{@garden}"
-
+- content_for :opengraph do
+ - @garden.photos.each do |photo|
+ = tag("meta", property: "og:image", content: photo.fullsize_url)
+ - if @garden.description
+ = tag("meta", property: "og:description", content: @garden.description)
+ = tag("meta", property: "og:title", content: "#{@garden.owner}'s #{@garden}")
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
.row
.col-md-9
-
- if can? :edit, @garden or can? :delete, @garden
%p.btn-group
- if can? :edit, @garden
@@ -28,37 +35,46 @@
%div
:growstuff_markdown
#{strip_tags @garden.description}
+ - unless @garden.description
+ .row-fluid
+ %p No description available yet.
- - if @garden.photos.count > 0 or (can? :edit, @garden and can? :create, Photo)
- .row
- %h2 Photos
+ - if can? :edit, @garden
+ %p
+ Why not
+ = link_to 'tell us more.', edit_garden_path(@garden)
- %ul.thumbnails
- - @garden.photos.each do |p|
- .col-md-2.six-across
- = render :partial => 'photos/thumbnail', :locals => { :photo => p }
+ - if @garden.photos.size > 0 or (can? :edit, @garden and can? :create, Photo)
+ .row-fluid
+ %h3 Photos
+ %p= pluralize(@garden.photos.length, "photo")
+ .row-fluid
+ %ul.thumbnails
+ - @garden.photos.each do |p|
+ .col-md-2.six-across
+ = render :partial => 'photos/thumbnail', :locals => { :photo => p }
+ .row-fluid
- if can? :create, Photo and can? :edit, @garden
- .col-md-2
- .thumbnail(style='height: 220px')
- %p{:style => 'text-align: center; padding-top: 50px'}
- = link_to "Add photo", new_photo_path(:type => "garden", :id => @garden.id), :class => 'btn btn-primary'
+ %p
+ = link_to "Add photo", new_photo_path(:type => "garden", :id => @garden.id), :class => 'btn btn-primary'
+ .row-fluid
+ %h3 What's planted here?
+ - if @garden.plantings.current.size > 0
+ - @garden.plantings.current.each.with_index do |planting_current, index_current|
+ = render partial: "plantings/thumbnail", locals: {:planting => planting_current}
+ - else
+ %p
+ Nothing is currently planted here.
- %h3
- What's planted here?
-
- - if @garden.plantings.current.count > 0
- - @garden.plantings.current.each do |p|
- = render :partial => "plantings/thumbnail", :locals => { :planting => p }
- - else
- %p
- Nothing is currently planted here.
-
- - if @garden.plantings.finished.count > 0
+ .row-fluid
%h3 Previously planted in this garden
- - @garden.plantings.finished.each do |p|
- = render :partial => "plantings/thumbnail", :locals => { :planting => p }
-
+ - if @garden.plantings.finished.size > 0
+ - @garden.plantings.finished.each.with_index do |planting_finished|
+ = render partial: "plantings/thumbnail", locals: {:planting => planting_finished}
+ - else
+ %p
+ Nothing has been planted here.
.col-md-3
%h4 About this garden
%p
@@ -82,7 +98,7 @@
- else
= link_to "#{othergarden}", garden_path(othergarden)
- - if @garden.owner.gardens.inactive.count > 0
+ - if @garden.owner.gardens.inactive.size > 0
%h4= "Inactive gardens"
%ul
- @garden.owner.gardens.inactive.each do |othergarden|
diff --git a/app/views/harvests/_form.html.haml b/app/views/harvests/_form.html.haml
index 83aa71d08..c116f757c 100644
--- a/app/views/harvests/_form.html.haml
+++ b/app/views/harvests/_form.html.haml
@@ -1,25 +1,28 @@
+= required_field_help_text
+
= form_for(@harvest, :html => {:class => "form-horizontal", :role => :form}) do |f|
- if @harvest.errors.any?
#error_explanation
- %h2= "#{pluralize(@harvest.errors.count, "error")} prohibited this harvest from being saved:"
+ %h2= "#{pluralize(@harvest.errors.size, "error")} prohibited this harvest from being saved:"
%ul
- @harvest.errors.full_messages.each do |msg|
%li= msg
- .form-group
+ .form-group.required
= f.label :crop, 'What did you harvest?', :class => 'control-label col-md-2'
.col-md-4
= auto_suggest @harvest, :crop, :class => 'form-control col-md-2', :default => @crop
.col-md-4
- = collection_select(:harvest, :plant_part_id, PlantPart.all, :id, :name, { :selected => @harvest.plant_part_id }, { :class => 'form-control' })
+ = collection_select(:harvest, :plant_part_id, PlantPart.all, :id, :name, { :selected => @harvest.plant_part_id }, { :class => 'form-control', :prompt => 'e.g. fruit', :required => "required" })
%span.help-block.col-md-8
Can't find what you're looking for?
- = link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link
+ = link_to "Request new crops.", new_crop_path
.form-group
= f.label :harvested_at, 'When?', :class => 'control-label col-md-2'
.col-md-2
= f.text_field :harvested_at, :value => @harvest.harvested_at ? @harvest.harvested_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :quantity, 'How many?', :class => 'control-label col-md-2'
@@ -27,20 +30,23 @@
-# Some browsers (eg Firefox for Android) assume "number" means
-# "integer" unless you specify step="any":
-# http://blog.isotoma.com/2012/03/html5-input-typenumber-and-decimalsfloats-in-chrome/
- = f.number_field :quantity, :class => 'input-small', :step => 'any', :class => 'form-control'
+ = f.number_field :quantity, :class => 'input-small form-control', :step => 'any'
+ = render :partial => 'shared/form_optional'
.col-md-2
= f.select(:unit, Harvest::UNITS_VALUES, {:include_blank => false}, :class => 'input-medium form-control')
.form-group
= f.label :weight_quantity, 'Weighing (in total):', :class => 'control-label col-md-2'
.col-md-2
- = f.number_field :weight_quantity, :class => 'input-small', :step => 'any', :class => 'form-control'
+ = f.number_field :weight_quantity, :class => 'input-small form-control', :step => 'any'
+ = render :partial => 'shared/form_optional'
.col-md-2
= f.select(:weight_unit, Harvest::WEIGHT_UNITS_VALUES, {:include_blank => false}, :class => 'form-control')
.form-group
= f.label :description, 'Notes', :class => 'control-label col-md-2'
.col-md-8
= f.text_area :description, :rows => 6, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.form-group
.form-actions.col-md-offset-2.col-md-8
diff --git a/app/views/harvests/_thumbnail.html.haml b/app/views/harvests/_thumbnail.html.haml
new file mode 100644
index 000000000..d21614947
--- /dev/null
+++ b/app/views/harvests/_thumbnail.html.haml
@@ -0,0 +1,27 @@
+.panel.panel-success
+ .panel-heading
+ %h3.panel-title
+ = link_to "#{harvest.owner.login_name}'s harvest", harvest.owner
+ - if can? :edit, harvest
+ %a.pull-right{:href => edit_harvest_path(harvest), :role => "button", :id => "edit_harvest_glyphicon"}
+ %span.glyphicon.glyphicon-pencil{:title => "Edit"}
+ .panel-body
+ .row
+ .col-md-4
+ = link_to image_tag((harvest.crop.default_photo ? harvest.crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => harvest.crop.name, :class => 'img'), harvest.crop
+ .col-md-8
+ %dl.dl-horizontal
+ %dt Crop :
+ %dd= link_to harvest.crop.name, harvest.crop
+ %dt Plant part :
+ %dd= link_to harvest.plant_part, harvest.plant_part
+ %dt Quantity :
+ %dd= display_quantity(harvest)
+ %dt Harvest date :
+ %dd= harvest.harvested_at
+ .panel-footer
+ %dt Description
+ %dd.truncate
+ = display_harvest_description(harvest)
+ = if not harvest.description.empty?
+ - link_to "Read more", harvest_path(harvest)
diff --git a/app/views/harvests/index.html.haml b/app/views/harvests/index.html.haml
index f50129c9a..f6f5fff7f 100644
--- a/app/views/harvests/index.html.haml
+++ b/app/views/harvests/index.html.haml
@@ -1,4 +1,6 @@
-- content_for :title, @owner ? "#{@owner}'s harvests" : @crop ? "Everyone's #{@crop.name} harvests" : "Everyone's harvests"
+- content_for :title, @owner ? t('.title.owner_harvests', owner: @owner) : @crop ? t('.title.crop_harvests', crop: @crop.name) : t('.title.default')
+- if @owner
+ = link_to "View #{@owner}'s profile >>", member_path(@owner)
%p
#{ENV['GROWSTUFF_SITE_NAME']} helps you track what you're
@@ -19,38 +21,17 @@
= render :partial => 'shared/signin_signup', :locals => { :to => 'track your harvests' }
%div.pagination
- = page_entries_info @harvests, :model => "harvests"
+ = page_entries_info @harvests
= will_paginate @harvests
-
-- if @harvests.length > 0
-
- %table.table.table-striped
- %tr
- - unless @owner
- %th Owner
- %th Crop
- %th Plant part
- %th Date
- %th Quantity
- %th Description
- %th
-
+.row
+ - if @harvests.size > 0
- @harvests.each do |harvest|
- %tr
- - unless @owner
- %td= link_to harvest.owner.login_name, harvest.owner
- %td= link_to harvest.crop.name, harvest.crop
- %td
- - if harvest.plant_part
- = link_to harvest.plant_part.name, harvest.plant_part
- %td= harvest.harvested_at
- %td= display_quantity(harvest)
- %td= harvest.description
- %td= link_to 'Details', harvest, :class => 'btn btn-default btn-xs'
+ .col-md-6
+ =render :partial => 'harvests/thumbnail', :locals => {:harvest => harvest}
- %div.pagination
- = page_entries_info @harvests, :model => "harvests"
- = will_paginate @harvests
+%div.pagination
+ = page_entries_info @harvests
+ = will_paginate @harvests
%ul.list-inline
%li The data on this page is available in the following formats:
diff --git a/app/views/harvests/show.html.haml b/app/views/harvests/show.html.haml
index 1cbd0d38e..f4e6220d8 100644
--- a/app/views/harvests/show.html.haml
+++ b/app/views/harvests/show.html.haml
@@ -1,4 +1,12 @@
=content_for :title, "#{@harvest.crop} harvested by #{@harvest.owner}"
+- content_for :opengraph do
+ - @harvest.photos.each do |photo|
+ = tag("meta", property: "og:image", content: photo.fullsize_url)
+ = tag("meta", property: "og:image:user_generated", content: "true")
+ = tag("meta", property: "og:title", content: "#{@harvest.crop} harvested by #{@harvest.owner}")
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
.row
.col-md-6
@@ -35,7 +43,7 @@
:growstuff_markdown
#{ @harvest.description != "" ? @harvest.description : "No description given." }
-- if @harvest.photos.count > 0 or (can? :edit, @harvest and can? :create, Photo)
+- if @harvest.photos.size > 0 or (can? :edit, @harvest and can? :create, Photo)
%h2 Pictures
%ul.thumbnails
diff --git a/app/views/home/_members.html.haml b/app/views/home/_members.html.haml
index cca5829d6..aea526c21 100644
--- a/app/views/home/_members.html.haml
+++ b/app/views/home/_members.html.haml
@@ -2,12 +2,12 @@
.hidden-xs
- members = Member.interesting.first(6)
- if members.present?
+ %section
%h2= t('.title')
- .row
+ .member-cards
- members.each do |m|
- .col-md-4.homepage-members
- = render :partial => "members/thumbnail", :locals => { :member => m }
+ = render :partial => "members/thumbnail", :locals => { :member => m }
%p.text-right
= link_to "#{t('.view_all')} »", members_path
diff --git a/app/views/home/_seeds.html.haml b/app/views/home/_seeds.html.haml
index 817af347c..ce786b7bd 100644
--- a/app/views/home/_seeds.html.haml
+++ b/app/views/home/_seeds.html.haml
@@ -4,7 +4,7 @@
%h2= t('.title')
- cache cache_key_for(Seed) do
- - if seeds.length > 0
+ - if seeds.size > 0
%table.table.table-striped
%tr
diff --git a/app/views/home/_stats.html.haml b/app/views/home/_stats.html.haml
index e13f74719..53ffd2492 100644
--- a/app/views/home/_stats.html.haml
+++ b/app/views/home/_stats.html.haml
@@ -1,7 +1,7 @@
- cache("homepage_stats") do
%p.stats
- = t('.message_html', { member: link_to(t('.member_linktext', count: Member.confirmed.count.to_i), members_path),
- number_crops: link_to(t('.number_crops_linktext', count: Crop.count.to_i), crops_path),
+ = t('.message_html', { member: link_to(t('.member_linktext', count: Member.confirmed.size.to_i), members_path),
+ number_crops: link_to(t('.number_crops_linktext', count: Crop.count.to_i), crops_path),
number_plantings: link_to(t('.number_plantings_linktext', count: Planting.count.to_i), plantings_path),
number_gardens: link_to(t('.number_gardens_linktext', count: Garden.count.to_i), gardens_path) })
diff --git a/app/views/layouts/_crowdfunding.html.haml b/app/views/layouts/_crowdfunding.html.haml
deleted file mode 100644
index 63a27b4a8..000000000
--- a/app/views/layouts/_crowdfunding.html.haml
+++ /dev/null
@@ -1,7 +0,0 @@
-- daysleft = Date.new(2014, 10, 22) - Date.today # end of campaign is the 21st, this gives a number that matches what IGG uses
-- if daysleft > 0
- .crowdfunding-banner
- Help us share free growing information with the world.
- = link_to "Support our crowdfunding campaign.", "https://www.indiegogo.com/projects/growstuff/x/6079859"
- There are only #{daysleft.to_i} days left.
-
diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml
index e7dba1d25..75e93f27f 100644
--- a/app/views/layouts/_footer.html.haml
+++ b/app/views/layouts/_footer.html.haml
@@ -1,9 +1,12 @@
.navbar.navbar-default.navbar-bottom
.container
.row
- .col-md-4#about-growstuff
+ .col-md-4#footer1
!= cms_snippet_content(:footer1)
- .col-md-4#policies
+ .col-md-4#footer2
!= cms_snippet_content(:footer2)
- .col-md-4#contact
+ .col-md-4#footer3
!= cms_snippet_content(:footer3)
+ %div(style="float: right;")
+ %a(href="http://opendefinition.org/ossd/")
+ %img(src="http://assets.okfn.org/images/ok_buttons/os_80x15_blue.png" alt="")
diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml
index 7560ebeec..ddc9c6af2 100644
--- a/app/views/layouts/_header.html.haml
+++ b/app/views/layouts/_header.html.haml
@@ -1,5 +1,5 @@
.sr-only
- =link_to "Skip navigation menu", "#skipnav"
+ =link_to t(".skip"), "#skipnav"
.navbar.navbar-default.navbar-fixed-top(role="navigation")
.container
.navbar-header
@@ -10,56 +10,61 @@
%span.icon-bar
%a.navbar-brand(href=root_path)
= image_tag("growstuff-brand.png", :size => "200x50", :alt => ENV['GROWSTUFF_SITE_NAME'])
+ = form_tag crops_search_path, :method => :get, :id => 'navbar-search', :class => 'navbar-form pull-right' do
+ .input
+ = label_tag :term, "Search crop database:", :class => 'sr-only'
+ = text_field_tag 'term', nil, :class => 'search-query input-medium form-control', :placeholder => 'Search crops'
+ = submit_tag "Search", :class => 'btn sr-only'
+
.navbar-collapse.collapse#navbar-collapse
- %ul.nav.navbar-nav
+ %ul.nav.navbar-nav.pull-right
%li.dropdown<
%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => crops_path}
Crops
%b.caret
%ul.dropdown-menu
- %li= link_to "Browse Crops", crops_path
- %li= link_to "Seeds", seeds_path
- %li= link_to "Plantings", plantings_path
- %li= link_to "Harvests", harvests_path
+ %li= link_to t('.browse_crops'), crops_path
+ %li= link_to t('.seeds'), seeds_path
+ %li= link_to t('.plantings'), plantings_path
+ %li= link_to t('.harvests'), harvests_path
%li.dropdown<
%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => members_path}
Community
%b.caret
%ul.dropdown-menu
- %li= link_to "Community Map", places_path
- %li= link_to "Browse Members", members_path
- %li= link_to "Posts", posts_path
- %li= link_to "Forums", forums_path
-
+ %li= link_to t('.community_map'), places_path
+ %li= link_to t('.browse_members'), members_path
+ %li= link_to t('.posts'), posts_path
+ %li= link_to t('.forums'), forums_path
+ %li= link_to t('.support_growstuff'), shop_path
- if member_signed_in?
%li.dropdown<
%a.dropdown-toggle{'data-toggle' => 'dropdown', :href => root_path}
- if current_member.notifications.unread_count > 0
- Your Stuff (#{current_member.notifications.unread_count})
+ = t('.your_stuff', unread_count: current_member.notifications.unread_count)
- else
- Your Stuff
+ #{current_member.login_name}
%b.caret
%ul.dropdown-menu
- %li= link_to "Profile", member_path(current_member)
- %li= link_to "Gardens", gardens_by_owner_path(:owner => current_member.slug)
- %li= link_to "Plantings", plantings_by_owner_path(:owner => current_member.slug)
- %li= link_to "Harvests", harvests_by_owner_path(:owner => current_member.slug)
- %li= link_to "Seeds", seeds_by_owner_path(:owner => current_member.slug)
- %li= link_to "Posts", posts_by_author_path(:author => current_member.slug)
- %li= link_to "Account", orders_path
+ %li= link_to t('.profile'), member_path(current_member)
+ %li= link_to t('.gardens'), gardens_by_owner_path(:owner => current_member.slug)
+ %li= link_to t('.plantings'), plantings_by_owner_path(:owner => current_member.slug)
+ %li= link_to t('.harvest'), harvests_by_owner_path(:owner => current_member.slug)
+ %li= link_to t('.seeds'), seeds_by_owner_path(:owner => current_member.slug)
+ %li= link_to t('.posts'), posts_by_author_path(:author => current_member.slug)
+ %li= link_to t('.account'), orders_path
%li
- if current_member.notifications.unread_count > 0
- = link_to("Inbox (#{current_member.notifications.unread_count})", notifications_path)
+ = link_to(t('.inbox_unread', unread_count: current_member.notifications.unread_count), notifications_path)
- else
- = link_to("Inbox", notifications_path)
+ = link_to(t('.inbox'), notifications_path)
- if current_member.has_role?(:crop_wrangler) || current_member.has_role?(:admin)
%li{:class => 'divider', :role => 'presentation'}
- if current_member.has_role?(:crop_wrangler)
- %li= link_to "Crop Wrangling", wrangle_crops_path
+ %li= link_to t('.crop_wrangling'), wrangle_crops_path
- if current_member.has_role?(:admin)
- %li= link_to "Admin", admin_path
- %li= link_to "Support Growstuff", shop_path
+ %li= link_to t('.admin'), admin_path
%li= link_to "Sign out", destroy_member_session_path, :method => :delete
@@ -68,11 +73,6 @@
%li= link_to 'Sign in', new_member_session_path, :id => 'navbar-signin'
%li= link_to 'Sign up', new_member_registration_path, :id => 'navbar-signup'
- = form_tag crops_search_path, :method => :get, :id => 'navbar-search', :class => 'navbar-form pull-right' do
- .input
- = label_tag :search, "Search crop database:", :class => 'sr-only'
- = text_field_tag 'search', nil, :class => 'search-query input-medium form-control', :placeholder => 'Search crops'
- = submit_tag "Search", :class => 'btn sr-only'
- # anchor tag for accessibility link to skip the navigation menu
%a{:name => 'skipnav'}
diff --git a/app/views/layouts/_meta.html.haml b/app/views/layouts/_meta.html.haml
index 13acb28bc..70785e06d 100644
--- a/app/views/layouts/_meta.html.haml
+++ b/app/views/layouts/_meta.html.haml
@@ -1,6 +1,14 @@
%head
+ - if content_for?(:opengraph)
+ = yield(:opengraph)
+ - else
+ = tag("meta", property: "og:image", content: image_url('facebook-thumbnail.png'))
+ = tag("meta", property: "og:title", content: "#{content_for?(:title) ? yield(:title) + " - #{ ENV['GROWSTUFF_SITE_NAME']} " : ENV['GROWSTUFF_SITE_NAME']}")
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: root_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
- if (content_for?(:member_rss_login_name) && content_for(:member_rss_slug))
= auto_discovery_link_tag(:rss, { :controller => "/members", :action => 'show', :format => "rss", :id => yield(:member_rss_slug) }, { :title => "#{ ENV['GROWSTUFF_SITE_NAME'] }- #{yield(:member_rss_login_name)}'s posts" })
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 66b78017a..a17bde125 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -1,9 +1,8 @@
!!! 5
-%html(lang="en")
+%html(lang="en" prefix="og: http://ogp.me/ns#")
= render :partial => "layouts/meta"
%body
= render :partial => "layouts/header"
- = render :partial => "layouts/crowdfunding"
#maincontainer.container
.row
diff --git a/app/views/members/_account.html.haml b/app/views/members/_account.html.haml
index 68dfbd591..ae8333067 100644
--- a/app/views/members/_account.html.haml
+++ b/app/views/members/_account.html.haml
@@ -9,3 +9,16 @@
= member.account_type
account
+%p
+ %strong Last Login:
+ = member.last_sign_in_at
+
+%p
+ %strong Member Roles:
+ %br
+ - if member.has_role? :admin
+ Administrator
+ - if member.has_role? :crop_wrangler
+ Crop Wrangler
+ - else
+ Member
diff --git a/app/views/members/_avatar.html.haml b/app/views/members/_avatar.html.haml
index da33ac2da..3089dc4be 100644
--- a/app/views/members/_avatar.html.haml
+++ b/app/views/members/_avatar.html.haml
@@ -1,9 +1,5 @@
= link_to |
- image_tag( |
- Gravatar.new(member.email).image_url( |
- options = { |
- :size => defined?(size) ? size : 150, |
- :default => :identicon }), |
+ image_tag(avatar_uri(member, 150), |
:alt => '', |
- :class => 'img img-responsive avatar' ), |
+ :class => 'img img-responsive avatar' ), |
member_path(member)
diff --git a/app/views/members/_gardens.html.haml b/app/views/members/_gardens.html.haml
index 38831922c..ad40fda9a 100644
--- a/app/views/members/_gardens.html.haml
+++ b/app/views/members/_gardens.html.haml
@@ -7,35 +7,49 @@
- first_garden = false
= link_to g.name, "#garden#{g.id}", 'data-toggle' => 'tab'
- if current_member == member
- %li= link_to 'New Garden', new_garden_path
- .tab-content
+ %li.navbar-right
+ = link_to new_garden_path, class: 'btn' do
+ Add New Garden
+ .tab-content{style: "padding-top: 1em"}
- first_garden = true
- member.gardens.each do |g|
%div{:class => ['tab-pane', first_garden ? 'active' : ''], :id => "garden#{g.id}"}
- first_garden = false
- %div
+ .container
:growstuff_markdown
#{ strip_tags g.description }
-
- - if g.photos.count > 0 or (can? :edit, g and can? :create, Photo)
+ - unless g.description
.row
- %h2 Photos
+ %p No description available yet.
- %ul.thumbnails
- - g.photos.each do |p|
- .col-md-2.six-across
- = render :partial => 'photos/thumbnail', :locals => { :photo => p }
- - if can? :create, Photo and can? :edit, g
- .col-md-2
- .thumbnail(style='height: 220px')
- %p{:style => 'text-align: center; padding-top: 50px'}
- = link_to "Add photo", new_photo_path(:type => "garden", :id => g.id), :class => 'btn btn-primary'
+ - if can? :edit, g
+ %p
+ Why not
+ = link_to 'tell us more.', edit_garden_path(g)
- %h3 What's planted here?
- - g.featured_plantings.each do |p|
- = render :partial => "plantings/thumbnail", :locals => { :planting => p, :hide_description => true }
- %p
- = link_to "More about this garden...", url_for(g)
+ - if g.photos.size > 0 or (can? :edit, g and can? :create, Photo)
+ .row
+ %h3 Photos
+ %p= pluralize(g.photos.length, "photo")
+ .row
+ %ul.thumbnails
+ - g.photos.each do |p|
+ .col-md-2.six-across
+ = render :partial => 'photos/thumbnail', :locals => { :photo => p }
+ .row
+ - if can? :create, Photo and can? :edit, g
+ %p
+ = link_to "Add photo", new_photo_path(:type => "garden", :id => g.id), :class => 'btn btn-primary'
+
+ %h3 What's planted here?
+ .row
+ - if g.featured_plantings.size > 0
+ - g.featured_plantings.each.with_index do |planting|
+ .col-xs-12.col-lg-6
+ = render partial: "plantings/thumbnail", locals: {:planting => planting}
+
+ %p
+ = link_to "More about this garden...", url_for(g)
diff --git a/app/views/members/_image_with_popover.html.haml b/app/views/members/_image_with_popover.html.haml
deleted file mode 100644
index fb9caddfc..000000000
--- a/app/views/members/_image_with_popover.html.haml
+++ /dev/null
@@ -1,15 +0,0 @@
-= link_to |
- image_tag( |
- Gravatar.new(member.email).image_url( |
- options = { |
- :size => defined?(size) ? size : 150, |
- :default => :identicon }), |
- :alt => member.login_name, |
- :class => 'img-responsive member-image' |
- ), |
- member, |
- :rel => "popover", |
- 'data-trigger' => 'hover', |
- 'data-title' => member.login_name, |
- 'data-content' => "#{ render :partial => 'members/popover', :locals => { :member => member } }", |
- 'data-html' => true
diff --git a/app/views/members/_location.html.haml b/app/views/members/_location.html.haml
index 195897d71..a8442afe2 100644
--- a/app/views/members/_location.html.haml
+++ b/app/views/members/_location.html.haml
@@ -2,4 +2,4 @@
- if member.location.blank?
unknown location
- else
- = link_to member.location, place_path(:place => member.location)
+ = link_to member.location, place_path(:place => member.location, anchor: "members")
diff --git a/app/views/members/_map.html.haml b/app/views/members/_map.html.haml
index d98792501..cbf32ea6e 100644
--- a/app/views/members/_map.html.haml
+++ b/app/views/members/_map.html.haml
@@ -1,5 +1,9 @@
- if member.latitude and member.longitude
%div#membermap
%p
- See other members near
- = link_to member.location, place_path(member.location)
+ See other members, plantings, seeds and more near
+ = link_to member.location, place_path(member.location, anchor: "members")
+- else
+ %div.location-not-set
+ %div.sr-only Location not known
+ %div.sr-only We can't show you what's nearby
\ No newline at end of file
diff --git a/app/views/members/_popover.html.haml b/app/views/members/_popover.html.haml
deleted file mode 100644
index 24122c560..000000000
--- a/app/views/members/_popover.html.haml
+++ /dev/null
@@ -1,15 +0,0 @@
-%small
- %p
- - if member.location
- %i
- = member.location
- %p
- Joined
- = distance_of_time_in_words(member.created_at, Time.zone.now)
- ago.
- %p
- = pluralize(member.gardens.size, "garden")
- %br/
- = pluralize(member.plantings.size, "planting")
- %br/
- = pluralize(member.seeds.size, "seed")
diff --git a/app/views/members/_stats.html.haml b/app/views/members/_stats.html.haml
index b6e52873d..26635e2f1 100644
--- a/app/views/members/_stats.html.haml
+++ b/app/views/members/_stats.html.haml
@@ -1,35 +1,35 @@
%h3 Activity
-%ul
+%ul.list-inline
%li
- - if member.plantings.count > 0
+ - if member.plantings.size > 0
= link_to pluralize(member.plantings.size, "planting"), plantings_by_owner_path(:owner => member)
- else
0 plantings
%li
- - if member.harvests.count > 0
+ - if member.harvests.size > 0
= link_to pluralize(member.harvests.size, "harvest"), harvests_by_owner_path(:owner => member)
- else
0 harvests
%li
- - if member.seeds.count > 0
+ - if member.seeds.size > 0
= link_to pluralize(member.seeds.size, "seeds"), seeds_by_owner_path(:owner => member)
- else
0 seeds
%li
- - if member.posts.count > 0
+ - if member.posts.size > 0
= link_to pluralize(member.posts.size, "post"), posts_by_author_path(:author => member)
- else
0 posts
%li
- - if member.followed.count > 0
+ - if member.followed.size > 0
= link_to pluralize(member.followed.size, "follow"), member_follows_path(member)
- else
0 following
%li
- - if member.followers.count > 0
+ - if member.followers.size > 0
= link_to pluralize(member.followers.size, "follower"), member_followers_path(member)
- else
0 followers
diff --git a/app/views/members/_thumbnail.html.haml b/app/views/members/_thumbnail.html.haml
index c90faba8a..a55c34e50 100644
--- a/app/views/members/_thumbnail.html.haml
+++ b/app/views/members/_thumbnail.html.haml
@@ -1,17 +1,24 @@
- cache member do
- .row
- .member-thumbnail
- .col-md-3
- = render :partial => "members/image_with_popover", :locals => { :member => member }
- .col-md-9
- %p
- = link_to member.login_name, member
- - if ! member.location.blank?
- %small
- %br/
- %i= member.location
- - if ! member.plantings.empty?
- %small
- %br/
- Recently planted:
- != member.plantings.first(3).map{|p| link_to p.crop_name, p }.join(", ")
+ .member-thumbnail.panel
+ %div
+ = render :partial => "members/avatar", :locals => { :member => member }
+ %div
+ %p.login-name
+ = link_to member.login_name, member
+ - if !member.location.blank?
+ %small
+ %br/
+ %i= member.location
+ - if !member.plantings.empty?
+ %small
+ %br/
+ Recently planted:
+ != member.plantings.first(3).map{|p| link_to p.crop_name, p }.join(", ")
+ %p
+ %small
+ Joined
+ = distance_of_time_in_words(member.created_at, Time.zone.now)
+ ago.
+ %p
+ %small
+ = [pluralize(member.gardens.size, "garden"), pluralize(member.plantings.size, "planting"), pluralize(member.seeds.size, "seed")].join(", ")
diff --git a/app/views/members/index.html.haml b/app/views/members/index.html.haml
index 36ba70887..43f3b2867 100644
--- a/app/views/members/index.html.haml
+++ b/app/views/members/index.html.haml
@@ -1,4 +1,4 @@
-= content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} members"
+= content_for :title, t(".title", site_name: "#{ENV['GROWSTUFF_SITE_NAME']}")
= form_tag(members_path, :method => :get, :class => 'form-inline', :role => 'form') do
.form-group
@@ -7,15 +7,13 @@
= submit_tag "Show", :class => 'btn btn-primary'
%div.pagination
- = page_entries_info @members, :model => "members"
+ = page_entries_info @members
= will_paginate @members
-.row
+.member-cards
- @members.each do |m|
- .col-md-4.three-across
- .thumbnail
- = render :partial => "members/thumbnail", :locals => { :member => m }
+ = render :partial => "members/thumbnail", :locals => { :member => m }
%div.pagination
- = page_entries_info @members, :model => "members"
+ = page_entries_info @members
= will_paginate @members
diff --git a/app/views/members/show.html.haml b/app/views/members/show.html.haml
index 591c2be77..c40482641 100644
--- a/app/views/members/show.html.haml
+++ b/app/views/members/show.html.haml
@@ -1,5 +1,12 @@
- content_for :title, @member.login_name
- content_for :subtitle, @member.location
+- content_for :opengraph do
+ = tag("meta", property: "og:image", content: avatar_uri(@member, 200))
+ = tag("meta", property: "og:image:user_generated", content: "true")
+ = tag("meta", property: "og:title", content: @member.login_name)
+ = tag("meta", property: "og:type", content: "profile")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
- content_for :buttonbar do
- if can? :update, @member
= link_to 'Edit profile', edit_member_registration_path, :class => 'btn btn-default'
diff --git a/app/views/members/unsubscribe.html.haml b/app/views/members/unsubscribe.html.haml
new file mode 100644
index 000000000..b11a52a50
--- /dev/null
+++ b/app/views/members/unsubscribe.html.haml
@@ -0,0 +1,5 @@
+- content_for :title, "Unsubscribe #{@member}"
+
+%p
+ If you wish to unsubscribe from other Growstuff emails, you may do so via
+ = link_to "your settings page", edit_member_registration_url
diff --git a/app/views/members/view_followers.html.haml b/app/views/members/view_followers.html.haml
index 25a10a860..6600c737c 100644
--- a/app/views/members/view_followers.html.haml
+++ b/app/views/members/view_followers.html.haml
@@ -1,7 +1,7 @@
- content_for :title, "#{@member.login_name}'s followers"
%div.pagination
- = page_entries_info @followers, :model => "members"
+ = page_entries_info @followers
= will_paginate @followers
.row
@@ -12,5 +12,5 @@
= render :partial => "members/thumbnail", :locals => { :member => f }
%div.pagination
- = page_entries_info @followers, :model => "members"
- = will_paginate @followers
\ No newline at end of file
+ = page_entries_info @followers
+ = will_paginate @followers
diff --git a/app/views/members/view_follows.html.haml b/app/views/members/view_follows.html.haml
index 93d2695ac..cd0c522de 100644
--- a/app/views/members/view_follows.html.haml
+++ b/app/views/members/view_follows.html.haml
@@ -1,7 +1,7 @@
- content_for :title, "#{@member.login_name}'s follows"
%div.pagination
- = page_entries_info @follows, :model => "members"
+ = page_entries_info @follows
= will_paginate @follows
.row
@@ -12,5 +12,5 @@
= render :partial => "members/thumbnail", :locals => { :member => f }
%div.pagination
- = page_entries_info @follows, :model => "members"
- = will_paginate @follows
\ No newline at end of file
+ = page_entries_info @follows
+ = will_paginate @follows
diff --git a/app/views/notifications/_form.html.haml b/app/views/notifications/_form.html.haml
index 91115b15a..094be410d 100644
--- a/app/views/notifications/_form.html.haml
+++ b/app/views/notifications/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @notification do |f|
- if @notification.errors.any?
#error_explanation
- %h2= "#{pluralize(@post.errors.count, "error")} prohibited this message from being sent:"
+ %h2= "#{pluralize(@post.errors.size, "error")} prohibited this message from being sent:"
%ul
- @notification.errors.full_messages.each do |msg|
%li= msg
@@ -13,7 +13,7 @@
To:
= link_to @recipient, @recipient
= label_tag :notification, "Subject:"
- = f.text_field :subject, :value => @subject, :class => 'form-control'
+ = f.text_field :subject, :value => @subject, :class => 'form-control', :maxlength => 255
= label_tag :body, "Type your message here:"
= f.text_area :body, :rows => 12, :class => 'form-control'
%span.help-block
diff --git a/app/views/notifications/_notification.html.haml b/app/views/notifications/_notification.html.haml
new file mode 100644
index 000000000..00748e728
--- /dev/null
+++ b/app/views/notifications/_notification.html.haml
@@ -0,0 +1,13 @@
+%p
+ From
+ = link_to notification.sender, notification.sender
+ on
+ = notification.created_at
+
+ - if notification.post_id
+ in response to:
+ = link_to notification.post.subject, notification.post
+
+.well
+ :growstuff_markdown
+ #{ strip_tags(notification.body) }
\ No newline at end of file
diff --git a/app/views/notifications/index.html.haml b/app/views/notifications/index.html.haml
index 1c7ec4489..e5352ad26 100644
--- a/app/views/notifications/index.html.haml
+++ b/app/views/notifications/index.html.haml
@@ -1,6 +1,7 @@
- content_for :title, "Inbox"
-- if @notifications.length > 0
+- if @notifications.size > 0
+ = paginate @notifications, theme: 'twitter-bootstrap-3'
%table.table.table-striped
%tr
%th From
@@ -28,5 +29,6 @@
%strong= n.created_at
%td
= link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
+ = paginate @notifications, theme: 'twitter-bootstrap-3'
- else
You have no messages.
diff --git a/app/views/notifications/reply.html.haml b/app/views/notifications/reply.html.haml
new file mode 100644
index 000000000..808985265
--- /dev/null
+++ b/app/views/notifications/reply.html.haml
@@ -0,0 +1,6 @@
+= content_for :title, "Send a message to #{@recipient}"
+
+= render @sender_notification
+
+=render 'form'
+
diff --git a/app/views/notifications/show.html.haml b/app/views/notifications/show.html.haml
index 1926876a6..d6cd49472 100644
--- a/app/views/notifications/show.html.haml
+++ b/app/views/notifications/show.html.haml
@@ -1,18 +1,6 @@
= content_for :title, @notification.subject
-%p
- From
- = link_to @notification.sender, @notification.sender
- on
- = @notification.created_at
-
- - if @notification.post_id
- in response to:
- = link_to @notification.post.subject, @notification.post
-
-.well
- :growstuff_markdown
- #{ strip_tags(@notification.body) }
+= render @notification
%p
=link_to 'Delete', @notification, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default'
diff --git a/app/views/notifier/crop_request_approved.html.haml b/app/views/notifier/crop_request_approved.html.haml
index 5fea20246..871522b0b 100644
--- a/app/views/notifier/crop_request_approved.html.haml
+++ b/app/views/notifier/crop_request_approved.html.haml
@@ -2,7 +2,7 @@
%p Hello #{@member.login_name},
%p
- Your request for the new crop: #{link_to @crop.name, crop_url(@crop)} has been approved!
+ Your request for the new crop: #{link_to @crop.name, crop_url(@crop)} has been approved! Thank you for helping us make our listing ever more complete!
%ul
%li
diff --git a/app/views/notifier/crop_request_rejected.html.haml b/app/views/notifier/crop_request_rejected.html.haml
index c58e2546b..d1ab14868 100644
--- a/app/views/notifier/crop_request_rejected.html.haml
+++ b/app/views/notifier/crop_request_rejected.html.haml
@@ -2,8 +2,6 @@
%p Hello #{@member.login_name},
%p
- Your request for the new crop: #{link_to @crop.name, crop_url(@crop)} has been rejected for the following reason.
+ We're sorry, but your request for the new crop: #{link_to @crop.name, crop_url(@crop)} has been rejected for the following reason: #{@crop.rejection_explanation}
- = @crop.reason_for_rejection
-
-= render :partial => 'signature'
\ No newline at end of file
+= render :partial => 'signature'
diff --git a/app/views/notifier/new_crop_request.html.haml b/app/views/notifier/new_crop_request.html.haml
index 163c898f4..0e8c65ab7 100644
--- a/app/views/notifier/new_crop_request.html.haml
+++ b/app/views/notifier/new_crop_request.html.haml
@@ -8,6 +8,7 @@
%ul
%li Name: #{@request.name}
%li Wikipedia URL: #{@request.en_wikipedia_url.present? ? @request.en_wikipedia_url : "not specified"}
+ %li Notes: #{@request.request_notes}
%p
As a crop wrangler, you can #{link_to "approve or reject this request", edit_crop_url(@request)}.
@@ -18,4 +19,4 @@
%p
Thanks for your help!
-= render :partial => 'signature'
\ No newline at end of file
+= render :partial => 'signature'
diff --git a/app/views/notifier/notify.html.haml b/app/views/notifier/notify.html.haml
index ed9cf32f2..08883a457 100644
--- a/app/views/notifier/notify.html.haml
+++ b/app/views/notifier/notify.html.haml
@@ -18,6 +18,7 @@
%br/
= link_to "View this message in your inbox", notification_url(@notification)
%br/
- = link_to "Turn off these notifications", edit_member_registration_url
+ = link_to "Unsubscribe from direct message notifications", unsubscribe_member_url(@signed_message)
+ from these notifications
= render :partial => 'signature'
\ No newline at end of file
diff --git a/app/views/notifier/planting_reminder.html.haml b/app/views/notifier/planting_reminder.html.haml
index 4dea05123..0c9d0d5ae 100644
--- a/app/views/notifier/planting_reminder.html.haml
+++ b/app/views/notifier/planting_reminder.html.haml
@@ -64,5 +64,5 @@
%hr/
%p
Don't want to get these emails any more?
- = link_to "Turn off these notifications", edit_member_registration_url
+ = link_to "Unsubscribe from planting reminders", unsubscribe_member_url(@signed_message)
diff --git a/app/views/orders/index.html.haml b/app/views/orders/index.html.haml
index e48b38c3c..f05b2f756 100644
--- a/app/views/orders/index.html.haml
+++ b/app/views/orders/index.html.haml
@@ -28,7 +28,7 @@
- else
In progress
%td
- - if order.order_items.count > 0
+ - if order.order_items.size > 0
- order.order_items.each do |o|
= o.quantity
x
diff --git a/app/views/orders/show.html.haml b/app/views/orders/show.html.haml
index dbc635d4e..29bd0f2bc 100644
--- a/app/views/orders/show.html.haml
+++ b/app/views/orders/show.html.haml
@@ -61,7 +61,7 @@
- if @order.errors.any?
.alert
#error_explanation
- %h3= "#{pluralize(@order.errors.count, "error")} stopped you from checking out:"
+ %h3= "#{pluralize(@order.errors.size, "error")} stopped you from checking out:"
%ul
- @order.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/photos/index.html.haml b/app/views/photos/index.html.haml
index 10a14f88e..f7791cdc0 100644
--- a/app/views/photos/index.html.haml
+++ b/app/views/photos/index.html.haml
@@ -3,7 +3,7 @@
%p Most recent photos added to #{ENV['GROWSTUFF_SITE_NAME']}.
%div.pagination
- = page_entries_info @photos, :model => "photos"
+ = page_entries_info @photos
= will_paginate @photos
.row
@@ -17,7 +17,7 @@
= link_to p.owner, p.owner
%div.pagination
- = page_entries_info @photos, :model => "photos"
+ = page_entries_info @photos
= will_paginate @photos
diff --git a/app/views/photos/new.html.haml b/app/views/photos/new.html.haml
index 6b4e589b0..6c8a525b6 100644
--- a/app/views/photos/new.html.haml
+++ b/app/views/photos/new.html.haml
@@ -10,7 +10,7 @@
- if @sets and @current_set
%h2= @sets.key(@current_set)
- - if @sets and @sets.length > 0
+ - if @sets and @sets.size > 0
%p
= form_tag(new_photo_path, :method => :get, :class => 'form-inline') do
= label_tag :set, "Choose a photo album:", :class => 'control-label'
@@ -20,7 +20,7 @@
= submit_tag "Search", :class => 'btn btn-primary'
%div.pagination
- = page_entries_info @photos, :model => "photos"
+ = page_entries_info @photos
= will_paginate @photos
.row
diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml
index ad331bd48..0ad731132 100644
--- a/app/views/photos/show.html.haml
+++ b/app/views/photos/show.html.haml
@@ -1,4 +1,11 @@
--content_for :title, @photo.title
+- content_for :title, @photo.title
+- content_for :opengraph do
+ = tag("meta", property: "og:title", content: @photo.title)
+ = tag("meta", property: "og:image", content: @photo.fullsize_url)
+ = tag("meta", property: "og:image:user_generated", content: "true")
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
.row
.col-md-6
@@ -19,11 +26,19 @@
%p= link_to 'Delete Photo', @photo, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
.col-md-6
- - if @photo.plantings.count > 0
+ - if @photo.plantings.size > 0 or @photo.harvests.size > 0 or @photo.gardens.size > 0
%p This photo depicts:
%ul
- - @photo.plantings.each do |p|
- %li= link_to p, p
+ - if @photo.plantings.size > 0
+ - @photo.plantings.each do |p|
+ %li= link_to t('.thing_by', thing: Planting.model_name.singular, owner: p.owner), p
+ - if @photo.harvests.size > 0
+ - @photo.harvests.each do |h|
+ %li= link_to t('.thing_by', thing: Harvest.model_name.singular, owner: h.owner), h
+ - if @photo.gardens.size > 0
+ - @photo.gardens.each do |g|
+ %li= link_to t('.thing_by', thing: Garden.model_name.singular, owner: g.owner), g
+
.row
.col-md-12
diff --git a/app/views/places/_search_form.html.haml b/app/views/places/_search_form.html.haml
new file mode 100644
index 000000000..430ebd58d
--- /dev/null
+++ b/app/views/places/_search_form.html.haml
@@ -0,0 +1,6 @@
+%form{:action => search_places_path, :method => :get, :class => 'form-inline', :role => 'form'}
+ .form-group
+ = label_tag :new_place, "Change location:", :class => 'sr-only'
+ = text_field_tag :new_place, '', :class => 'form-control', :placeholder => "New location..."
+ = submit_tag "Search", :class => 'btn btn-primary', :id => "search_button"
+%br/
diff --git a/app/views/places/index.html.haml b/app/views/places/index.html.haml
index 135d3a113..fe3264375 100644
--- a/app/views/places/index.html.haml
+++ b/app/views/places/index.html.haml
@@ -1,4 +1,4 @@
--content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} Community Map"
-
+-content_for :title, t(".title", site_name: "#{ENV['GROWSTUFF_SITE_NAME']}")
+= render partial: 'search_form'
%div#placesmap
diff --git a/app/views/places/show.html.haml b/app/views/places/show.html.haml
index b34846b39..d37da8433 100644
--- a/app/views/places/show.html.haml
+++ b/app/views/places/show.html.haml
@@ -1,20 +1,54 @@
--content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} members near #{@place}"
+-content_for :title, "#{ENV['GROWSTUFF_SITE_NAME']} community near #{@place}"
+- content_for :opengraph do
+ = tag("meta", property: "og:title", content: "#{ENV['GROWSTUFF_SITE_NAME']} community near #{@place}")
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
-%form{:action => search_places_path, :method => :get, :class => 'form-inline', :role => 'form'}
- .form-group
- = label_tag :new_place, "Change location:", :class => 'sr-only'
- = text_field_tag :new_place, '', :class => 'form-control', :placeholder => "New location..."
- = submit_tag "Search", :class => 'btn btn-primary'
-%br/
+= render partial: 'search_form'
%div#placesmap{ :style => "height:300px"}
-%h3 Nearby members
+%h3#members= "Nearby members"
- if !@nearby_members.empty?
.row
- @nearby_members.first(30).each do |member|
.col-md-4.three-across
= render :partial => "members/thumbnail", :locals => { :member => member }
-- elsif @place
- %p No results found
+ = link_to "View all members >>", members_path
+
+ %h3#seeds= "Seeds available for trade near #{@place}"
+ - crop_id = []
+ - @nearby_members.first(10).each do |member|
+ - member.seeds.first(5).each do |seed|
+ - crop_id.push seed.crop.id
+ - if !crop_id.blank?
+ .row
+ - crop_id.uniq.first(20).each do |crop|
+ .col-md-2.six-across
+ = render :partial => "crops/thumbnail", :locals => { :crop => Crop.find(crop) }
+ = link_to "View all seeds >>", seeds_path
+ - else
+ %p No nearby seeds found
+
+ #plantings
+ %h3= "Recent plantings near #{@place}"
+
+
+ - plantings = []
+ - @nearby_members.first(10).each do |member|
+ - member.plantings.first(5).each do |planting|
+ - plantings << planting
+ - if !plantings.blank?
+ .row
+ - plantings.first(10).each.with_index do |planting, index|
+ .col-xs-12.col-lg-6
+ = render partial: "plantings/thumbnail", locals: {:planting => planting, :index => index}
+ .row
+ = link_to "View all plantings >>", plantings_path
+ - else
+ .row
+ %p No nearby plantings found
+- else
+ %p No results found
\ No newline at end of file
diff --git a/app/views/plant_parts/_form.html.haml b/app/views/plant_parts/_form.html.haml
index 16bf0268d..fca6c3af3 100644
--- a/app/views/plant_parts/_form.html.haml
+++ b/app/views/plant_parts/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @plant_part do |f|
- if @plant_part.errors.any?
#error_explanation
- %h2= "#{pluralize(@plant_part.errors.count, "error")} prohibited this plant_part from being saved:"
+ %h2= "#{pluralize(@plant_part.errors.size, "error")} prohibited this plant_part from being saved:"
%ul
- @plant_part.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/plant_parts/show.html.haml b/app/views/plant_parts/show.html.haml
index 0af93e520..c24cf6ea0 100644
--- a/app/views/plant_parts/show.html.haml
+++ b/app/views/plant_parts/show.html.haml
@@ -1,4 +1,9 @@
- content_for :title, @plant_part.name.titlecase
+- content_for :opengraph do
+ = tag("meta", property: "og:title", content: @plant_part.name.titlecase)
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
- if @plant_part.crops.empty?
%p No crops are harvested for this plant part (yet).
diff --git a/app/views/plantings/_form.html.haml b/app/views/plantings/_form.html.haml
index b797d3523..bdbae6aa2 100644
--- a/app/views/plantings/_form.html.haml
+++ b/app/views/plantings/_form.html.haml
@@ -1,19 +1,21 @@
+= required_field_help_text
+
= form_for(@planting, :html => {:class => "form-horizontal", :role => "form"}) do |f|
- if @planting.errors.any?
#error_explanation
- %h2= "#{pluralize(@planting.errors.count, "error")} prohibited this planting from being saved:"
+ %h2= "#{pluralize(@planting.errors.size, "error")} prohibited this planting from being saved:"
%ul
- @planting.errors.full_messages.each do |msg|
%li= msg
- .form-group
+ .form-group.required
= f.label :crop, 'What did you plant?', :class => 'control-label col-md-2'
.col-md-8
= auto_suggest @planting, :crop, :class => 'form-control', :default => @crop
%span.help-inline
Can't find what you're looking for?
- = link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link
- .form-group
+ = link_to "Request new crops.", new_crop_path
+ .form-group.required
= f.label :garden_id, 'Where did you plant it?', :class => 'control-label col-md-2'
.col-md-8
= collection_select(:planting, :garden_id, Garden.active.where(:owner_id => current_member), :id, :name, {:selected => @planting.garden_id || @garden.id}, {:class => 'form-control'})
@@ -21,32 +23,42 @@
= link_to "Add a garden.", new_garden_path
.form-group
= f.label :planted_at, 'When?', :class => 'control-label col-md-2'
- .col-md-2= f.text_field :planted_at, :value => @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
+ .col-md-2
+ = f.text_field :planted_at, :value => @planting.planted_at ? @planting.planted_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :quantity, 'How many?', :class => 'control-label col-md-2'
.col-md-2
= f.number_field :quantity, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :planted_from, 'Planted from:', :class => 'control-label col-md-2'
.col-md-8
- = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, {:include_blank => true}, :class => 'form-control')
+ = f.select(:planted_from, Planting::PLANTED_FROM_VALUES, {:include_blank => ''}, :class => 'form-control')
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :sunniness, 'Sun or shade?', :class => 'control-label col-md-2'
.col-md-8
- = f.select(:sunniness, Planting::SUNNINESS_VALUES, {:include_blank => true}, :class => 'form-control')
+ = f.select(:sunniness, Planting::SUNNINESS_VALUES, {:include_blank => ''}, :class => 'form-control')
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :description, 'Tell us more about it', :class => 'control-label col-md-2'
- .col-md-8= f.text_area :description, :rows => 6, :class => 'form-control'
+ .col-md-8
+ = f.text_area :description, :rows => 6, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :finished, 'Mark as finished', :class => 'control-label col-md-2'
.col-md-8
= f.check_box :finished
+ = render :partial => 'shared/form_optional'
%span.help-block
- A planting is finished when you've harvested all of the crop, or it dies, or it's otherwise no longer growing in your garden.
+ = t('.finish_helper')
+
.form-group
= f.label :finished_at, 'Finished date', { :class => 'control-label col-md-2' }
.col-md-2
- = f.text_field :finished_at, :value => @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', :class => 'add-datepicker form-control'
+ = f.text_field :finished_at, :value => @planting.finished_at ? @planting.finished_at.to_s(:ymd) : '', :class => 'add-datepicker form-control', :placeholder => 'optional'
+ = render :partial => 'shared/form_optional'
.form-group
.form-actions.col-md-offset-2.col-md-8
= f.submit 'Save', :class => 'btn btn-primary'
diff --git a/app/views/plantings/_planting_progress.html.haml b/app/views/plantings/_planting_progress.html.haml
new file mode 100644
index 000000000..a9c851709
--- /dev/null
+++ b/app/views/plantings/_planting_progress.html.haml
@@ -0,0 +1,10 @@
+- if !planting.planted?
+ = "Progress: 0% - not planted yet"
+- elsif planting.finished?
+ = "Progress: 100%"
+ = render partial: "plantings/progress_bar", locals: {status: "success", progress: "100%"}
+- elsif planting.days_before_maturity.nil?
+ = "Progress: Not calculated, days before maturity unknown"
+- else
+ = "Progress: #{planting.percentage_grown}%"
+ = render partial: "plantings/progress_bar", locals: {status: "success", progress: "#{planting.percentage_grown}%"}
diff --git a/app/views/plantings/_progress_bar.html.haml b/app/views/plantings/_progress_bar.html.haml
new file mode 100644
index 000000000..4b13c3338
--- /dev/null
+++ b/app/views/plantings/_progress_bar.html.haml
@@ -0,0 +1,2 @@
+.progress
+ %div{:class => "progress-bar progress-bar-#{status}", :role => "progressbar", :style => "width: #{progress}"}
diff --git a/app/views/plantings/_thumbnail.html.haml b/app/views/plantings/_thumbnail.html.haml
index f1b67c2cb..3ae1ee084 100644
--- a/app/views/plantings/_thumbnail.html.haml
+++ b/app/views/plantings/_thumbnail.html.haml
@@ -1,47 +1,44 @@
-.well
- .row
- .col-md-3
- = link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => '', :class => 'img'), planting
-
- .col-md-9
- %h4
- - if defined?(title) && title == 'owner'
- = link_to planting.owner, planting.owner
- - else
- = link_to planting.crop.name, planting
-
- %p
- Planted
- - if planting.planted_at
- = planting.planted_at
- in
- = link_to planting.location, planting.garden
-
- %p
- - if planting.quantity
- Quantity:
- = planting.quantity
- - else
-
-
- - if planting.description && ! defined?(hide_description)
- %div
- :growstuff_markdown
- #{ planting.description }
-
- - if planting.finished
- %p
- Finished:
- - if planting.finished_at
- = planting.finished_at
- - else
- Yes (no date specified)
-
- - if can? :edit, planting or can? :destroy, planting
- %p
+.panel.panel-success.planting-thumbnail
+ .panel-heading
+ %h3.panel-title= link_to planting.crop.name, planting.crop
+ .panel-body
+ .row
+ .col-xs-12.col-md-4
+ = link_to image_tag((planting.default_photo ? planting.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => planting.crop_id, :class => 'img'), planting
+ .col-xs-7.col-md-5
+ %dl.dl-horizontal.planting-attributes
+ %dt Owner:
+ %dd= link_to planting.owner.login_name, planting.owner
+ %dt Garden:
+ %dd= link_to planting.garden.name, planting.garden
+ %dt Planted on:
+ %dd= planting.planted_at
+ %dt Quantity:
+ %dd= "#{display_planting_quantity(planting)}"
+ %dt Finished on:
+ %dd= "#{display_finished(planting)}"
+ %dt Sun/shade?:
+ %dd
+ - sunniness = planting.sunniness.blank? ? "not specified" : planting.sunniness
+ = image_tag("sunniness_#{sunniness}.png", :size => "25x25", :alt => "#{sunniness}", :title => "#{sunniness}")
+ = " (#{sunniness})"
+ %dt Planted from:
+ %dd= "#{display_planted_from(planting)}"
+ .col-xs-1.col-md-3
+ %ul{:style => "list-style-type:none; text-align:right"}
+ %li= link_to 'Details', planting, :class => 'btn btn-default btn-xs'
- if can? :edit, planting
- =link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs'
+ %li= link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs'
- if ! planting.finished
- = link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date'
+ %li= link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date'
- if can? :destroy, planting
- =link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
+ %li= link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
+
+ .row
+ .col-xs-12.col-md-4
+ %dl
+ %dt Days until maturity:
+ %dd= "#{display_days_before_maturity(planting)}"
+
+ .col-xs-12.col-md-8
+ = render partial: 'plantings/planting_progress', locals: {planting: planting}
diff --git a/app/views/plantings/index.html.haml b/app/views/plantings/index.html.haml
index 1d27df4e8..14c319a5b 100644
--- a/app/views/plantings/index.html.haml
+++ b/app/views/plantings/index.html.haml
@@ -1,4 +1,6 @@
-- content_for :title, @owner ? "#{@owner}'s plantings" : @crop ? "Everyone's #{@crop.name} plantings" : "Everyone's plantings"
+- content_for :title, @owner ? t('.title.owner_plantings', owner: @owner) : @crop ? t('.title.crop_plantings', crop: @crop.name) : t('.title.default')
+- if @owner
+ = link_to "View #{@owner}'s profile >>", member_path(@owner)
%p
- if can? :create, Planting
@@ -14,52 +16,19 @@
- else
= render :partial => 'shared/signin_signup', :locals => { :to => "track what you've planted" }
- %div.pagination
- = page_entries_info @plantings, :model => "plantings"
- = will_paginate @plantings
+%div.pagination
+ = page_entries_info @plantings
+ = will_paginate @plantings
-- if @plantings.length > 0
+.row
+ - if @plantings.size > 0
+ - @plantings.each.with_index do |planting|
+ .col-xs-12.col-lg-6
+ = render partial: "plantings/thumbnail", locals: {:planting => planting}
- %table.table.table-striped
- %tr
- - unless @owner
- %th Owner
- %th Crop
- %th Garden
- %th Quantity
- %th Planted on
- %th Finished
- %th Sun/shade?
- %th Planted from
- %th
-
- - @plantings.each do |planting|
- %tr
- - unless @owner
- %td= link_to planting.owner.login_name, planting.owner
- %td= link_to planting.crop.name, planting.crop
- %td= link_to planting.garden.name, planting.garden
- %td= planting.quantity
- %td= planting.planted_at
- %td
- - if planting.finished and planting.finished_at
- = planting.finished_at
- - elsif planting.finished
- Yes (no date specified)
- %td= planting.sunniness
- %td= planting.planted_from
- %td
- = link_to 'Details', planting, :class => 'btn btn-default btn-xs'
- - if can? :edit, planting
- =link_to 'Edit', edit_planting_path(planting), :class => 'btn btn-default btn-xs'
- - if ! planting.finished
- = link_to "Mark as finished", planting_path(planting, :planting => {:finished => 1}), :method => :put, :class => 'btn btn-default btn-xs append-date'
- - if can? :destroy, planting
- =link_to 'Delete', planting, method: :delete, data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
-
- %div.pagination
- = page_entries_info @plantings, :model => "plantings"
- = will_paginate @plantings
+%div.pagination
+ = page_entries_info @plantings
+ = will_paginate @plantings
%ul.list-inline
%li The data on this page is available in the following formats:
diff --git a/app/views/plantings/show.html.haml b/app/views/plantings/show.html.haml
index 72819f7ac..6ad55ff15 100644
--- a/app/views/plantings/show.html.haml
+++ b/app/views/plantings/show.html.haml
@@ -1,45 +1,55 @@
=content_for :title, "#{@planting.crop} in #{@planting.location}"
+- content_for :opengraph do
+ - @planting.crop.photos.each do |photo|
+ = tag("meta", property: "og:image", content: photo.fullsize_url)
+ = tag("meta", property: "og:title", content: "#{@planting.crop} in #{@planting.location}")
+ - if @planting.description
+ = tag("meta", property: "og:description", content: @planting.description)
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
-.row
+.row.planting
.col-md-6
- %p
- %b Owner:
- = link_to @planting.owner, @planting.owner
- —
- = link_to "view all #{@planting.owner}'s plantings", plantings_by_owner_path(:owner => @planting.owner.slug)
- %p
- %b Planted:
- = @planting.planted_at ? @planting.planted_at : "not specified"
+ %dl.dl-horizontal.planting-attributes
+ %dt Owner:
+ %dd
+ = link_to @planting.owner, @planting.owner
+ —
+ = link_to "view all #{@planting.owner}'s plantings", plantings_by_owner_path(:owner => @planting.owner.slug)
+
+ %dt Planted on:
+ %dd= @planting.planted_at ? @planting.planted_at : "not specified"
+
+ %dt Where:
+ %dd
+ =link_to "#{@planting.owner}'s", @planting.owner
+ =link_to @planting.garden, @planting.garden
+ - if ! @planting.owner.location.blank?
+ = "(#{@planting.owner.location})"
+
+ %dt Quantity:
+ %dd
+ ="#{display_planting_quantity(@planting)}"
+
+ - if !@planting.planted_from.blank?
+ %dt Planted from:
+ %dd= "#{display_planted_from(@planting)}"
+
+ %dt Sun or shade?
+ %dd
+ - sunniness = @planting.sunniness.blank? ? "not specified" : @planting.sunniness
+ = image_tag("sunniness_#{sunniness}.png", :size => "25x25", :alt => "#{sunniness}", :title => "#{sunniness}")
+ = " (#{sunniness})"
+
+ %dt Days until maturity:
+ %dd= "#{display_days_before_maturity(@planting)}"
+
+ %dt Finished:
+ %dd= "#{display_finished(@planting)}"
%p
- %b Where:
- =link_to "#{@planting.owner}'s", @planting.owner
- =link_to @planting.garden, @planting.garden
- - if ! @planting.owner.location.blank?
- = "(#{@planting.owner.location})"
- %p
- %b Quantity:
- = @planting.quantity.blank? ? "not specified" : @planting.quantity
-
- - if ! @planting.planted_from.blank?
- %p
- %b Planted from:
- = @planting.planted_from
-
- - if ! @planting.sunniness.blank?
- %p
- %b Sun or shade?
- = @planting.sunniness
-
- - if @planting.finished
- %p
- %b Finished:
- - if @planting.finished_at
- = @planting.finished_at
- - else
- Yes (no date specified)
-
-
+ = render 'planting_progress', planting: @planting
- if can? :edit, @planting or can? :destroy, @planting
%p
@@ -52,13 +62,18 @@
.col-md-6
= render :partial => "crops/index_card", :locals => { :crop => @planting.crop}
+ - if @planting.owner.location
+ %p
+ %small
+ View other plantings, members and more near
+ = link_to @planting.owner.location, place_path(@planting.owner.location, anchor: "plantings")
+- if @planting.description
+ %h2 Notes
-%h2 Notes
+ :growstuff_markdown
+ #{ @planting.description != "" ? @planting.description : "No description given." }
-:growstuff_markdown
- #{ @planting.description != "" ? @planting.description : "No description given." }
-
-- if @planting.photos.count > 0 or (can? :edit, @planting and can? :create, Photo)
+- if @planting.photos.size > 0 or (can? :edit, @planting and can? :create, Photo)
%h2 Pictures
.row
diff --git a/app/views/policy/api.html.haml b/app/views/policy/api.html.haml
deleted file mode 100644
index 4dc0bbdd8..000000000
--- a/app/views/policy/api.html.haml
+++ /dev/null
@@ -1,45 +0,0 @@
--content_for :title, 'API and Data Use Policy'
-
-:markdown
- We hate legalese, so we've tried to make this policy readable. If you've got any questions, feel free to [ask us](mailto:support@growstuff.org), and we'll do our best to answer.
-
- This API and Data Use Policy covers all websites (such as [growstuff.org](http://growstuff.org)) owned and operated by Growstuff Pty Ltd ("Growstuff", "we", "us", "our") and all associated services, collectively referred to as the Service.
-
- In particular, this policy covers any access to the Service via any Application Programming Interface, feeds, spidering, scraping, or any other automated or programmatic access to the Structured Data or Content available via the Service (collectively, the "API"). This policy applies to anyone who uses the API ("you", "developer").
-
- ## 1. API Provided As-Is, and Subject to Change
-
- Growstuff provides its API on an as-is basis, as described under "Disclaimer of Warranties" in our [Terms of Service](http://growstuff.org/policy/tos).
-
- Growstuff's API is subject to change. We will make reasonable efforts to notify developers of changes and of the release status of any API features. You should take reasonable efforts to keep up with Growstuff technical news via our forums, mailing lists, or other channels.
-
- ## 2. Don't overload our servers
-
- You agree to limit your access to the API in such a way as to prevent excessive load on the Service. Growstuff reserves the right to restrict or rate-limit access to the API if necessary to maintain the performance of the Service.
-
- ## 3. Use of Growstuff Data and Content
-
- You agree to observe the terms of the [Creative Commons Attribution-ShareAlike (CC-BY-SA) 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/deed.en_US) under which our Structured Data is made available. You agree to to observe the copyright and intellectual property rights of Growstuff's members with regard to their Content posted on the Service, including but not limited to posts, comments, images, etc.
-
- You agree to respect any privacy settings which pertain to the Structured Data or Content you access via the API. You agree not to republish any Structured Data or Content with more permissive access than was originally intended by the member who posted it.
-
- Growstuff acknowledges that Structured Data and Content made available under the API may be cached or retained by third parties for any length of time. However, we request that if you are building an application using current Structured Data and Content, you will take reasonable efforts to regularly update it, including removing any Structured Data or Content that is deleted from the Service, and reflecting any changes in privacy settings that pertain to it.
-
- ## 4. Authentication
-
- Growstuff reserves the right to require authentication and/or app registration as a condition of use of the API and Data.
-
- If you provide users with the ability to login to Growstuff, you must do so via OAuth. You may not require users to provide their Growstuff login name and password.
-
- ## 5. Penalties
-
- If you violate the terms of this Policy, Growstuff may restrict your access to the API.
-
- ## 6. Changes
-
- We may change our API and Data Use Policy from time to time. A history of changes to this Policy is available via our public source code repository at [https://github.com/Growstuff/policy](https://github.com/Growstuff/policy). We will take reasonable steps to notify you of any substantial changes to this Policy; however, it is your responsibility to check this Policy periodically for changes. Your continued use of this site after any change in this Privacy Policy will constitute your acceptance of such change.
-
- ## 7. Creative Commons License
-
- This API and Data Use Policy is licensed under a [Creative Commons Attribution-ShareAlike (CC-BY-SA) 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/deed.en_US).
-
diff --git a/app/views/policy/community.html.haml b/app/views/policy/community.html.haml
deleted file mode 100644
index c6c0c8f49..000000000
--- a/app/views/policy/community.html.haml
+++ /dev/null
@@ -1,31 +0,0 @@
--content_for :title, 'Growstuff Community Guidelines'
-
-:markdown
- Growstuff is a community by and for food-gardeners. Together, we are building a website where we can share our experience, knowledge, and the products of our harvest. The most important thing about Growstuff is the people. For Growstuff to thrive, we need people to add their crops, share their knowledge, and help build the site itself.
-
- Whatever your interest in Growstuff you are welcome here, and will be treated with respect. In particular:
-
- - We welcome people of any age, gender identity or expression, ethnicity, nationality, religion or absence thereof, political opinion, sexual orientation, marital status, family structure, ability or disability, appearance, subculture, or other identity or self-identification.
-
- - Although Growstuff is primarily focused on food gardening, we welcome all kinds of gardeners, including organic and conventional growers; those who grow their crops in fields or on balconies or in hydroponic systems; those who garden commercially or non-commercially; those who subsist on their crops and those who garden for other reasons.
-
- - We welcome people of all skill and experience levels, and we don't believe in being dismissive or commenting rudely just because you are new or learning.
-
- - Every role in our community is important, including gardeners who contribute skills, knowledge, and information to our site; coders, designers and other techies who help build it; moderators and others who help our community thrive; or any other form of participation. We believe in working together, and prioritise communication and mutual understanding.
-
- If you want to participate in the Growstuff community (which includes our website and any auxiliary forums such as our mailing list(s), IRC channel, etc), you need to agree to our general commitment to inclusiveness and mutual respect, as well as to the following specific policies:
-
- - Harassment of any Growstuff community member is forbidden. Harassment includes slurs directed at individuals or groups; unwanted sexual remarks directed at any person or group; sexually explicit comments or imagery in public spaces; stalking or other repeated, unwanted contact; or any repeated or sustained behaviour which disrupts someone else's enjoyment of the Growstuff site or community.
-
- - The privacy of our community members is very important. You may not disclose any member's personal details (including names by which they are known outside of Growstuff, their location, employment details, family details, outside-of-Growstuff contact details, or any other identifying or personal information) without their explicit consent.
-
- - Although we let you choose your own name on our site, and don't insist that you use the same name on our website as you have on the cards in your wallet, you're not allowed to create or use a pseudonymous account to mislead people, evade accountability, or otherwise cause trouble. (This is commonly known as a "sockpuppet" account.)
-
- If you experience or witness behaviour that goes against these community guidelines, you can report it to support@growstuff.org. We will listen carefully and take your report seriously. Once we've looked into the situation, we may take any action we deem necessary. For instance, we may issue a warning, or in serious cases we may suspend or ban people from our community. If this happens, we will always tell the person affected the reason for our action, with reference to our policy documents.
-
- We don't want to make these guidelines too long or legalistic, so we'll leave it there, except for one final guideline. As Bill and Ted said: *be excellent to each other*. And grow stuff.
-
- ## Creative Commons License
-
- These Community Guidelines are licensed under a [Creative Commons Attribution-ShareAlike (CC-BY-SA) 3.0 Unported License](http://creativecommons.org/licenses/by-sa/3.0/deed.en_US).
-
diff --git a/app/views/policy/copyright.html.haml b/app/views/policy/copyright.html.haml
deleted file mode 100644
index 9f947f373..000000000
--- a/app/views/policy/copyright.html.haml
+++ /dev/null
@@ -1,91 +0,0 @@
--content_for :title, 'Copyright Infringement Policy'
-
-:markdown
- We hate legalese, so we've tried to make this policy readable. If you've got any questions, feel free to [ask us](mailto:support@growstuff.org), and we'll do our best to answer.
-
- This Copyright Infringement Policy covers all websites (such as [growstuff.org](http://growstuff.org)) owned and operated by Growstuff Pty Ltd ("Growstuff", "we", "us", "our") and all associated services, collectively referred to as "the Service". It describes how you may report a violation of copyright on the Service.
-
- Growstuff respects the intellectual property of others, and we ask our users to do the same. Growstuff members are required by the [Terms of Service](http://growstuff.org/policy/tos) to ensure that they have the legal right to post content to the Service.
-
- Growstuff is based in Melbourne, Australia and is not subject to the provisions of the United States Digital Millennium Copyright Act (DMCA). However, we have established policy and procedures which are similar to those required by the DMCA, as we believe they constitute best practice for web services operating in Australia.
-
- ## 1. Notifying us of an infringement
-
- If you believe that a Growstuff member has infringed your intellectual property rights by posting Content to the service, you may follow these steps to notify us and ask for the removal of the Content.
-
- Notifications may be submitted by email to [support@growstuff.org](mailto:support@growstuff.org) or by physical mail to:
-
- Growstuff
- Level 3, 673 Bourke Street
- Melbourne VIC 3000
- AUSTRALIA
-
- We prefer to receive notifications by email.
-
- Copyright infringement notifications sent through any other mechanism or forum will not be acted upon.
-
- You must provide the following information:
-
- * Sufficient information to identify the copyrighted work being infringed. For instance, if the work is a published book, provide the title, author, and ISBN; if the work is a magazine article, provide the title, author, magazine name, and magazine issue; if the work is available on the Internet, provide the URL of the work.
- * The URL of the specific page on Growstuff where your work was reproduced without permission. General descriptions or non-specific links (such as to Growstuff's homepage) cannot be acted upon.
- * Your postal address, telephone number, and email address.
- * A statement by you that the above information is accurate and that you are the copyright or intellectual property owner or authorized to act on the copyright or intellectual property owner's behalf.
- * A physical signature or digital signature in a recognized industry-standard format such as PGP, of the copyright or intellectual property owner or the person authorized to act on their behalf. Unsigned notifications will not be processed.
-
- ## 2. Responding to notifications
-
- We will respond to copyright infringement notifications within two business days.
-
- If we are not provided with enough information to act on the notification, including all the items listed in the section above, we will reject the notification and notify the submitter that it cannot be acted upon.
-
- If the Content is not hosted on our servers (for instance, if the notification concerns an image hosted on another site which is merely displayed on or linked from our site) we will respond, notifying the submitter that the Content is not hosted by us and referring them to the hosting site.
-
- Provided we are able to act upon the notification, we will contact the member who posted the Content and inform them of the notification and claim of intellectual property rights.
-
- The member will have two business days to respond. They may respond as follows:
-
- * Admit that they have posted something to which they do not hold intellectual property rights. In this case, the member may delete the Content from the Service, or we may render it inaccessible.
- * Submit a counter-notification, stating that they have the right to post the Content, and that they are prepared to uphold this claim in court. The process for this is outlined below.
- * Respond saying that they do not believe they have infringed any intellectual property rights, but that they do not wish to formally submit a counter-notification. In this case, the member may delete the Content from the Service, or we may render the Content inaccessible.
- * If the member fails to respond, we will render the Content inaccessible.
-
- When Content is deleted or rendered inaccessible, we will take reasonable efforts to ensure it cannot be accessed via the Service. However, caching or external references may mean that Content remains accessible for some time, including on third-party sites or applications. Third party sites and applications are not under Growstuff's control. If infringing Content has been removed or rendered inaccessible via the Service but is still available via third-party sites and applications, the copyright or intellectual property holder may contact the operators of those sites/applications to notify them of the infringement.
-
- ## 3. Counter-notification and restoration process
-
- A counter-notification is a statement that you do not believe your content infringes on another person's rights, or that your use of another person's copyrighted material falls into a protected category under law.
-
- By filing a counter-notification, you are indicating that you are willing to defend your use of the material in court, if the copyright owner chooses to bring a lawsuit against you for your use of the material. This may involve civil and/or criminal penalties. We strongly suggest you contact an intellectual property lawyer licensed to practice law in your jurisdiction before you do this, so that you are aware of your rights and obligations under the law.
-
- A counter-notification must contain the following items:
-
- * Your signature. Signatures may be a physical signature or a digital signature in a recognized industry-standard format such as PGP.
- * The URL of the Content that has been called into question (this will have been provided in the original notification).
- * A statement that you have a good faith belief that the copyright infringement notification was sent as a result of mistake or misidentification of the material. This should include any reasons why you believe your use of the material is not infringing.
- * Your name, address, and telephone number.
-
- We will forward your counter-notification, in full, to the submitter of the original notification. They will then have 14 days to initiate legal action and notify us that they have done so.
-
- In the meantime, we will render the Content inaccessible.
-
- If, after 14 days, we have not been informed that legal proceedings have been initiated, we will restore the Content.
-
- If you have filed a counter-notification, you may not re-post the allegedly-infringing material until we notify you that the waiting period has expired.
-
- ## 4. Repeat offenses
-
- Members who receive three or more valid copyright infringement notices will have their accounts terminated.
-
- If a counter-notification is filed, or if the member has stated that they do not accept the allegation of copyright infringement but do not wish to formally file a counter-notification, the notification will not be counted toward termination.
-
- We also reserve the right to terminate the accounts of those who, in our opinion, misuse or abuse the copyright infringement notification process against other members.
-
- ## 5. Changes
-
- We may change our Copyright Infringement Policy from time to time. A history of changes to this Policy is available via our public source code repository at [https://github.com/Growstuff/policy](https://github.com/Growstuff/policy). We will take reasonable steps to notify you of any substantial changes to this Policy; however, it is your responsibility to check this Policy periodically for changes. Your continued use of this site after any change in this Privacy Policy will constitute your acceptance of such change.
-
- ## 6. Creative Commons license
-
- This Terms of Service document is based on one developed by Dreamwidth ([http://www.dreamwidth.org/legal/dmca](http://www.dreamwidth.org/legal/dmca)) and is licensed under a [Creative Commons Attribution-ShareAlike 2.5 License](http://creativecommons.org/licenses/by-sa/2.5/).
-
-
diff --git a/app/views/policy/privacy.html.haml b/app/views/policy/privacy.html.haml
deleted file mode 100644
index 3a2fc2f5c..000000000
--- a/app/views/policy/privacy.html.haml
+++ /dev/null
@@ -1,107 +0,0 @@
--content_for :title, 'Privacy Policy'
-
-:markdown
- We hate legalese, so we've tried to make this policy readable. If you've got any questions, feel free to [ask us](mailto:support@growstuff.org), and we'll do our best to answer.
-
- This privacy statement ("Privacy Policy") covers all websites (such as [growstuff.org](http://growstuff.org/)) owned and operated by Growstuff Pty Ltd ("Growstuff", "we", "us", "our") and all associated services, collectively referred to as "the Service".
-
- We use information you share with us for our internal business purposes. We do not sell your information. This notice tells you what information we collect, how we use it, and steps we take to protect and secure it.
-
- ## 1. Information we collect
-
- ### 1.1 Non-Personal Data
-
- Like most website operators, we collect Non-Personal Data such as browser type, language preference, referring site, and the date and time of each visitor request.
-
- We collect this to understand how our visitors and members use our service, and use it to make decisions about how to change and adapt the service.
-
- From time to time, we may release Non-Personal Data in aggregate form (for instance, by publishing trends in site usage) to explain our reasoning in making decisions. We will not release individual information, only aggregate information.
-
- ### 1.2 Personal Data
-
- Personal Data is anything which can be used to identify or contact you, such as your legal name, email address, IP address, or physical location.
-
- #### 1.2.1 Automatically collected Personal Data
-
- We automatically collect some Personal Data, such as IP address, provided by your browser and your computer whenever you visit our website.
-
- We collect this information for several purposes:
-
- * To diagnose and repair network issues with your use of the site;
- * To estimate the number of users accessing the service from specific geographic regions;
- * To help prevent fraud and abuse.
-
- #### 1.2.2 Email address
-
- In order to register for the service, you must give us your email address. We will use your email address to send confirmation of certain actions, such as when you change your password. We will contact you when it's necessary to complete a transaction that you've initiated, or if there's a critical or administrative issue affecting your use of the service.
-
- Once you have created your account, you can choose to subscribe to certain events and have notifications of those events sent to you via email. You will be able to change your mind and opt out of receiving notifications via email at any time.
-
- We will never sell or provide your email address to any third party for marketing purposes, or for any other reason except as set out below.
-
- #### 1.2.3 Optional Personal Data you provide to us
-
- As you use the service, you have the option to provide more Personal Data, through your profile and other activity on the site. Providing this information is strictly optional.
-
- You have the option to provide us with your location. You may provide this at whatever level of detail you wish, for instance you may provide your street address or your country of residence or nothing at all. We use this location to provide you with relevant content.
-
- Many of your activities on the Service may allow you to post Personal Data or to directly or indirectly disclose Personal Data about yourself. For instance, you may disclose Personal Data in a post or comment on the site, by uploading a picture, by linking to another website you use, or by recording your gardening activity in detail. All of these activities are optional. You should use due caution when disclosing Personal Data through your activity on the Service.
-
- We will show the information you provide, including any Personal Data it may contain, to others viewing the site, in accordance with the privacy options you've selected.
-
- The information you provide is also made available to third parties via our API and feeds, in accordance with the privacy options you've selected and subject to the terms of our API and Data Use Policy which is available at [http://growstuff.org/policy/api](http://growstuff.org/policy/api).
-
- Some of the information you provide is categorised as Structured Data, which is defined more fully in our [Terms of Service]([http://growstuff.org/policy/tos). We make Structured Data freely available under a Creative Commons Attribution ShareAlike (CC-BY-SA) 3.0 Unported license for use by third parties, in accordance with the privacy options you've selected.
-
- We may also use any Personal Data you provide, in aggregate, to make decisions about how to change and adapt the service. From time to time, we may release information in aggregate form (for instance, by publishing trends in site usage) to explain our reasoning in making decisions. We will not release individual information, only aggregate information.
-
- #### 1.2.4 Financial information and transactions
-
- You can engage in financial transactions with Growstuff to purchase a paid account. These transactions are optional. If you choose to purchase a paid account, you will be asked to provide financial information to complete the transaction.
-
- Credit cards: If you pay by credit card, we need you to provide your credit card number, your full name as it appears on the card, your address as it appears on the card statement, and the CVN or Card Verification Number. This information is required so we can authorize and charge your credit card. Your financial information is protected by industry-standard encryption methods. It is never stored on our servers: we pass it immediately along to our processor for the sole purpose of completing the authorized transaction.
-
- In all cases, Growstuff collects this personal and financial information only as necessary or appropriate for the completion of the single requested transaction. Any additional non-financial Personal Data you disclose during these transactions will be governed by the "Disclosure of Personal Data" provisions below.
-
- ## 2. Disclosure of Personal Data
-
- We disclose Personal Data, including optional personal information you have provided but which is not normally available to other site users, only to those of our employees, contractors, and volunteers who (i) need to know that information in order to operate the service and (ii) have agreed not to disclose it to others. Circumstances in which this is necessary include, but are not limited to: troubleshooting and diagnosing technical problems, investigating possible Terms of Service violations, and legal compliance issues.
-
- We contract with third-party vendors to provide some site features. We will only share personal information with third-party vendors to the extent that is necessary for them to provide these site features. We require our third-party vendors to provide the same level of privacy protection that we do, and they do not have the right to share or use personal information for any purpose other than for an authorized transaction.
-
- We may disclose Personal Data or potentially personally-identifying data when that release is required by law or by court order, or when we believe in good faith that disclosure is reasonably necessary to protect the safety or rights of us, third parties, or the public at large.
-
- We reserve the right to transfer your Personal Data to a third party in the event of a sale, merger, liquidation, receivership or transfer of all or substantially all of the assets of our company provided that the third party agrees to adhere to the terms of the Growstuff Privacy Policy and provided that the third party only uses your Personal Data for the purposes that you provided it to us. You will be notified in the event of any such transfer and you will be afforded an opportunity to opt-out.
-
- ## 3. Cookies
-
- A cookie is a string of information that a website stores on a visitor's computer, and that the visitor's browser provides to the website each time the visitor returns. We use cookies to help us identify and track visitors, their usage of the website, and their website access preferences. We also use cookies to govern logging into your account.
-
- Visitors who do not wish to have cookies placed on their computers should set their browsers to refuse cookies before using the site, with the drawback that certain features of the site may not function properly without the aid of cookies.
-
- ## 4. Confidentiality and security
-
- No data transmisson over the Internet can ever be guaranteed to be 100% secure. You use this service at your own risk. However, we will take all reasonable steps (including appropriate technical and organisational measures) to protect your Personal Data.
-
- Your account information is password-protected. We recommend that you choose a strong and secure password. We use industry-standard encryption to protect your password on our servers.
-
- If we learn of a system security breach, we will notify you electronically so you can take appropriate steps to protect yourself.
-
- ## 5. Deleting your information
-
- You can change or delete any optional information that you've provided us at any time. If you change or delete any optional information you've provided, the change will take place immediately on the Service. However, caching or references to the data, including in third party applications based on the Service, may mean that formerly available data remains available for some time.
-
- As part of the day to day operation of the Service, we will make regular copies of the data contained in the databases for backup purposes. These backups can potentially contain deleted data for several weeks or months. These backups will also be governed by the rules for Disclosure of Personal Data.
-
- ## 6. Changes
-
- We may change our Privacy Policy from time to time. A history of changes to this Policy is available via our public source code repository at [https://github.com/Growstuff/policy](https://github.com/Growstuff/policy). We will take reasonable steps to notify you of any substantial changes to this Policy; however, it is your responsibility to check this Policy periodically for changes. Your continued use of this site after any change in this Privacy Policy will constitute your acceptance of such change.
-
- ## 7. Contacting us
-
- If you have questions about this policy, you can contact us at [support@growstuff.org](mailto:support@growstuff.org).
-
- ## 8. Creative Commons
-
- This privacy policy is based on one developed by Automattic ([http://automattic.com/privacy/](http://automattic.com/privacy/)) and amended by Dreamwidth ([http://dreamwidth.org/legal/privacy](http://dreamwidth.org/legal/privacy)) and is licensed under a [Creative Commons Attribution-ShareAlike 2.5 License](http://creativecommons.org/licenses/by-sa/2.5/).
-
diff --git a/app/views/policy/tos.html.haml b/app/views/policy/tos.html.haml
deleted file mode 100644
index 2cae2f57a..000000000
--- a/app/views/policy/tos.html.haml
+++ /dev/null
@@ -1,156 +0,0 @@
--content_for :title, 'Growstuff Terms of Service'
-
-:markdown
- We hate legalese, so we've tried to make our Terms of Service readable. If you've got any questions, feel free to [ask us](mailto:support@growstuff.org), and we'll do our best to answer.
-
- Growstuff Pty Ltd ("we", "us", "our", "Growstuff") present the following terms and conditions, which govern your use of the Growstuff website at [growstuff.org](http://growstuff.org), and all content, services and products available at or through the website, which we collectively refer to as "the Service".
-
- To use the Service, you need to agree to these Terms of Service, along with all other policies we publish (including, but not limited to, Growstuff's Privacy Policy, API and Data Use Policy, Copyright Infringement Policy and Community Guidelines). We refer to this as "the Agreement".
-
- Please read this Agreement carefully before accessing or using the Service. By accessing or using any part of the Service, you agree that you are bound by the terms and conditions of this Agreement. If you do not agree to all the terms and conditions of this Agreement, then you may not access the Service.
-
- ## 1. Your Account
-
- If you create an account on the Service, you are responsible for maintaining the security of your account. You are responsible for all activities that occur under the account. You must take reasonable steps to guard the security of your account. We will not be liable for anything that happens if your account security is breached as a result of your failure to protect it.
-
- ## 2. Account Structure
-
- Growstuff currently has three types of accounts:
-
- * Free Accounts are available free of charge. Free accounts can access basic site functions, but do not receive access to premium features.
- * Paid Accounts are available for term-based fee and receive access to a number of premium features. When your Paid Account expires, it will revert to a Free Account until you pay for it again.
- * Permanent Accounts are reserved for those who have contributed significantly to the Growstuff project, at our discretion. They receive all features available to paid accounts, for as long as Growstuff continues to operate, without need for future payment.
-
- Payments to Growstuff, for account services or for any other purpose, are refundable or transferable solely at Growstuff's discretion.
-
- By using this Service, you agree to this account structure, and to Growstuff's right to change, modify, or discontinue any type of account or the features available to it at any time.
-
- ## 3. Content policy
-
- Our content policy relates to any material you may post on the Growstuff website or through the Service, which we call "Content". This includes profile information, posts and comments, information about your food growing activity, and any other material, whether text, graphics, or any other format, which you may post on Growstuff itself or link to from Growstuff.
-
- All Content posted to the Service in any way is the responsibility of the owner. If Content is deemed illegal by any law having jurisdiction over you, you agree that we may submit any necessary information to the proper authorities.
-
- We claim no ownership or control over any Content that you post to the Service. You retain any intellectual property rights to the Content you post, in accordance with applicable law. By posting Content, you represent that you have the rights to reproduce that Content (and the right to allow us to serve such Content) without violation of the rights of any third party. You agree that you will bear any liability resulting from the posting of any Content that you do not have the rights to post.
-
- You grant us a world-wide, royalty-free, and non-exclusive license to reproduce, modify, adapt and publish the Content, solely for the purpose of displaying, distributing and promoting the contents of your account, through any part of the Service including through our API, feeds, and external clients.
-
- If you delete Content, we will use reasonable efforts to remove it from the Service, but you acknowledge that caching or references to the Content may not be made immediately unavailable.
-
- ### 3.1 Structured Data
-
- There is a subset of Content which we refer to as "Structured Data". Structured Data is Content which represents simple facts, rather than creative effort. For instance, locations, dates, or the type and number of crops you have planted are Structured Data. Structured Data may be created explicitly by you or implicitly by the Website in response to your activity.
-
- By using the Service, you acknowledge that Structured Data will be gathered and stored by Growstuff, and that any Structured Data pertaining to you or your activity may be made available for use by third parties under a Creative Commons Attribution ShareAlike (CC-BY-SA) license. You also agree that attribution for the Structured Data under the terms of the Creative Commons license will be given to Growstuff.
-
- ### 3.2 Content Posted on Other Websites
-
- We have not reviewed, and cannot review, all of the material, including computer software, made available through the websites and webpages to which we, any user, or any provider of Content links, or that link to us. We do not have any control over those websites and webpages, and are not responsible for their contents or their use. By linking to an external website or webpage, we do not represent or imply that we endorse such website or webpage. You are responsible for taking precautions as necessary to protect yourself and your computer systems from viruses, worms, Trojan horses, and other harmful or destructive content. We disclaim any responsibility for any harm resulting from your use of external websites and webpages, whether that link is provided by us or by any provider of Content on the Service.
-
- ### 3.3 How we deal with problem Content
-
- You agree that by using the Service, you may be exposed to Content you find offensive or objectionable.
-
- We do not pre-screen Content. However, you acknowledge that we have the right (but not the obligation), in our sole discretion, to remove or refuse to remove any Content from the Service. If such Content is reported to us, it will be our sole discretion as to what action, if any, should be taken.
-
- If any Content you have submitted is reported to us as violating this Agreement, you agree that we may call upon you to change, modify, or remove that Content, within a reasonable amount of time, as defined by us. If you do not follow this directive, we may terminate your account.
-
- ## 4. Member Conduct
-
- You agree that you will not use the Service to:
-
- 1. Upload, post, or otherwise transmit any Content that is harmful, threatening, abusive, hateful, invasive to the privacy and publicity rights of any person, or that violates any applicable local, state, national, or international law, including any regulation having the force of law;
- 1. Upload, post, or otherwise transmit any Content that is spam, or contains unethical or unwanted commercial content designed to drive traffic to third party sites or boost the search engine rankings of third party sites, or to further unlawful acts (such as phishing) or mislead recipients as to the source of the material (such as spoofing);
- 1. Maliciously impersonate any real person or entity, including but not limited to a Growstuff staff member or volunteer, or to otherwise misrepresent your affiliation with any person or entity;
- 1. Upload, post or otherwise transmit any Content that you do not have a right to transmit under any law or under contractual or fiduciary relationships (such as inside information, proprietary and confidential information learned or disclosed as part of employment relationships or under nondisclosure agreements);
- 1. Upload, post or otherwise transmit any Content that infringes any patent, trademark, trade secret, copyright, or other proprietary rights of any party;
- 1. Interfere with or disrupt the Service or servers or networks connected to the Service, or disobey any requirements, procedures, policies or regulations of networks connected to the Service;
- 1. Solicit passwords or personal identifying information for unintended, commercial or unlawful purposes from other users;
- 1. Upload, post or otherwise transmit any Content that contains viruses, worms, malware, Trojan horses or other harmful or destructive content;
- 1. Allow usage by others in such a way as to violate this Agreement;
- 1. Make excessive or otherwise harmful automated use of the Service;
- 1. Access any other person's account, or exceed the scope of the Service that you have signed up for; for example, accessing and using features you don't have a right to use.
-
- You agree that you will abide by the Community Guidelines, which are currently available at [http://growstuff.org/policy/community](http://growstuff.org/policy/community).
-
- ## 5. Volunteers
-
- We appreciate the service of volunteers in many aspects of Growstuff's operations. Volunteer activities include but are not limited to developing software, providing technical support, writing documentation, performing site administration duties, providing expert advice, research, technical writing, reviewing, categorizing, and other duties as necessary to support the operation of the Service.
-
- All volunteers are expected to be of legal age, or volunteering with the consent of a legal parent or guardian.
-
- By volunteering, you agree that any work created as a result of your volunteer activities shall be licensed to Growstuff on a perpetual, irrevocable, and world-wide basis, to the extent permitted by law. You agree that Growstuff may determine the basis upon which your volunteer work shall be licensed to others, including under Open Source or Creative Commons licenses that may permit the further alteration or dissemination of your work. If laws prevent such licensing, you agree never to sue Growstuff for the use of said work.
-
- By volunteering, you agree that you are providing your work with no expectation of pay or future consideration by Growstuff. You also agree that you have taken reasonable diligence to ensure that the work is correct, accurate, and free of defect. You agree that you will not disclose or share any proprietary or confidential information you are provided with in the course of your volunteer work.
-
- No user is required to volunteer, and users who do not volunteer will receive equal care, support, and attention.
-
- ## 6. Privacy Policy
-
- Your use of the Website is governed by the Privacy Policy, currently located at [http://growstuff.org/policy/privacy](http://growstuff.org/policy/privacy).
-
- ## 7. API and Data Use Policy
-
- Your use of our API and/or data is governed by our API and Data Use Policy, currently located at [http://growstuff.org/policy/api](http://growstuff.org/policy/api).
-
- ## 8. Copyright Infringement
-
- If you believe that material located on the Website violates your copyright, you may notify us in accordance with our Copyright Policy, currently located at [http://growstuff.org/policy/copyright](http://growstuff.org/policy/copyright).
-
- ## 9. Resale of Services
-
- You agree not to reproduce, duplicate, copy, sell, resell, or exploit any portion of the Service, use of the Service, or access to the Service, except as is permitted under our API and Data Use Policy, open source license pertaining to the Service's source code, or Creative Commons licenses pertaining to Content or other material posted on the Service.
-
- ## 10. Indemnity
-
- You agree to indemnify and hold harmless Growstuff Pty Ltd, its contractors, its licensors, and their respective directors, officers, employees and agents from and against any and all claims and expenses, including attorneys' fees, arising out of your use of the Service, including but not limited to out of your violation of this Agreement.
-
- ## 11. Termination
-
- Growstuff may terminate your account or otherwise restrict your use of the Service at any time if we believe you have violated this Agreement. If this occurs, you will be notified by email, and we will tell you which part of the Agreement we believe you violated. We may, at our discretion, choose to issue a warning rather than terminate your account, in which case you will also be notified by email and told which part of the Agreement we believe you violated. We will also provide you with a contact address where you may appeal our decision, however, we do not guarantee that we will change our minds.
-
- You agree that any termination of your access to the Service may involve removing or discarding any content you have provided.
-
- Paid accounts that are terminated for violations of this Agreement will only be refunded at our discretion, and only if such termination should come under our established criteria for issuing refunds.
-
- We may, at our sole discretion, discontinue providing the Service at any time, with or without notice.
-
- If you wish to terminate this Agreement, you may delete your account and cease using the Service. You agree that, upon deletion of your account, we may, but are not required to, remove any Content you have provided, at any time past the deletion of your account.
-
- All provisions of this Agreement which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability.
-
- ## 12. Changes
-
- We reserve the right, at our sole discretion, to modify or replace any part of this Agreement at any time. A history of changes to this Agreement is available via our public source code repository at [https://github.com/Growstuff/policy](https://github.com/Growstuff/policy). We will take reasonable steps to notify you of any substantial changes to this Agreement; however, it is your responsibility to check this Agreement periodically for changes. Your continued use of the Service following the posting of any changes to this Agreement constitutes acceptance of those changes.
-
- We may also, in the future, offer new features or services through the Service. Such new features and/or services shall be subject to the terms and conditions of this Agreement.
-
- ## 13. Disclaimer of Warranties
-
- This Service is provided "as is". Growstuff Pty Ltd and its suppliers and licensors hereby disclaim all warranties of any kind, express or implied, including, without limitation, the warranties of merchantability, fitness for a particular purpose and non-infringement. Neither Growstuff Pty Ltd nor its suppliers and licensors, makes any warranty that the Service will be error free or that access to the Service will be continuous or uninterrupted. You agree that any interruptions to the service will not qualify for reimbursement or compensation. You understand that you download from, or otherwise obtain content or services through, the Service at your own discretion and risk.
-
- No advice or information, whether oral or written, obtained by you in any fashion shall create any warranty not expressly stated in this Agreement.
-
- ## 14. Limitation of Liability
-
- You expressly understand and agree that in no event will Growstuff Pty Ltd or its suppliers or licensors, be liable with respect to any subject matter of this agreement under any contract, negligence, strict liability or other legal or equitable theory for: (i) any special, incidental or consequential damages; (ii) the cost of procurement or substitute products or services; (iii) interruption of use or loss or corruption of data; (iv) any statements or conduct of any third party on the service; or (v) any unauthorized access to or alterations of your Content. We shall have no liability for any failure or delay due to matters beyond our reasonable control.
-
- The foregoing shall not apply to the extent prohibited by applicable law.
-
- ## 15. General Information
-
- This Agreement constitutes the entire agreement between us and you concerning your use of the Service. This Agreement may only be modified by a written amendment signed by an authorized representative of Growstuff Pty Ltd, or by the posting of a revised version to this location. Except to the extent that applicable law (if any) provides otherwise, any dispute arising between you and Growstuff Pty Ltd regarding these Terms of Service and/or your use or access of the Service will be governed by the laws of the state of Victoria and the federal laws of Australia, excluding any conflict of law provisions. You agree to submit to the jurisdiction of the state and federal courts located in Melbourne, Australia for any disputes arising out of or relating to your use of the Service or your acceptance of this Agreement.
-
- If any part of this Agreement is held invalid or unenforceable, that part will be construed to reflect the parties' original intent, and the remaining portions will remain in full force and effect. A waiver by either party of any term or condition of this Agreement or any breach thereof, in any one instance, will not waive such term or condition or any subsequent breach thereof.
-
- The section titles in this Agreement are for convenience only and have no legal or contractual effect.
-
- ## 16. Reporting Violations
-
- To report a violation of this agreement, please email [support@growstuff.org](support@growstuff.org).
-
- ## 17. Creative Commons
-
- This Terms of Service document is based on one developed by Automattic ([http://wordpress.com/tos/](http://wordpress.com/tos/)) with amendments by Dreamwidth ([http://www.dreamwidth.org/legal/tos](http://www.dreamwidth.org/legal/tos)) and is licensed under a [Creative Commons Attribution-ShareAlike 2.5 License](http://creativecommons.org/licenses/by-sa/2.5/).
-
-
diff --git a/app/views/posts/_comments.html.haml b/app/views/posts/_comments.html.haml
index bf565debc..78375ab00 100644
--- a/app/views/posts/_comments.html.haml
+++ b/app/views/posts/_comments.html.haml
@@ -1,7 +1,7 @@
%a{:name => "comments"}
- if post.comments
%h2
- =pluralize(post.comments.length, "comment")
+ =pluralize(post.comments.size, "comment")
- post.comments.post_order.each do |c|
= render :partial => "comments/single", :locals => { :comment => c }
diff --git a/app/views/posts/_form.html.haml b/app/views/posts/_form.html.haml
index 3ae4e5172..607b76bd8 100644
--- a/app/views/posts/_form.html.haml
+++ b/app/views/posts/_form.html.haml
@@ -1,14 +1,14 @@
= form_for(@post, :html => {:role => "form"}) do |f|
- if @post.errors.any?
#error_explanation
- %h2= "#{pluralize(@post.errors.count, "error")} prohibited this post from being saved:"
+ %h2= "#{pluralize(@post.errors.size, "error")} prohibited this post from being saved:"
%ul
- @post.errors.full_messages.each do |msg|
%li= msg
.form-group
= label_tag :post, "Subject", :class => 'control-label'
- = f.text_field :subject, :class => 'form-control'
+ = f.text_field :subject, :class => 'form-control', :autofocus => 'autofocus', :maxlength => 255
.form-group
- if @post.forum || @forum
diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml
index 27ec7aefe..e791123b9 100644
--- a/app/views/posts/_single.html.haml
+++ b/app/views/posts/_single.html.haml
@@ -14,8 +14,11 @@
- if post.forum
in
= link_to post.forum, post.forum
- at
+ on
= post.created_at
+ - if post.updated_at > post.created_at
+ and edited at
+ = post.updated_at
.post-body
:growstuff_markdown
@@ -24,7 +27,7 @@
- unless defined?(hide_comments)
.post-comments
%ul.list-inline
- %li.first= link_to pluralize(post.comments.count, "comment"),
+ %li.first= link_to pluralize(post.comments.size, "comment"),
post_path(post, :anchor => 'comments')
-if can? :create, Comment
%li= link_to "Reply", new_comment_path(:post_id => post.id)
diff --git a/app/views/posts/_summary.html.haml b/app/views/posts/_summary.html.haml
index f04dd2fb0..38db48a67 100644
--- a/app/views/posts/_summary.html.haml
+++ b/app/views/posts/_summary.html.haml
@@ -1,5 +1,5 @@
- howmany ||= 100
-- if posts.length > 0
+- if posts.size > 0
%table.table.table-striped
%tr
%th Subject
@@ -15,7 +15,11 @@
%td.hidden-xs
=link_to post.author, post.author
%td
- = distance_of_time_in_words(post.recent_activity, Time.zone.now)
- ago
+ - if post.updated_at > post.recent_activity
+ = post.updated_at.to_date.to_formatted_s(:short)
+ - else
+ = post.recent_activity.to_date.to_formatted_s(:short)
+ // once the site gets more active, can change this to include time as well
+ // can't make it relative (distance_of_time_in_words) as it's cached
%td.hidden-xs
- = post.comments.count.to_s
+ = post.comments.size.to_s
diff --git a/app/views/posts/index.html.haml b/app/views/posts/index.html.haml
index 930dbdf84..fa2156dcd 100644
--- a/app/views/posts/index.html.haml
+++ b/app/views/posts/index.html.haml
@@ -1,4 +1,4 @@
-- content_for :title, @author ? "#{@author}'s posts" : "Everyone's posts"
+- content_for :title, @author ? t('.title.author_posts', author: @author) : t('.title.default')
%p
- if can? :create, Post
@@ -15,7 +15,7 @@
= render :partial => 'shared/signin_signup', :locals => { :to => 'write a post' }
%div.pagination
- = page_entries_info @posts, :model => "posts"
+ = page_entries_info @posts
= will_paginate @posts
- unless @posts.empty?
@@ -23,14 +23,14 @@
= render :partial => "single", :locals => { :post => post, :subject => true }
%div.pagination
- = page_entries_info @posts, :model => "posts"
+ = page_entries_info @posts
= will_paginate @posts
%p
- if @author
Subscribe to
= succeed "." do
- = link_to "#{@author}'s posts RSS feed", posts_path(:format => 'rss')
+ = link_to "#{@author}'s posts RSS feed", posts_by_author_path(format: 'rss', author: @author)
- else
Subscribe to the #{ENV['GROWSTUFF_SITE_NAME']}
diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml
index b6e07bde7..6e0ee6161 100644
--- a/app/views/posts/show.html.haml
+++ b/app/views/posts/show.html.haml
@@ -1,4 +1,11 @@
= content_for :title, @post.subject
+- content_for :opengraph do
+ = tag("meta", property: "og:image", content: avatar_uri(@post.author, 200))
+ = tag("meta", property: "og:description", content: "#{strip_tags(@post.body).split(' ')[0..20].join(' ')}...")
+ = tag("meta", property: "og:title", content: @post.subject)
+ = tag("meta", property: "og:type", content: "article")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
- unless current_member
.alert.alert-info
@@ -16,16 +23,23 @@
= render :partial => "single", :locals => { :post => @post, :subject => false, :hide_comments => true }
-- if can? :edit, @post or can? :destroy, @post
- .post-actions
- - if can? :edit, @post
- = link_to 'Edit Post', edit_post_path(@post), :class => 'btn btn-default btn-xs'
- - if can? :destroy, @post
- = link_to 'Delete Post', @post, method: :delete, |
- data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
+- unless @post.crops.empty?
+ %h3 Crops mentioned in this post
+ - @post.crops.each do |c|
+ .col-md-2
+ = render :partial => 'crops/thumbnail', :locals => { :crop => c }
-= render :partial => "comments", :locals => { :post => @post }
+.col-md-11
+ - if can? :edit, @post or can? :destroy, @post
+ .post-actions
+ - if can? :edit, @post
+ = link_to 'Edit Post', edit_post_path(@post), :class => 'btn btn-default btn-xs'
+ - if can? :destroy, @post
+ = link_to 'Delete Post', @post, method: :delete, |
+ data: { confirm: 'Are you sure?' }, :class => 'btn btn-default btn-xs'
-- if can? :create, Comment
- .post-actions
- =link_to 'Comment', new_comment_path(:post_id => @post.id), :class => 'btn btn-primary'
+ = render :partial => "comments", :locals => { :post => @post }
+
+ - if can? :create, Comment
+ .post-actions
+ =link_to 'Comment', new_comment_path(:post_id => @post.id), :class => 'btn btn-primary'
diff --git a/app/views/products/_form.html.haml b/app/views/products/_form.html.haml
index f09bce0d8..78908001a 100644
--- a/app/views/products/_form.html.haml
+++ b/app/views/products/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @product do |f|
- if @product.errors.any?
#error_explanation
- %h2= "#{pluralize(@product.errors.count, "error")} prohibited this product from being saved:"
+ %h2= "#{pluralize(@product.errors.size, "error")} prohibited this product from being saved:"
%ul
- @product.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/roles/_form.html.haml b/app/views/roles/_form.html.haml
index 954a2f6a0..0d307d999 100644
--- a/app/views/roles/_form.html.haml
+++ b/app/views/roles/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @role do |f|
- if @role.errors.any?
#error_explanation
- %h2= "#{pluralize(@role.errors.count, "error")} prohibited this role from being saved:"
+ %h2= "#{pluralize(@role.errors.size, "error")} prohibited this role from being saved:"
%ul
- @role.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/scientific_names/_form.html.haml b/app/views/scientific_names/_form.html.haml
index e8d08978a..c29d371bf 100644
--- a/app/views/scientific_names/_form.html.haml
+++ b/app/views/scientific_names/_form.html.haml
@@ -1,7 +1,7 @@
= form_for @scientific_name, :html => {:class => 'form-horizontal', :role => "form"} do |f|
- if @scientific_name.errors.any?
#error_explanation
- %h2= "#{pluralize(@scientific_name.errors.count, "error")} prohibited this scientific_name from being saved:"
+ %h2= "#{pluralize(@scientific_name.errors.size, "error")} prohibited this scientific_name from being saved:"
%ul
- @scientific_name.errors.full_messages.each do |msg|
%li= msg
diff --git a/app/views/scientific_names/show.html.haml b/app/views/scientific_names/show.html.haml
index a3efe2d6f..b5d9c332f 100644
--- a/app/views/scientific_names/show.html.haml
+++ b/app/views/scientific_names/show.html.haml
@@ -1,5 +1,16 @@
+- content_for :opengraph do
+ - @scientific_name.crop.photos.each do |photo|
+ = tag("meta", property: "og:image", content: photo.fullsize_url)
+
+ = tag("meta", property: "og:title", content: @scientific_name.scientific_name)
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
+
%p#notice= notice
+= render :partial => 'crops/approval_status_message', :locals => { :crop => @scientific_name.crop }
+
%p
%b Scientific name:
= @scientific_name.scientific_name
@@ -7,6 +18,8 @@
%b Crop:
= link_to @scientific_name.crop, @scientific_name.crop
-= link_to 'Edit', edit_scientific_name_path(@scientific_name), :class => 'btn btn-default btn-xs'
-\|
+
+- if can? :edit, @scientific_name
+ = link_to 'Edit', edit_scientific_name_path(@scientific_name), :class => 'btn btn-default btn-xs'
+ \|
= link_to 'Back', scientific_names_path
diff --git a/app/views/seeds/_form.html.haml b/app/views/seeds/_form.html.haml
index 8d8eeaa97..77b4a6998 100644
--- a/app/views/seeds/_form.html.haml
+++ b/app/views/seeds/_form.html.haml
@@ -1,46 +1,53 @@
+= required_field_help_text
+
= form_for(@seed, :html => {:class => "form-horizontal", :role => "form"}) do |f|
- if @seed.errors.any?
#error_explanation
- %h2= "#{pluralize(@seed.errors.count, "error")} prohibited this seed from being saved:"
+ %h2= "#{pluralize(@seed.errors.size, "error")} prohibited this seed from being saved:"
%ul
- @seed.errors.full_messages.each do |msg|
%li= msg
- .form-group
+ .form-group.required
= f.label :crop, 'Crop:', :class => 'control-label col-md-2'
.col-md-8
= auto_suggest @seed, :crop, :class => 'form-control', :default => @crop
%span.help-inline
Can't find what you're looking for?
- = link_to "Request new crops.", Growstuff::Application.config.new_crops_request_link
+ = link_to "Request new crops.", new_crop_path
.form-group
= f.label :quantity, 'Quantity:', :class => 'control-label col-md-2'
.col-md-2
= f.number_field :quantity, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :plant_before, 'Plant before:', :class => 'control-label col-md-2'
.col-md-2
= f.text_field :plant_before, :class => 'add-datepicker form-control', :value => @seed.plant_before ? @seed.plant_before.to_s(:ymd) : ''
+ = render :partial => 'shared/form_optional'
.form-group
= f.label :days_until_maturity_min, 'Days until maturity:', :class => 'control-label col-md-2'
%fieldset
.col-md-2
= f.number_field :days_until_maturity_min, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.col-md-1
= f.label :days_until_maturity_max, 'to', :class => 'control-label'
.col-md-2
= f.number_field :days_until_maturity_max, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.col-md-1
= f.label :dummy, 'days', :class => 'control-label'
- .form-group
+
+ .form-group.required
= f.label :organic, 'Organic?', :class => 'control-label col-md-2'
.col-md-8
= f.select(:organic, Seed::ORGANIC_VALUES, {}, :class => 'form-control', :default => 'unknown')
- .form-group
+ .form-group.required
= f.label :gmo, 'GMO?', :class => 'control-label col-md-2'
.col-md-8
= f.select(:gmo, Seed::GMO_VALUES, {}, :class => 'form-control', :default => 'unknown')
- .form-group
+ .form-group.required
= f.label :heirloom, 'Heirloom?', :class => 'control-label col-md-2'
.col-md-8
= f.select(:heirloom, Seed::HEIRLOOM_VALUES, {}, :class => 'form-control', :default => 'unknown')
@@ -48,15 +55,12 @@
= f.label :description, 'Description:', :class => 'control-label col-md-2'
.col-md-8
= f.text_area :description, :rows => 6, :class => 'form-control'
+ = render :partial => 'shared/form_optional'
.form-group
.col-md-offset-2.col-md-8
%span.help-block
- Are you interested in trading or swapping seeds with other
- #{ENV['GROWSTUFF_SITE_NAME']} members? If you
- list your seeds as available for trade, other members can
- contact you to request seeds. You can list any conditions or
- other information in the description, above.
- .form-group
+ = t('.trade_help', :site_name => ENV['GROWSTUFF_SITE_NAME'])
+ .form-group.required
= f.label :tradable_to, 'Will trade:', :class => 'control-label col-md-2'
.col-md-8
= f.select(:tradable_to, Seed::TRADABLE_TO_VALUES, {}, :class => 'form-control')
diff --git a/app/views/seeds/_thumbnail.html.haml b/app/views/seeds/_thumbnail.html.haml
new file mode 100644
index 000000000..7bc5f6ad2
--- /dev/null
+++ b/app/views/seeds/_thumbnail.html.haml
@@ -0,0 +1,29 @@
+.panel.panel-success
+ .panel-heading
+ %h3.panel-title
+ = link_to "#{seed.owner.login_name}'s seed", seed
+ - if can? :edit, seed
+ %a.pull-right{:href => edit_seed_path(seed), :role => "button", :id => "edit_seed_glyphicon"}
+ %span.glyphicon.glyphicon-pencil{:title => "Edit"}
+ .panel-body
+ .row
+ .col-md-4
+ = link_to image_tag((seed.crop.default_photo ? seed.crop.default_photo.thumbnail_url : 'placeholder_150.png'), :alt => seed.crop.name, :class => 'img'), seed.crop
+ .col-md-8
+ %dl.dl-horizontal
+ %dt Crop :
+ %dd= link_to seed.crop.name, seed.crop
+ %dt Plant before :
+ %dd= seed.plant_before
+ %dt Quantity :
+ %dd= seed.quantity
+ %dt Will trade to :
+ %dd= seed.tradable_to
+ %dt From location :
+ %dd= seed.owner.location
+ %dt Owner :
+ %dd= link_to seed.owner.login_name, seed.owner
+ .panel-footer
+ %dt Description
+ %dd
+ = display_seed_description(seed)
diff --git a/app/views/seeds/index.csv.shaper b/app/views/seeds/index.csv.shaper
index 818e68909..68f5664d3 100644
--- a/app/views/seeds/index.csv.shaper
+++ b/app/views/seeds/index.csv.shaper
@@ -11,6 +11,9 @@ csv.headers :id,
:latitude,
:longitude,
:description,
+ :organic,
+ :gmo,
+ :heirloom,
:date_added,
:last_modified,
:license
@@ -37,6 +40,9 @@ csv.headers :id,
csv.cell :longitude, s.owner.longitude
csv.cell :description
+ csv.cell :organic
+ csv.cell :gmo
+ csv.cell :heirloom
csv.cell :date_added, s.created_at.to_s(:db)
csv.cell :last_modified, s.updated_at.to_s(:db)
diff --git a/app/views/seeds/index.html.haml b/app/views/seeds/index.html.haml
index c9e981651..86329147c 100644
--- a/app/views/seeds/index.html.haml
+++ b/app/views/seeds/index.html.haml
@@ -1,4 +1,6 @@
-- content_for :title, @owner ? "#{@owner}'s seeds" : @crop ? "Everyone's #{@crop.name} seeds" : "Everyone's seeds"
+- content_for :title, @owner ? t('.title.owner_seeds', owner: @owner) : @crop ? t('.title.crop_seeds', crop: @crop.name) : t('.title.default')
+- if @owner
+ = link_to "View #{@owner}'s profile >>", member_path(@owner)
%p
#{ENV['GROWSTUFF_SITE_NAME']} helps you track your seed
@@ -19,54 +21,25 @@
= render :partial => 'shared/signin_signup', :locals => { :to => 'add seeds to your stash' }
%div.pagination
- = page_entries_info @seeds, :model => "seeds"
+ = page_entries_info @seeds
+ = will_paginate @seeds
+.row
+ - if @seeds.size > 0
+ - @seeds.each do |seed|
+ .col-md-6
+ =render :partial => 'seeds/thumbnail', :locals => {:seed => seed}
+
+%div.pagination
+ = page_entries_info @seeds
= will_paginate @seeds
-- if @seeds.length > 0
-
- %table.table.table-striped
- %tr
- - unless @owner
- %th Owner
- %th Crop
- %th Description
- %th Quantity
- %th Plant before
- %th Will trade to
- %th From location
- %th
-
- - @seeds.each do |seed|
- %tr
- - unless @owner
- %td= link_to seed.owner.login_name, seed.owner
- %td= link_to seed.crop.name, seed.crop
- %td= seed.description
- %td= seed.quantity
- %td= seed.plant_before
- %td= seed.tradable? ? seed.tradable_to : ''
- %td
- - if seed.tradable?
- - if seed.owner.location.blank?
- unspecified
- - else
- = link_to seed.owner.location, place_path(seed.owner.location)
- %td
- = link_to 'Details', seed, :class => 'btn btn-default btn-xs'
- - if can? :edit, seed
- = link_to 'Edit', edit_seed_path(seed), :class => 'btn btn-default btn-xs'
-
- %div.pagination
- = page_entries_info @seeds, :model => "seeds"
- = will_paginate @seeds
-
- %ul.list-inline
- %li The data on this page is available in the following formats:
- - if @owner
- %li= link_to "CSV", seeds_by_owner_path(@owner, :format => 'csv')
- %li= link_to "JSON", seeds_by_owner_path(@owner, :format => 'json')
- %li= link_to "RSS", seeds_by_owner_path(@owner, :format => 'rss')
- - else
- %li= link_to "CSV", seeds_path(:format => 'csv')
- %li= link_to "JSON", seeds_path(:format => 'json')
- %li= link_to "RSS", seeds_path(:format => 'rss')
+%ul.list-inline
+ %li The data on this page is available in the following formats:
+ - if @owner
+ %li= link_to "CSV", seeds_by_owner_path(@owner, :format => 'csv')
+ %li= link_to "JSON", seeds_by_owner_path(@owner, :format => 'json')
+ %li= link_to "RSS", seeds_by_owner_path(@owner, :format => 'rss')
+ - else
+ %li= link_to "CSV", seeds_path(:format => 'csv')
+ %li= link_to "JSON", seeds_path(:format => 'json')
+ %li= link_to "RSS", seeds_path(:format => 'rss')
diff --git a/app/views/seeds/index.rss.haml b/app/views/seeds/index.rss.haml
index 30cec02af..c35bc0d74 100644
--- a/app/views/seeds/index.rss.haml
+++ b/app/views/seeds/index.rss.haml
@@ -12,6 +12,9 @@
:escaped
Will trade #{seed.tradable_to} from #{seed.owner.location ? seed.owner.location : 'unknown location'}
diff --git a/app/views/seeds/show.html.haml b/app/views/seeds/show.html.haml
index c2f3399ea..e4e55f68e 100644
--- a/app/views/seeds/show.html.haml
+++ b/app/views/seeds/show.html.haml
@@ -1,4 +1,13 @@
- content_for :title, "#{@seed.owner}'s #{@seed.crop} seeds"
+- content_for :opengraph do
+ - @seed.crop.photos.each do |photo|
+ = tag("meta", property: "og:image", content: photo.fullsize_url)
+ - if @seed.description
+ = tag("meta", property: "og:description", content: @seed.description)
+ = tag("meta", property: "og:image", content: "#{@seed.owner}'s #{@seed.crop} seeds")
+ = tag("meta", property: "og:type", content: "website")
+ = tag("meta", property: "og:url", content: request.original_url)
+ = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME'])
.row
.col-md-6
@@ -35,7 +44,7 @@
- else
(from
= succeed ")" do
- = link_to @seed.owner.location, place_path(@seed.owner.location)
+ = link_to @seed.owner.location, place_path(@seed.owner.location, anchor: "seeds")
%p
%b Description:
@@ -57,3 +66,8 @@
.col-md-6
= render :partial => "crops/index_card", :locals => { :crop => @seed.crop }
+ - if @seed.owner.location
+ %p
+ %small
+ View other seeds, members and more near
+ = link_to @seed.owner.location, place_path(@seed.owner.location, anchor: "seeds")
\ No newline at end of file
diff --git a/app/views/shared/_form_optional.html.haml b/app/views/shared/_form_optional.html.haml
new file mode 100644
index 000000000..28fe3598b
--- /dev/null
+++ b/app/views/shared/_form_optional.html.haml
@@ -0,0 +1,2 @@
+%span.help-block.optional
+ = I18n.t 'optional', :scope => 'forms'
diff --git a/app/views/shared/_markdown_help.html.haml b/app/views/shared/_markdown_help.html.haml
index 41aaa1a31..28505a083 100644
--- a/app/views/shared/_markdown_help.html.haml
+++ b/app/views/shared/_markdown_help.html.haml
@@ -5,3 +5,5 @@ to format your text.
For instance, *italic*, **bold**, or a link [like this](http://to.some.site.com/).
%br/
Quick crop links: [sweet potato](crop).
+%br/
+Quick member links: @Username or [Username](member).
diff --git a/app/views/shop/index.html.haml b/app/views/shop/index.html.haml
index d2064828e..da7008d69 100644
--- a/app/views/shop/index.html.haml
+++ b/app/views/shop/index.html.haml
@@ -1,4 +1,4 @@
--content_for :title, 'Shop'
+-content_for :title, t('.title')
%p
Growstuff relies on your support to build and run this open source
@@ -26,7 +26,7 @@
= render "shared/account_status"
-- elsif @order and @order.order_items.count > 0
+- elsif @order and @order.order_items.size > 0
%h2 Your current order
%p
diff --git a/app/views/support/index.html.haml b/app/views/support/index.html.haml
deleted file mode 100644
index 2b64fd000..000000000
--- a/app/views/support/index.html.haml
+++ /dev/null
@@ -1,211 +0,0 @@
--content_for :title, 'Support - Frequently Asked Questions'
-
-:markdown
- ## About Growstuff
-
- ### Who runs Growstuff?
-
- Growstuff is run by Alex Bayley ([Skud](/members/skud)) an open source
- software developer and keen veggie gardener from Melbourne, Australia.
-
- ### How did Growstuff get started?
-
- The idea of Growstuff came out of a discussion at an open source conference in Spain in 2012. We wanted a free, open source of information about planting and growing crops, and realised the best way to do this would be to crowdsource it from gardeners around the world.
-
- We first set up Growstuff as an open source project in August 2012, and quietly launched it in March 2013. We are planning to have a full public launch in May 2013.
-
- ### Is Growstuff a non-profit?
-
- No, Growstuff is a for-profit business (Growstuff Pty Ltd), incorporated in Australia. The business helps provide hosting and support for the Growstuff website. However, we make our best efforts to operate as an ethical, transparent, and community-minded company. You should also know that software and aggregated data about crops and who's growing them are freely available under open licenses. You might like to read [Why Growstuff is Open Source](http://blog.growstuff.org/2013/02/20/why-growstuff-is-open-source/) to understand some of the reasoning behind that.
-
- ### How does Growstuff make money?
-
- We will offer paid subscriptions/memberships, which give you access to special features and a warm glow of knowing you're supporting a sustainable, community-focused project.
-
- ### Can I advertise on Growstuff?
-
- Sorry, we're 100% ad-free!
-
- If you're a member, you can post things to trade or sell in our trading post area, but we don't have and will never have banner ads or the like. We believe that supporting a website through outside advertising makes for a less pleasant experience for our members and visitors, and is not a sustainable business model.
-
- ### What's the status of Growstuff? Is it in beta?
-
- We don't much like the word "beta" or the idea it represents.
- Growstuff is in a constant state of change and improvement, and we
- hope we will always be adding new features and making things better
- for our members.
-
- If you find any bugs or problems, please let us know via our support
- forum. If a feature you want isn't available yet, check back soon!
-
- ## Membership and payments
-
- ### Can I use Growstuff for free?
-
- Absolutely! You can sign up right now for a no-cost membership and use it for as long as you want, perhaps forever.
-
- ### Can I get a membership for my family, school, or community group?
-
- Yup! Feel free to sign up as "JonesFamily" or "SmithfieldCommunity" or whatever floats your boat.
-
- Just keep in mind that you are responsible for anything that happens under that account, so be careful who you allow to use it. In due course, we are hoping to develop features to help community gardens share with their members/gardeners, so that they can track what's planted in the community garden without having to login as the community garden account. We'll publicise this widely when it's ready, so keep an ear to the ground.
-
- ### What other types of accounts are there?
-
- You can purchase a paid account which will give you access to special
- features, and a warm glow of knowing you're supporting a
- community-focused, open source project. You can see the current list
- of paid account options in our [shop](/shop).
-
- ## Profile, settings, and privacy
-
- ### How do I add a picture to my profile?
-
- Profile pictures are provided [Gravatar](http://gravatar.com Gravatar), a service that provides "Globally Recognised Avatars", run by the people who operate the Wordpress blogging platform.
-
- If you have ever signed up for Gravatar in the past, using the same address as you signed up for Growstuff, you will already have a picture for your profile.
-
- If you have signed up for Growstuff with a different email address than your Gravatar address, you will need to add it on Gravatar.
-
- If you have never signed up for Gravatar before, you can create an account and upload a picture, which will appear not only on Growstuff, but on any other site which supports Gravatars and where you use the same email address.
-
- ### Do I have to fill in all this personal stuff?
-
- Your profile asks several questions about you, which you can choose to answer (or not) as you see fit. We don't require personal information like your legal name, gender, or age for tracking or demographic purposes -- one of the benefits of not having ads on our site!
-
- When it comes to location, it really helps if you can provide that to Growstuff because we use it to suggest things to grow. However, you can do it at whatever level of detail you're comfortable with: perhaps the name of your town, or your state or province, or even your country if the country is small enough and has a fairly consistent climate. Just choose something that is close enough to give you accurate growing advice, and vague enough to feel safe.
-
- You can read more about the privacy of your information in our [Privacy Policy](http://growstuff.org/policy/privacy).
-
-
- ## Crops, gardens, and planting
-
- ### How can I add a new crop?
-
- For now, please drop a note in [Requests for new crops](http://www.growstuff.org/posts/skud-20130319-requests-for-new-crops) on our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support).
-
- ### Will you add non-edible plants?
-
- We do not currently have plans to add plants which are not edible or which are not "useful" in a food-growing or sustainability context -- these might include companions plants, green manure crops, plants used to manage pests or diseases, and the like. If you're thinking of purely ornamental plants, we probably won't be adding them anytime soon.
-
- However, we are hoping, in future, to support the ability for any member to plant "unofficial" plants that aren't in our crop database.
-
- ## Posting, commenting, and forums
-
- ### What formatting can I use in posts and comments?
-
- We use [Markdown](http://daringfireball.net/projects/markdown/syntax/) syntax, which offers a pretty wide range of options from simple emphasis (bold and italics) to links, pictures, and more. We're hoping to install a toolbar to help you generate the right syntax, but in the meantime I'm afraid all we can offer is the rather technical documentation linked above.
-
- ## Forthcoming features
-
- ### Where can I see what features are planned?
-
- Our software developers use a tracking tool called Pivotal Tracker, and you can see ours at [http://tracker.growstuff.org/](http://tracker.growstuff.org). This tells you what features we are currently working on and plan to work on soon.
-
- Pivotal Tracker's interface shows three columns of information:
-
- * the "Current" section shows the features (called "stories") that we're working on at the moment
- * "Backlog" shows you stories that we're planning to work on in the nearish future
- * "Icebox" contains stories that we've identified as things we'd like to do, but which don't have a timeframe set yet.
-
- ### Where can I suggest a feature I'd like to see?
-
- We suggest checking the [tracker](http://tracker.growstuff.org/) first (see above) to see if it's something we're already planning or talking about. Once you've done that, if it's not already planned or you have some other comments to make, you can post your suggestion in the [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support].
-
- ## Developers and API
-
- ### Is there a Growstuff API?
-
- At present there is no official API, as our site is still changing so
- rapidly. However, we do expose some of our data via JSON and/or RSS
- feeds, and you're welcome to play with it, on the understanding that
- it may change under you. You can find [API docs on our wiki](http://wiki.growstuff.org/index.php/API).
-
- Use of our API and data is subject to the [API and Data Use Policy](http://www.growstuff.org/policy/api).
-
- ### What license is your data under?
-
- Growstuff's data is licensed under the [Creative Commons Attribution Share-Alike license (CC-BY-SA) 3.0 Unported license](http://creativecommons.org/licenses/by-sa/3.0/). This means you can re-use it as long as you attribute it to Growstuff (by linking back to our site), and as long as your own app/site/project shares its own content or data under CC-BY-SA.
-
- See our [API and Data Use Policy](http://growstuff.org/policy/api) for more information.
-
- ## Volunteering and jobs
-
- ### Are you hiring?
-
- Sadly, no. We're a self-funded/bootstrapped company, and at present we're not even paying ourselves.
-
- When we are ready to hire, we will most likely look first to people we know from our community. If you want to get involved, see below.
-
- ### How can I volunteer to help Growstuff?
-
- First and foremost, by being an active member of the site -- growing crops, tracking your harvests, posting in our forums, getting to know other members -- you help build our database and our community, without which Growstuff would be completely pointless. So, thanks for that!
-
- Secondly, we'd love it if you could spread the word about Growstuff to your friends who grow their own food or who might like to try. You can see some tips on how to do that below.
-
- Growstuff's software is built with the help of volunteer developers, too. If you're a coder or would like to learn how to code, you can join us in that. All are welcome, regardless of experience.
-
- We also have volunteer crop wranglers, who manage our crops database, and moderators, who help keep the forums running smoothly. These are usually chosen from among our most active and helpful members.
-
- ### How can I get involved as a coder?
-
- Start by checking out our [wiki](http://wiki.growstuff.org/), code on [Github](http://github.com/Growstuff/growstuff), and [tracker](http://tracker.growstuff.org) to get an idea of how we work.
-
- If you want to get involved, you should join our [discussion mailing list](http://lists.growstuff.org/mailman/listinfo/discuss) and/or come hang out on our [IRC channel](http://wiki.growstuff.org/index.php/IRC), #growstuff on irc.freenode.net.
-
- ### My coding skills are rusty or non-existent. Can I still get involved?
-
- Sure! We love to mentor new coders, people who haven't coded in a while, or people who are just learning our platform (Ruby on Rails) for the first time. We work by pair programming, and can get you started on easy stories, starting with something as simple as fixing a typo or HTML tag (check the "easy" tag in our [tracker](http://tracker.growstuff.org) for some examples).
-
- ### How can I help spread the word about Growstuff?
-
- First and foremost, by telling your friends and inviting them to join and be part of it. We don't want to be spammy about it, so we'll never ask to scrape your address book or automatically post Facebook updates or tweet on your behalf. But we would really love it if you'd tell people in your own words.
-
- Places to spread the word online: Facebook, Twitter, and other social media; your own blog or website; gardening or sustainability forums you participate in.
-
- Or offline: tell friends, family and neighbours; spread the word through your local community gardens, farmers markets, or produce swaps; contact your local sustainability or Transition group; or any other place where you think food-growers might be.
-
- ## Terms of service, copyright, and other abuse
-
- ### Where can I report a violation of the Terms of Service or Community Guidelines?
-
- You can post in our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support) or send email to [support@growstuff.org](mailto:support@growstuff.org).
-
- ### What do you consider spam, and how can I report it?
-
- There are many kinds of spam. The most obvious is repeated, unwanted commercial advertising. Many spammers also post irrelevant, nonsensical, or low-value content to forums to try and get you to click on a link, or just to see what they can get away with.
-
- Please report all these kinds of spam!
-
- For now, because we're so new, we don't have a good spam reporting mechanism set up. However, you can drop a link in our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support) and we'll do what we can.
-
- ### Someone posted something I believe is copyright. Where can I report it?
-
- If you are the copyright owner, you can submit a complaint by following the procedure outlined in our [Copyright Infringement Policy](http://growstuff.org/policy/copyright).
-
- ### Is Growstuff safe for kids to use?
-
- As a website that's focused on growing food, we expect Growstuff to be a pretty safe and friendly environment. However, some parts of the site (such as posts made by members) may contain mature concepts, coarse language, and the like. If you don't want your kids exposed to these, we strongly suggest you supervise their use of Growstuff. We also suggest you be careful about what personal information your kids share on Growstuff.
-
- ## Further support
-
- ### Where can I find a list of known issues with the site?
-
- In the [Known Issues](http://www.growstuff.org/posts/skud-20130319-known-issues) post on our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support).
-
- ### My question's not answered here. Where can I ask for further support?
-
- On our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support). Please check the list of known issues before posting.
-
- ### Where can I post feedback/kudos?
-
- We love feedback! Drop us a note in our [Feedback & Support forum](http://www.growstuff.org/forums/growstuff-feedback-support). (Is there an echo in here?)
-
- ### How else can I contact you?
-
- If you need help with something that hasn't been covered here, then you can send an email to [support@growstuff.org](mailto:support@growstuff.org).
-
- Media/press enquiries can go to [media@growstuff.org](mailto:media@growstuff.org).
-
- If you have an enquiry about the site in general (eg. businessy stuff, or just want to get in touch with someone official in a non-support-like way), you can send an email to [info@growstuff.org](mailto:info@growstuff.org).
-
diff --git a/config.rb b/config.rb
index 70630b003..5cd5b6cc6 100644
--- a/config.rb
+++ b/config.rb
@@ -19,7 +19,7 @@ images_dir = "app/assets/images"
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
-# preferred_syntax = :sass
+preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
diff --git a/config/application.rb b/config/application.rb
index 113d0bc66..facb29787 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -5,7 +5,7 @@ require 'openssl'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
- Bundler.require(*Rails.groups(:assets => %w(development test)))
+ Bundler.require(*Rails.groups(assets: %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
@@ -84,9 +84,9 @@ module Growstuff
config.action_mailer.delivery_method = :sendmail
config.action_mailer.sendmail_settings = {
- :location => '/usr/sbin/sendmail',
- :arguments => '-i -t',
- :openssl_verify_mode => 'none'
+ location: '/usr/sbin/sendmail',
+ arguments: '-i -t',
+ openssl_verify_mode: 'none'
}
# Growstuff-specific configuration variables
diff --git a/config/application.yml.example b/config/application.yml.example
index 03e8afe2c..309ac509a 100644
--- a/config/application.yml.example
+++ b/config/application.yml.example
@@ -78,6 +78,7 @@ GROWSTUFF_ELASTICSEARCH: "false"
test:
GROWSTUFF_SITE_NAME: Growstuff (test)
+ GROWSTUFF_CAPYBARA_DRIVER: poltergeist
# Note: there is no good way to deploy settings from Figaro to
# Travis-CI. If you need env vars set there in order for tests to pass,
diff --git a/config/database.yml b/config/database.yml
index 6b0ab1503..eb75b3791 100644
--- a/config/database.yml
+++ b/config/database.yml
@@ -3,12 +3,14 @@ development:
database: growstuff_dev
host: localhost
user: postgres
+ password: postgres
test:
adapter: postgresql
database: growstuff_test
host: localhost
user: postgres
+ password: postgres
production:
adapter: postgresql
diff --git a/config/database.yml.example b/config/database.yml.example
new file mode 100644
index 000000000..eb75b3791
--- /dev/null
+++ b/config/database.yml.example
@@ -0,0 +1,31 @@
+development:
+ adapter: postgresql
+ database: growstuff_dev
+ host: localhost
+ user: postgres
+ password: postgres
+
+test:
+ adapter: postgresql
+ database: growstuff_test
+ host: localhost
+ user: postgres
+ password: postgres
+
+production:
+ adapter: postgresql
+ database: growstuff_prod
+ pool: 5
+ timeout: 5000
+ username: growstuff
+ host: localhost
+ password: thisisnottherealpassword
+
+staging:
+ adapter: postgresql
+ database: growstuff_prod
+ pool: 5
+ timeout: 5000
+ username: growstuff
+ host: localhost
+ password: thisisnottherealpassword
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 45d7b96bf..700771c10 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -44,16 +44,15 @@ Growstuff::Application.configure do
# config.action_view.raise_on_missing_translations = true
# Growstuff config
- config.new_crops_request_link = "http://example.com/not-a-real-url"
- config.action_mailer.default_url_options = { :host => 'localhost:8080' }
+ config.action_mailer.default_url_options = { host: 'localhost:8080' }
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = {
- :port => '587',
- :address => 'smtp.mandrillapp.com',
- :user_name => ENV['GROWSTUFF_MANDRILL_USERNAME'],
- :password => ENV['GROWSTUFF_MANDRILL_APIKEY'],
- :authentication => :login
+ port: '587',
+ address: 'smtp.mandrillapp.com',
+ user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'],
+ password: ENV['GROWSTUFF_MANDRILL_APIKEY'],
+ authentication: :login
}
config.host = 'localhost:8080'
@@ -66,9 +65,9 @@ Growstuff::Application.configure do
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
- :login => ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy',
- :password => ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy',
- :signature => ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy'
+ login: ENV['GROWSTUFF_PAYPAL_USERNAME'] || 'dummy',
+ password: ENV['GROWSTUFF_PAYPAL_PASSWORD'] || 'dummy',
+ signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE'] || 'dummy'
}
::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 523418b32..3b61a9255 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -67,16 +67,15 @@ Growstuff::Application.configure do
config.active_record.dump_schema_after_migration = false
# Growstuff configuration
- config.new_crops_request_link = "http://growstuff.org/posts/skud-20130319-requests-for-new-crops"
- config.action_mailer.default_url_options = { :host => 'growstuff.org' }
+ config.action_mailer.default_url_options = { host: 'growstuff.org' }
config.action_mailer.smtp_settings = {
- :port => '587',
- :address => 'smtp.mandrillapp.com',
- :user_name => ENV['GROWSTUFF_MANDRILL_USERNAME'],
- :password => ENV['GROWSTUFF_MANDRILL_APIKEY'],
- :domain => 'heroku.com',
- :authentication => :plain
+ port: '587',
+ address: 'smtp.mandrillapp.com',
+ user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'],
+ password: ENV['GROWSTUFF_MANDRILL_APIKEY'],
+ domain: 'heroku.com',
+ authentication: :plain
}
config.action_mailer.delivery_method = :smtp
@@ -94,9 +93,9 @@ Growstuff::Application.configure do
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :production
paypal_options = {
- :login => ENV['GROWSTUFF_PAYPAL_USERNAME'],
- :password => ENV['GROWSTUFF_PAYPAL_PASSWORD'],
- :signature => ENV['GROWSTUFF_PAYPAL_SIGNATURE']
+ login: ENV['GROWSTUFF_PAYPAL_USERNAME'],
+ password: ENV['GROWSTUFF_PAYPAL_PASSWORD'],
+ signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE']
}
::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
diff --git a/config/environments/staging.rb b/config/environments/staging.rb
index 150c62d8c..e9702cad0 100644
--- a/config/environments/staging.rb
+++ b/config/environments/staging.rb
@@ -69,16 +69,15 @@ Growstuff::Application.configure do
config.active_record.dump_schema_after_migration = false
# Growstuff configuration
- config.new_crops_request_link = "http://example.com/not-a-real-url"
- config.action_mailer.default_url_options = { :host => 'staging.growstuff.org' }
+ config.action_mailer.default_url_options = { host: 'staging.growstuff.org' }
config.action_mailer.smtp_settings = {
- :port => '587',
- :address => 'smtp.mandrillapp.com',
- :user_name => ENV['GROWSTUFF_MANDRILL_USERNAME'],
- :password => ENV['GROWSTUFF_MANDRILL_APIKEY'],
- :domain => 'heroku.com',
- :authentication => :plain
+ port: '587',
+ address: 'smtp.mandrillapp.com',
+ user_name: ENV['GROWSTUFF_MANDRILL_USERNAME'],
+ password: ENV['GROWSTUFF_MANDRILL_APIKEY'],
+ domain: 'heroku.com',
+ authentication: :plain
}
config.action_mailer.delivery_method = :smtp
@@ -92,9 +91,9 @@ Growstuff::Application.configure do
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
- :login => ENV['GROWSTUFF_PAYPAL_USERNAME'],
- :password => ENV['GROWSTUFF_PAYPAL_PASSWORD'],
- :signature => ENV['GROWSTUFF_PAYPAL_SIGNATURE']
+ login: ENV['GROWSTUFF_PAYPAL_USERNAME'],
+ password: ENV['GROWSTUFF_PAYPAL_PASSWORD'],
+ signature: ENV['GROWSTUFF_PAYPAL_SIGNATURE']
}
::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
diff --git a/config/environments/test.rb b/config/environments/test.rb
index ffdc4c972..61eba7adc 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -40,8 +40,7 @@ Growstuff::Application.configure do
# config.action_view.raise_on_missing_translations = true
# Growstuff config
- config.new_crops_request_link = "http://example.com/not-a-real-url"
- config.action_mailer.default_url_options = { :host => 'localhost:8080' }
+ config.action_mailer.default_url_options = { host: 'localhost:8080' }
Growstuff::Application.configure do
config.host = 'test.example.com'
@@ -57,7 +56,7 @@ Growstuff::Application.configure do
end
-Geocoder.configure(:lookup => :test)
+Geocoder.configure(lookup: :test)
Geocoder::Lookup::Test.add_stub(
"Amundsen-Scott Base, Antarctica", [
@@ -68,6 +67,20 @@ Geocoder::Lookup::Test.add_stub(
]
)
+Geocoder::Lookup::Test.add_stub(
+ "Philippines", [
+ {
+ 'latitude' => 12.7503486,
+ 'longitude' => 122.7312101,
+ 'address' => 'Manila, Mnl, Philippines',
+ 'state' => 'Manila',
+ 'state_code' => 'Mnl',
+ 'country' => 'Philippines',
+ 'country_code' => 'PH'
+ }
+ ]
+)
+
Geocoder::Lookup::Test.add_stub(
"Greenwich, UK", [
{
diff --git a/config/factory_girl.rb b/config/factory_girl.rb
new file mode 100644
index 000000000..f9e9b5bfb
--- /dev/null
+++ b/config/factory_girl.rb
@@ -0,0 +1,9 @@
+ActionDispatch::Callbacks.after do
+ # Reload the factories
+ return unless (Rails.env.development? || Rails.env.test?)
+
+ unless FactoryGirl.factories.blank? # first init will load factories, this should only run on subsequent reloads
+ FactoryGirl.factories.clear
+ FactoryGirl.find_definitions
+ end
+end
diff --git a/config/initializers/comfortable_mexican_sofa.rb b/config/initializers/comfortable_mexican_sofa.rb
index fe6e80ace..fc5025933 100644
--- a/config/initializers/comfortable_mexican_sofa.rb
+++ b/config/initializers/comfortable_mexican_sofa.rb
@@ -97,7 +97,7 @@ end
module CmsDeviseAuth
def authenticate
unless current_member && current_member.has_role?(:admin)
- redirect_to root_path, :alert => 'Permission denied. Please sign in as an admin user to use the CMS admin area.'
+ redirect_to root_path, alert: 'Permission denied. Please sign in as an admin user to use the CMS admin area.'
end
end
end
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index 801a6677f..a11c9b5ca 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -121,7 +121,7 @@ Devise.setup do |config|
# Email regex used to validate email formats. It simply asserts that
# an one (and only one) @ exists in the given string. This is mainly
# to give user feedback and not to assert the e-mail validity.
- # config.email_regexp = /\A[^@]+@[^@]+\z/
+ config.email_regexp = /\A[^@]+@[^@]+\z/
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
diff --git a/config/initializers/geocoder.rb b/config/initializers/geocoder.rb
index 16de69ec0..9c52ced91 100644
--- a/config/initializers/geocoder.rb
+++ b/config/initializers/geocoder.rb
@@ -1,9 +1,9 @@
require 'geocodable'
Geocoder.configure(
- :units => :km,
- :timeout => 10,
- :http_headers => {
+ units: :km,
+ timeout: 10,
+ http_headers: {
"User-Agent" =>
"#{Growstuff::Application.config.user_agent} #{Growstuff::Application.config.user_agent_email}",
"From" => Growstuff::Application.config.user_agent_email
@@ -12,6 +12,5 @@ Geocoder.configure(
# This configuration takes precedence over environment/test.rb
# Reported as https://github.com/alexreisner/geocoder/issues/509
if Geocoder.config.lookup != :test
- Geocoder.configure(:lookup => :nominatim)
-end
-
+ Geocoder.configure(lookup: :nominatim)
+end
\ No newline at end of file
diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb
deleted file mode 100644
index 8ebcc27d3..000000000
--- a/config/initializers/secret_token.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# Be sure to restart your server when you modify this file.
-
-# Your secret key for verifying the integrity of signed cookies.
-# If you change this key, all old signed cookies will become invalid!
-# Make sure the secret is at least 30 characters and all random,
-# no regular words or you'll be exposed to dictionary attacks.
-Growstuff::Application.config.secret_token = ENV['RAILS_SECRET_TOKEN'] || "this is not a real secret token but it's here to make life easier for developers"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 84f8cf9e0..aa3d52424 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2,6 +2,8 @@
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
+ forms:
+ optional: "(Optional)"
unauthorized:
read:
notification: "You must be signed in to view notifications."
@@ -15,18 +17,91 @@ en:
all: "Not authorized to %{action} %{subject}."
layouts:
- footer:
- about: "About"
- our_values: "Our Values"
- open_source: "Open Source"
- growstuff_team: "Growstuff Team"
- get_involved: "Get Involved"
- terms_of_service: "Terms of Service"
- privacy_policy: "Privacy Policy"
- data_use_policy: "Data Use Policy"
- community_guidelines: "Community Guidelines"
- support_: "Support" # for some reason 'support' seems to be a reserved word
- contact: "Contact"
+ header:
+ skip: "Skip navigation menu"
+ browse_crops: &browse_crops "Browse Crops"
+ seeds: "Seeds"
+ plantings: "Plantings"
+ harvests: "Harvests"
+ community_map: "Community Map"
+ browse_members: "Browse Members"
+ posts: "Posts"
+ forums: &forums "Forums"
+ support_growstuff: "Support Growstuff"
+ profile: "Profile"
+ gardens: "Gardens"
+ account: "Account"
+ inbox_unread: "Inbox (%{unread_count})"
+ inbox: "Inbox"
+ crop_wrangling: "Crop Wrangling"
+ admin: "Admin"
+ your_stuff: "Your Stuff (%{unread_count})"
+
+ crops:
+ index:
+ title: *browse_crops
+ subtitle: "%{crops_size} total"
+
+ gardens:
+ form:
+ location_helper: "If you have a location set in your profile, it will be used when
+ you create a new garden."
+
+ seeds:
+ index:
+ title:
+ default: "Everyone's seeds"
+ crop_seeds: "Everyone's %{crop} seeds"
+ owner_seeds: "%{owner} seeds"
+ form:
+ trade_help: "Are you interested in trading or swapping seeds with other
+ %{site_name} members? If you
+ list your seeds as available for trade, other members can
+ contact you to request seeds. You can list any conditions or
+ other information in the description, above."
+
+ plantings:
+ index:
+ title:
+ default: "Everyone's plantings"
+ crop_plantings: "Everyone's %{crop} plantings"
+ owner_plantings: "%{owner} plantings"
+ form:
+ finish_helper: "A planting is finished when you've harvested all of the crop, or
+ it dies, or it's otherwise no longer growing in your garden."
+
+ photos:
+ show:
+ thing_by: "A %{thing} by %{owner}"
+
+ harvests:
+ index:
+ title:
+ default: "Everyone's harvests"
+ crop_harvests: "Everyone's %{crop} harvests"
+ owner_harvests: "%{owner} harvests"
+
+ places:
+ index:
+ title: "%{site_name} Community Map"
+
+ members:
+ index:
+ title: "%{site_name} members"
+
+ posts:
+ index:
+ title:
+ default: "Everyone's posts"
+ author_posts: "%{author} posts"
+
+ shop:
+ index:
+ title: "Shop"
+
+ forums:
+ index:
+ title: *forums
home:
blurb:
@@ -96,3 +171,32 @@ en:
post: "Post"
edit_profile: "Edit profile"
+ activerecord:
+ models:
+ comment:
+ one: "comment"
+ other: "comments"
+ crop:
+ one: "crop"
+ other: "crops"
+ garden:
+ one: "garden"
+ other: "gardens"
+ harvest:
+ one: "harvest"
+ other: "harvests"
+ member:
+ one: "member"
+ other: "members"
+ photo:
+ one: "photo"
+ other: "photos"
+ planting:
+ one: "planting"
+ other: "plantings"
+ post:
+ one: "post"
+ other: "posts"
+ seed:
+ one: "seed"
+ other: "seeds"
diff --git a/config/robots.staging.txt b/config/robots.staging.txt
new file mode 100644
index 000000000..c6742d8a8
--- /dev/null
+++ b/config/robots.staging.txt
@@ -0,0 +1,2 @@
+User-Agent: *
+Disallow: /
diff --git a/config/robots.txt b/config/robots.txt
new file mode 100644
index 000000000..e69de29bb
diff --git a/config/routes.rb b/config/routes.rb
index 98c1d8db0..08ca6a439 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,15 +1,19 @@
Growstuff::Application.routes.draw do
+ get '/robots.txt' => 'robots#robots'
resources :plant_parts
- devise_for :members, :controllers => { :registrations => "registrations", :passwords => "passwords" }
+ devise_for :members, controllers: { registrations: "registrations", passwords: "passwords", sessions: "sessions" }
+ devise_scope :member do
+ get '/members/unsubscribe/:message' => 'members#unsubscribe', :as => 'unsubscribe_member'
+ end
- resources :members
+ resources :members
resources :photos
- resources :authentications, :only => [:create, :destroy]
+ resources :authentications, only: [:create, :destroy]
resources :plantings
get '/plantings/owner/:owner' => 'plantings#index', :as => 'plantings_by_owner'
@@ -40,9 +44,11 @@ Growstuff::Application.routes.draw do
resources :comments
resources :roles
resources :forums
- resources :notifications
+ resources :notifications do
+ get 'reply', on: :member
+ end
- resources :follows, :only => [:create, :destroy]
+ resources :follows, only: [:create, :destroy]
get '/members/:login_name/follows' => 'members#view_follows', :as => 'member_follows'
get '/members/:login_name/followers' => 'members#view_followers', :as => 'member_followers'
@@ -65,22 +71,14 @@ Growstuff::Application.routes.draw do
resources :likes, :only => [:create, :destroy]
get "home/index"
- root :to => 'home#index'
+ root to: 'home#index'
get 'auth/:provider/callback' => 'authentications#create'
-
- get '/policy/:action' => 'policy#:action'
-
- get '/support' => 'support#index'
- get '/support/:action' => 'support#:action'
-
- get '/about' => 'about#index'
- get '/about/:action' => 'about#:action'
-
get '/shop' => 'shop#index'
get '/shop/:action' => 'shop#:action'
+ comfy_route :cms_admin, path: '/admin/cms'
get '/admin/orders' => 'admin/orders#index'
get '/admin/orders/:action' => 'admin/orders#:action'
get '/admin' => 'admin#index'
@@ -88,7 +86,6 @@ Growstuff::Application.routes.draw do
get '/admin/:action' => 'admin#:action'
# CMS stuff -- must remain LAST
- comfy_route :cms_admin, :path => '/cms/admin'
- comfy_route :cms, :path => '/', :sitemap => false
+ comfy_route :cms, path: '/', sitemap: false
end
diff --git a/config/secrets.yml b/config/secrets.yml
new file mode 100644
index 000000000..0337fd547
--- /dev/null
+++ b/config/secrets.yml
@@ -0,0 +1,20 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+
+development:
+ secret_key_base: 'b1b67abb399261478f4721e704eb3851466daf60d9cd2b53a1839b056d641c4c1c2a476bcaf7addc6d6548926cfd32fa5a00a8de258880257ebb5a6fd86cb08f'
+ # run 'rake secret' to generate your own
+
+test:
+ secret_key_base: 'be557aa019b181f201c9906663dbf8f22efb1b70b11f78035bfeda86aa7dcfd1efb184e2ee894a0ae0dc37fe67d311f38e7731fa16d8d595f2e1ef5447bae020'
+ # run 'rake secret' to generate your own
+
+staging:
+ secret_key_base: <%= ENV["RAILS_SECRET_TOKEN"] %>
+
+production:
+ secret_key_base: <%= ENV["RAILS_SECRET_TOKEN"] %>
diff --git a/db/migrate/20120903092956_devise_create_users.rb b/db/migrate/20120903092956_devise_create_users.rb
index 2dd95591c..cb9c47966 100644
--- a/db/migrate/20120903092956_devise_create_users.rb
+++ b/db/migrate/20120903092956_devise_create_users.rb
@@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
- t.string :email, :null => false, :default => ""
- t.string :encrypted_password, :null => false, :default => ""
+ t.string :email, null: false, default: ""
+ t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
@@ -13,7 +13,7 @@ class DeviseCreateUsers < ActiveRecord::Migration
t.datetime :remember_created_at
## Trackable
- t.integer :sign_in_count, :default => 0
+ t.integer :sign_in_count, default: 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
@@ -26,7 +26,7 @@ class DeviseCreateUsers < ActiveRecord::Migration
t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
- t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+ t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts
t.string :unlock_token # Only if unlock strategy is :email or :both
t.datetime :locked_at
@@ -37,10 +37,10 @@ class DeviseCreateUsers < ActiveRecord::Migration
t.timestamps
end
- add_index :users, :email, :unique => true
- add_index :users, :reset_password_token, :unique => true
- add_index :users, :confirmation_token, :unique => true
- add_index :users, :unlock_token, :unique => true
+ add_index :users, :email, unique: true
+ add_index :users, :reset_password_token, unique: true
+ add_index :users, :confirmation_token, unique: true
+ add_index :users, :unlock_token, unique: true
# add_index :users, :authentication_token, :unique => true
end
end
diff --git a/db/migrate/20121003190731_require_system_name_for_crops.rb b/db/migrate/20121003190731_require_system_name_for_crops.rb
index 47a46ec26..f4536c18b 100644
--- a/db/migrate/20121003190731_require_system_name_for_crops.rb
+++ b/db/migrate/20121003190731_require_system_name_for_crops.rb
@@ -2,13 +2,13 @@ class RequireSystemNameForCrops < ActiveRecord::Migration
def up
change_table :crops do |t|
t.index :system_name
- t.change :system_name, :string, :null => false
+ t.change :system_name, :string, null: false
end
end
def down
change_table :crops do |t|
- t.change :system_name, :string, :null => true
+ t.change :system_name, :string, null: true
t.remove_index :system_name
end
end
diff --git a/db/migrate/20121105032913_create_gardens.rb b/db/migrate/20121105032913_create_gardens.rb
index eaa7715d6..373179c26 100644
--- a/db/migrate/20121105032913_create_gardens.rb
+++ b/db/migrate/20121105032913_create_gardens.rb
@@ -1,9 +1,9 @@
class CreateGardens < ActiveRecord::Migration
def change
create_table :gardens do |t|
- t.string :name, :null => false
+ t.string :name, null: false
t.integer :user_id
- t.string :slug, :null => false
+ t.string :slug, null: false
t.timestamps
end
diff --git a/db/migrate/20121107012827_create_scientific_names.rb b/db/migrate/20121107012827_create_scientific_names.rb
index 4651a5b91..36140e27a 100644
--- a/db/migrate/20121107012827_create_scientific_names.rb
+++ b/db/migrate/20121107012827_create_scientific_names.rb
@@ -1,8 +1,8 @@
class CreateScientificNames < ActiveRecord::Migration
def change
create_table :scientific_names do |t|
- t.string :scientific_name, :null => false
- t.integer :crop_id, :null => false
+ t.string :scientific_name, null: false
+ t.integer :crop_id, null: false
t.timestamps
end
diff --git a/db/migrate/20121108105440_create_updates.rb b/db/migrate/20121108105440_create_updates.rb
index fa96f17a5..a2b29ed03 100644
--- a/db/migrate/20121108105440_create_updates.rb
+++ b/db/migrate/20121108105440_create_updates.rb
@@ -1,9 +1,9 @@
class CreateUpdates < ActiveRecord::Migration
def change
create_table :updates do |t|
- t.integer :user_id, :null => false
- t.string :subject, :null => false
- t.text :body, :null => false
+ t.integer :user_id, null: false
+ t.string :subject, null: false
+ t.text :body, null: false
t.timestamps
end
diff --git a/db/migrate/20121219022554_create_plantings.rb b/db/migrate/20121219022554_create_plantings.rb
index 2c50a7813..7fe96782e 100644
--- a/db/migrate/20121219022554_create_plantings.rb
+++ b/db/migrate/20121219022554_create_plantings.rb
@@ -1,8 +1,8 @@
class CreatePlantings < ActiveRecord::Migration
def change
create_table :plantings do |t|
- t.integer :garden_id, :null => false
- t.integer :crop_id, :null => false
+ t.integer :garden_id, null: false
+ t.integer :crop_id, null: false
t.datetime :planted_at
t.integer :quantity
t.text :description
diff --git a/db/migrate/20130208034248_require_fields_for_comments.rb b/db/migrate/20130208034248_require_fields_for_comments.rb
index c1adea261..ecb17f302 100644
--- a/db/migrate/20130208034248_require_fields_for_comments.rb
+++ b/db/migrate/20130208034248_require_fields_for_comments.rb
@@ -1,17 +1,17 @@
class RequireFieldsForComments < ActiveRecord::Migration
def up
change_table :comments do |t|
- t.change :post_id, :integer, :null => false
- t.change :author_id, :integer, :null => false
- t.change :body, :text, :null => false
+ t.change :post_id, :integer, null: false
+ t.change :author_id, :integer, null: false
+ t.change :body, :text, null: false
end
end
def down
change_table :comments do |t|
- t.change :post_id, :integer, :null => true
- t.change :author_id, :integer, :null => true
- t.change :body, :text, :null => true
+ t.change :post_id, :integer, null: true
+ t.change :author_id, :integer, null: true
+ t.change :body, :text, null: true
end
end
end
diff --git a/db/migrate/20130212123628_create_notifications.rb b/db/migrate/20130212123628_create_notifications.rb
index 0bb5e1bec..03ca126a8 100644
--- a/db/migrate/20130212123628_create_notifications.rb
+++ b/db/migrate/20130212123628_create_notifications.rb
@@ -2,7 +2,7 @@ class CreateNotifications < ActiveRecord::Migration
def change
create_table :notifications do |t|
t.integer :from_id
- t.integer :to_id, :null => false
+ t.integer :to_id, null: false
t.string :subject
t.text :body
t.boolean :read
diff --git a/db/migrate/20130213014511_create_forums.rb b/db/migrate/20130213014511_create_forums.rb
index 6388876e6..1969b09dc 100644
--- a/db/migrate/20130213014511_create_forums.rb
+++ b/db/migrate/20130213014511_create_forums.rb
@@ -1,9 +1,9 @@
class CreateForums < ActiveRecord::Migration
def change
create_table :forums do |t|
- t.string :name, :null => false
- t.text :description, :null => false
- t.integer :owner_id, :null => false
+ t.string :name, null: false
+ t.text :description, null: false
+ t.integer :owner_id, null: false
t.timestamps
end
diff --git a/db/migrate/20130214024117_create_roles.rb b/db/migrate/20130214024117_create_roles.rb
index 8ccaf5ca6..8797691d5 100644
--- a/db/migrate/20130214024117_create_roles.rb
+++ b/db/migrate/20130214024117_create_roles.rb
@@ -1,7 +1,7 @@
class CreateRoles < ActiveRecord::Migration
def change
create_table :roles do |t|
- t.string :name, :null => false
+ t.string :name, null: false
t.text :description
t.timestamps
diff --git a/db/migrate/20130214034838_add_members_roles_table.rb b/db/migrate/20130214034838_add_members_roles_table.rb
index a8044ebc8..9e84fd37d 100644
--- a/db/migrate/20130214034838_add_members_roles_table.rb
+++ b/db/migrate/20130214034838_add_members_roles_table.rb
@@ -1,6 +1,6 @@
class AddMembersRolesTable < ActiveRecord::Migration
def change
- create_table :members_roles, :id => false do |t|
+ create_table :members_roles, id: false do |t|
t.integer :member_id
t.integer :role_id
end
diff --git a/db/migrate/20130222060730_default_read_to_false.rb b/db/migrate/20130222060730_default_read_to_false.rb
index b7250b8c6..efe6d4b61 100644
--- a/db/migrate/20130222060730_default_read_to_false.rb
+++ b/db/migrate/20130222060730_default_read_to_false.rb
@@ -1,13 +1,13 @@
class DefaultReadToFalse < ActiveRecord::Migration
def up
change_table :notifications do |t|
- t.change :read, :boolean, :default => false
+ t.change :read, :boolean, default: false
end
end
def down
change_table :notifications do |t|
- t.change :read, :boolean, :default => nil
+ t.change :read, :boolean, default: nil
end
end
end
diff --git a/db/migrate/20130327120024_add_send_email_to_member.rb b/db/migrate/20130327120024_add_send_email_to_member.rb
index b52c5fdb2..b83dd9e03 100644
--- a/db/migrate/20130327120024_add_send_email_to_member.rb
+++ b/db/migrate/20130327120024_add_send_email_to_member.rb
@@ -1,5 +1,5 @@
class AddSendEmailToMember < ActiveRecord::Migration
def change
- add_column :members, :send_notification_email, :boolean, :default => true
+ add_column :members, :send_notification_email, :boolean, default: true
end
end
diff --git a/db/migrate/20130404174459_create_authentications.rb b/db/migrate/20130404174459_create_authentications.rb
index 3acdf6080..aeeb109da 100644
--- a/db/migrate/20130404174459_create_authentications.rb
+++ b/db/migrate/20130404174459_create_authentications.rb
@@ -1,8 +1,8 @@
class CreateAuthentications < ActiveRecord::Migration
def change
create_table :authentications do |t|
- t.integer :member_id, :null => false
- t.string :provider, :null => false
+ t.integer :member_id, null: false
+ t.string :provider, null: false
t.string :uid
t.string :token
t.string :secret
diff --git a/db/migrate/20130409103549_make_post_subject_non_null.rb b/db/migrate/20130409103549_make_post_subject_non_null.rb
index 0a7f8db34..877bd048f 100644
--- a/db/migrate/20130409103549_make_post_subject_non_null.rb
+++ b/db/migrate/20130409103549_make_post_subject_non_null.rb
@@ -1,3 +1,3 @@
class MakePostSubjectNonNull < ActiveRecord::Migration
- change_column :posts, :subject, :string, :null => false
+ change_column :posts, :subject, :string, null: false
end
diff --git a/db/migrate/20130507105357_create_products.rb b/db/migrate/20130507105357_create_products.rb
index 0ad9b1063..8e8901293 100644
--- a/db/migrate/20130507105357_create_products.rb
+++ b/db/migrate/20130507105357_create_products.rb
@@ -1,9 +1,9 @@
class CreateProducts < ActiveRecord::Migration
def change
create_table :products do |t|
- t.string :name, :null => false
- t.string :description, :null => false
- t.decimal :min_price, :null => false
+ t.string :name, null: false
+ t.string :description, null: false
+ t.decimal :min_price, null: false
t.timestamps
end
diff --git a/db/migrate/20130507110411_create_orders.rb b/db/migrate/20130507110411_create_orders.rb
index 0aed92dfb..7cde95ad2 100644
--- a/db/migrate/20130507110411_create_orders.rb
+++ b/db/migrate/20130507110411_create_orders.rb
@@ -1,7 +1,7 @@
class CreateOrders < ActiveRecord::Migration
def change
create_table :orders do |t|
- t.string :member_id, :null => false
+ t.string :member_id, null: false
t.timestamps
end
diff --git a/db/migrate/20130507113915_add_orders_products_table.rb b/db/migrate/20130507113915_add_orders_products_table.rb
index 92af21427..8666e01ab 100644
--- a/db/migrate/20130507113915_add_orders_products_table.rb
+++ b/db/migrate/20130507113915_add_orders_products_table.rb
@@ -1,6 +1,6 @@
class AddOrdersProductsTable < ActiveRecord::Migration
def change
- create_table :orders_products, :id => false do |t|
+ create_table :orders_products, id: false do |t|
t.integer :order_id
t.integer :product_id
end
diff --git a/db/migrate/20130508104506_create_photos.rb b/db/migrate/20130508104506_create_photos.rb
index f7c56188d..f6c908529 100644
--- a/db/migrate/20130508104506_create_photos.rb
+++ b/db/migrate/20130508104506_create_photos.rb
@@ -1,10 +1,10 @@
class CreatePhotos < ActiveRecord::Migration
def change
create_table :photos do |t|
- t.integer :owner_id, :null => false
- t.integer :flickr_photo_id, :null => false
- t.string :thumbnail_url, :null => false
- t.string :fullsize_url, :null => false
+ t.integer :owner_id, null: false
+ t.integer :flickr_photo_id, null: false
+ t.string :thumbnail_url, null: false
+ t.string :fullsize_url, null: false
t.timestamps
end
diff --git a/db/migrate/20130509123711_add_metadata_to_photos.rb b/db/migrate/20130509123711_add_metadata_to_photos.rb
index 9e73a6272..cb76a901a 100644
--- a/db/migrate/20130509123711_add_metadata_to_photos.rb
+++ b/db/migrate/20130509123711_add_metadata_to_photos.rb
@@ -5,9 +5,9 @@ class AddMetadataToPhotos < ActiveRecord::Migration
t.string :license_name
t.string :license_url
t.string :link_url
- t.change :title, :string, :null => false
- t.change :license_name, :string, :null => false
- t.change :link_url, :string, :null => false
+ t.change :title, :string, null: false
+ t.change :license_name, :string, null: false
+ t.change :link_url, :string, null: false
end
end
diff --git a/db/migrate/20130517015920_create_account_details.rb b/db/migrate/20130517015920_create_account_details.rb
index 8eb899fd5..99f4c4eb8 100644
--- a/db/migrate/20130517015920_create_account_details.rb
+++ b/db/migrate/20130517015920_create_account_details.rb
@@ -1,7 +1,7 @@
class CreateAccountDetails < ActiveRecord::Migration
def change
create_table :account_details do |t|
- t.integer :member_id, :null => false
+ t.integer :member_id, null: false
t.integer :account_type_id
t.datetime :paid_until
diff --git a/db/migrate/20130517234458_require_account_type_name.rb b/db/migrate/20130517234458_require_account_type_name.rb
index c4bdfa69a..6e745cb4b 100644
--- a/db/migrate/20130517234458_require_account_type_name.rb
+++ b/db/migrate/20130517234458_require_account_type_name.rb
@@ -1,9 +1,9 @@
class RequireAccountTypeName < ActiveRecord::Migration
def up
- change_column :account_types, :name, :string, :null => false
+ change_column :account_types, :name, :string, null: false
end
def down
- change_column :account_types, :name, :string, :null => true
+ change_column :account_types, :name, :string, null: true
end
end
diff --git a/db/migrate/20130531110729_add_photos_plantings_table.rb b/db/migrate/20130531110729_add_photos_plantings_table.rb
index 07040ed93..ab08ff0d1 100644
--- a/db/migrate/20130531110729_add_photos_plantings_table.rb
+++ b/db/migrate/20130531110729_add_photos_plantings_table.rb
@@ -1,6 +1,6 @@
class AddPhotosPlantingsTable < ActiveRecord::Migration
def change
- create_table :photos_plantings, :id => false do |t|
+ create_table :photos_plantings, id: false do |t|
t.integer :photo_id
t.integer :planting_id
end
diff --git a/db/migrate/20130715110134_create_seeds.rb b/db/migrate/20130715110134_create_seeds.rb
index 1d0d49225..d5ece87ec 100644
--- a/db/migrate/20130715110134_create_seeds.rb
+++ b/db/migrate/20130715110134_create_seeds.rb
@@ -1,8 +1,8 @@
class CreateSeeds < ActiveRecord::Migration
def change
create_table :seeds do |t|
- t.integer :owner_id, :null => false
- t.integer :crop_id, :null => false
+ t.integer :owner_id, null: false
+ t.integer :crop_id, null: false
t.text :description
t.integer :quantity
t.date :use_by
diff --git a/db/migrate/20130917053547_create_harvests.rb b/db/migrate/20130917053547_create_harvests.rb
index e7b7db6b4..8a808ac1a 100644
--- a/db/migrate/20130917053547_create_harvests.rb
+++ b/db/migrate/20130917053547_create_harvests.rb
@@ -1,8 +1,8 @@
class CreateHarvests < ActiveRecord::Migration
def change
create_table :harvests do |t|
- t.integer :crop_id, :null => false
- t.integer :owner_id, :null => false
+ t.integer :crop_id, null: false
+ t.integer :owner_id, null: false
t.date :harvested_at
t.decimal :quantity
t.string :units
diff --git a/db/migrate/20131025104228_add_fields_to_gardens.rb b/db/migrate/20131025104228_add_fields_to_gardens.rb
index 24b73c966..2c3983507 100644
--- a/db/migrate/20131025104228_add_fields_to_gardens.rb
+++ b/db/migrate/20131025104228_add_fields_to_gardens.rb
@@ -1,6 +1,6 @@
class AddFieldsToGardens < ActiveRecord::Migration
def change
- add_column :gardens, :active, :boolean, :default => true
+ add_column :gardens, :active, :boolean, default: true
add_column :gardens, :location, :string
add_column :gardens, :latitude, :float
add_column :gardens, :longitude, :float
diff --git a/db/migrate/20140718075753_default_plantings_count_to_zero.rb b/db/migrate/20140718075753_default_plantings_count_to_zero.rb
index 608821fbc..ce8d0d075 100644
--- a/db/migrate/20140718075753_default_plantings_count_to_zero.rb
+++ b/db/migrate/20140718075753_default_plantings_count_to_zero.rb
@@ -1,9 +1,9 @@
class DefaultPlantingsCountToZero < ActiveRecord::Migration
def up
- change_column :crops, :plantings_count, :integer, :default => 0
+ change_column :crops, :plantings_count, :integer, default: 0
end
def down
- change_column :crops, :plantings_count, :integer, :default => nil
+ change_column :crops, :plantings_count, :integer, default: nil
end
end
diff --git a/db/migrate/20140829230600_add_finished_to_planting.rb b/db/migrate/20140829230600_add_finished_to_planting.rb
index 8be30756a..f8cb41663 100644
--- a/db/migrate/20140829230600_add_finished_to_planting.rb
+++ b/db/migrate/20140829230600_add_finished_to_planting.rb
@@ -1,6 +1,6 @@
class AddFinishedToPlanting < ActiveRecord::Migration
def change
- add_column :plantings, :finished, :boolean, :default => false
+ add_column :plantings, :finished, :boolean, default: false
add_column :plantings, :finished_at, :date
end
end
diff --git a/db/migrate/20140905001730_add_harvests_photos_table.rb b/db/migrate/20140905001730_add_harvests_photos_table.rb
index edacd061b..fb9c73a37 100644
--- a/db/migrate/20140905001730_add_harvests_photos_table.rb
+++ b/db/migrate/20140905001730_add_harvests_photos_table.rb
@@ -1,6 +1,6 @@
class AddHarvestsPhotosTable < ActiveRecord::Migration
def change
- create_table :harvests_photos, :id => false do |t|
+ create_table :harvests_photos, id: false do |t|
t.integer :photo_id
t.integer :harvest_id
end
diff --git a/db/migrate/20140928044231_add_crops_posts_table.rb b/db/migrate/20140928044231_add_crops_posts_table.rb
index a8c06927b..6f200c3d8 100644
--- a/db/migrate/20140928044231_add_crops_posts_table.rb
+++ b/db/migrate/20140928044231_add_crops_posts_table.rb
@@ -1,6 +1,6 @@
class AddCropsPostsTable < ActiveRecord::Migration
def change
- create_table :crops_posts, :id => false do |t|
+ create_table :crops_posts, id: false do |t|
t.integer :crop_id
t.integer :post_id
end
diff --git a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb
index e6a5ec214..67c7184d7 100644
--- a/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb
+++ b/db/migrate/20140928085713_add_send_planting_reminder_to_member.rb
@@ -1,5 +1,5 @@
class AddSendPlantingReminderToMember < ActiveRecord::Migration
def change
- add_column :members, :send_planting_reminder, :boolean, :default => true
+ add_column :members, :send_planting_reminder, :boolean, default: true
end
end
diff --git a/db/migrate/20141018111015_create_alternate_names.rb b/db/migrate/20141018111015_create_alternate_names.rb
index 8a63471c8..7364fceb0 100644
--- a/db/migrate/20141018111015_create_alternate_names.rb
+++ b/db/migrate/20141018111015_create_alternate_names.rb
@@ -1,9 +1,9 @@
class CreateAlternateNames < ActiveRecord::Migration
def change
create_table :alternate_names do |t|
- t.string :name, :null => false
- t.integer :crop_id, :null => false
- t.integer :creator_id, :null => false
+ t.string :name, null: false
+ t.integer :crop_id, null: false
+ t.integer :creator_id, null: false
t.timestamps
end
diff --git a/db/migrate/20150124110540_add_properties_to_seeds.rb b/db/migrate/20150124110540_add_properties_to_seeds.rb
index e2fa64fe7..7d60735fd 100644
--- a/db/migrate/20150124110540_add_properties_to_seeds.rb
+++ b/db/migrate/20150124110540_add_properties_to_seeds.rb
@@ -2,8 +2,8 @@ class AddPropertiesToSeeds < ActiveRecord::Migration
def change
add_column :seeds, :days_until_maturity_min, :integer
add_column :seeds, :days_until_maturity_max, :integer
- add_column :seeds, :organic, :text, :default => 'unknown'
- add_column :seeds, :gmo, :text, :default => 'unknown'
- add_column :seeds, :heirloom, :text, :default => 'unknown'
+ add_column :seeds, :organic, :text, default: 'unknown'
+ add_column :seeds, :gmo, :text, default: 'unknown'
+ add_column :seeds, :heirloom, :text, default: 'unknown'
end
end
diff --git a/db/migrate/20150127043022_add_gardens_photos_table.rb b/db/migrate/20150127043022_add_gardens_photos_table.rb
index c0cfd76fc..7e8f8bd81 100644
--- a/db/migrate/20150127043022_add_gardens_photos_table.rb
+++ b/db/migrate/20150127043022_add_gardens_photos_table.rb
@@ -1,6 +1,6 @@
class AddGardensPhotosTable < ActiveRecord::Migration
def change
- create_table :gardens_photos, :id => false do |t|
+ create_table :gardens_photos, id: false do |t|
t.integer :photo_id
t.integer :garden_id
end
diff --git a/db/migrate/20150201052245_create_cms.rb b/db/migrate/20150201052245_create_cms.rb
index 9e999488f..0a29e2b6d 100644
--- a/db/migrate/20150201052245_create_cms.rb
+++ b/db/migrate/20150201052245_create_cms.rb
@@ -6,52 +6,52 @@ class CreateCms < ActiveRecord::Migration
when 'PostgreSQL'
{ }
else
- { :limit => 16777215 }
+ { limit: 16777215 }
end
# -- Sites --------------------------------------------------------------
create_table :comfy_cms_sites do |t|
- t.string :label, :null => false
- t.string :identifier, :null => false
- t.string :hostname, :null => false
+ t.string :label, null: false
+ t.string :identifier, null: false
+ t.string :hostname, null: false
t.string :path
- t.string :locale, :null => false, :default => 'en'
- t.boolean :is_mirrored, :null => false, :default => false
+ t.string :locale, null: false, default: 'en'
+ t.boolean :is_mirrored, null: false, default: false
end
add_index :comfy_cms_sites, :hostname
add_index :comfy_cms_sites, :is_mirrored
# -- Layouts ------------------------------------------------------------
create_table :comfy_cms_layouts do |t|
- t.integer :site_id, :null => false
+ t.integer :site_id, null: false
t.integer :parent_id
t.string :app_layout
- t.string :label, :null => false
- t.string :identifier, :null => false
+ t.string :label, null: false
+ t.string :identifier, null: false
t.text :content, text_limit
t.text :css, text_limit
t.text :js, text_limit
- t.integer :position, :null => false, :default => 0
- t.boolean :is_shared, :null => false, :default => false
+ t.integer :position, null: false, default: 0
+ t.boolean :is_shared, null: false, default: false
t.timestamps
end
add_index :comfy_cms_layouts, [:parent_id, :position]
- add_index :comfy_cms_layouts, [:site_id, :identifier], :unique => true
+ add_index :comfy_cms_layouts, [:site_id, :identifier], unique: true
# -- Pages --------------------------------------------------------------
create_table :comfy_cms_pages do |t|
- t.integer :site_id, :null => false
+ t.integer :site_id, null: false
t.integer :layout_id
t.integer :parent_id
t.integer :target_page_id
- t.string :label, :null => false
+ t.string :label, null: false
t.string :slug
- t.string :full_path, :null => false
+ t.string :full_path, null: false
t.text :content_cache, text_limit
- t.integer :position, :null => false, :default => 0
- t.integer :children_count, :null => false, :default => 0
- t.boolean :is_published, :null => false, :default => true
- t.boolean :is_shared, :null => false, :default => false
+ t.integer :position, null: false, default: 0
+ t.integer :children_count, null: false, default: 0
+ t.boolean :is_published, null: false, default: true
+ t.boolean :is_shared, null: false, default: false
t.timestamps
end
add_index :comfy_cms_pages, [:site_id, :full_path]
@@ -59,9 +59,9 @@ class CreateCms < ActiveRecord::Migration
# -- Page Blocks --------------------------------------------------------
create_table :comfy_cms_blocks do |t|
- t.string :identifier, :null => false
+ t.string :identifier, null: false
t.text :content, text_limit
- t.references :blockable, :polymorphic => true
+ t.references :blockable, polymorphic: true
t.timestamps
end
add_index :comfy_cms_blocks, [:identifier]
@@ -69,27 +69,27 @@ class CreateCms < ActiveRecord::Migration
# -- Snippets -----------------------------------------------------------
create_table :comfy_cms_snippets do |t|
- t.integer :site_id, :null => false
- t.string :label, :null => false
- t.string :identifier, :null => false
+ t.integer :site_id, null: false
+ t.string :label, null: false
+ t.string :identifier, null: false
t.text :content, text_limit
- t.integer :position, :null => false, :default => 0
- t.boolean :is_shared, :null => false, :default => false
+ t.integer :position, null: false, default: 0
+ t.boolean :is_shared, null: false, default: false
t.timestamps
end
- add_index :comfy_cms_snippets, [:site_id, :identifier], :unique => true
+ add_index :comfy_cms_snippets, [:site_id, :identifier], unique: true
add_index :comfy_cms_snippets, [:site_id, :position]
# -- Files --------------------------------------------------------------
create_table :comfy_cms_files do |t|
- t.integer :site_id, :null => false
+ t.integer :site_id, null: false
t.integer :block_id
- t.string :label, :null => false
- t.string :file_file_name, :null => false
- t.string :file_content_type, :null => false
- t.integer :file_file_size, :null => false
- t.string :description, :limit => 2048
- t.integer :position, :null => false, :default => 0
+ t.string :label, null: false
+ t.string :file_file_name, null: false
+ t.string :file_content_type, null: false
+ t.integer :file_file_size, null: false
+ t.string :description, limit: 2048
+ t.integer :position, null: false, default: 0
t.timestamps
end
add_index :comfy_cms_files, [:site_id, :label]
@@ -98,31 +98,31 @@ class CreateCms < ActiveRecord::Migration
add_index :comfy_cms_files, [:site_id, :block_id]
# -- Revisions -----------------------------------------------------------
- create_table :comfy_cms_revisions, :force => true do |t|
- t.string :record_type, :null => false
- t.integer :record_id, :null => false
+ create_table :comfy_cms_revisions, force: true do |t|
+ t.string :record_type, null: false
+ t.integer :record_id, null: false
t.text :data, text_limit
t.datetime :created_at
end
add_index :comfy_cms_revisions, [:record_type, :record_id, :created_at],
- :name => 'index_cms_revisions_on_rtype_and_rid_and_created_at'
+ name: 'index_cms_revisions_on_rtype_and_rid_and_created_at'
# -- Categories ---------------------------------------------------------
- create_table :comfy_cms_categories, :force => true do |t|
- t.integer :site_id, :null => false
- t.string :label, :null => false
- t.string :categorized_type, :null => false
+ create_table :comfy_cms_categories, force: true do |t|
+ t.integer :site_id, null: false
+ t.string :label, null: false
+ t.string :categorized_type, null: false
end
- add_index :comfy_cms_categories, [:site_id, :categorized_type, :label], :unique => true,
- :name => 'index_cms_categories_on_site_id_and_cat_type_and_label'
+ add_index :comfy_cms_categories, [:site_id, :categorized_type, :label], unique: true,
+ name: 'index_cms_categories_on_site_id_and_cat_type_and_label'
- create_table :comfy_cms_categorizations, :force => true do |t|
- t.integer :category_id, :null => false
- t.string :categorized_type, :null => false
- t.integer :categorized_id, :null => false
+ create_table :comfy_cms_categorizations, force: true do |t|
+ t.integer :category_id, null: false
+ t.string :categorized_type, null: false
+ t.integer :categorized_id, null: false
end
- add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], :unique => true,
- :name => 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
+ add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], unique: true,
+ name: 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
end
def self.down
diff --git a/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb
new file mode 100644
index 000000000..0ddf5acb5
--- /dev/null
+++ b/db/migrate/20150625224805_add_days_before_maturity_to_plantings.rb
@@ -0,0 +1,5 @@
+class AddDaysBeforeMaturityToPlantings < ActiveRecord::Migration
+ def change
+ add_column :plantings, :days_before_maturity, :integer
+ end
+end
diff --git a/db/migrate/20150824145414_add_member_preferred_image.rb b/db/migrate/20150824145414_add_member_preferred_image.rb
new file mode 100644
index 000000000..dc24bd5a0
--- /dev/null
+++ b/db/migrate/20150824145414_add_member_preferred_image.rb
@@ -0,0 +1,5 @@
+class AddMemberPreferredImage < ActiveRecord::Migration
+ def change
+ add_column :members, :preferred_avatar_uri, :string
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index b22cfbab4..669bf45da 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,8 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-
-ActiveRecord::Schema.define(version: 20150209105410) do
+ActiveRecord::Schema.define(version: 20150824145414) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -320,6 +319,7 @@ ActiveRecord::Schema.define(version: 20150209105410) do
t.integer "plantings_count"
t.boolean "newsletter"
t.boolean "send_planting_reminder", default: true
+ t.string "preferred_avatar_uri"
end
add_index "members", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
@@ -394,8 +394,8 @@ ActiveRecord::Schema.define(version: 20150209105410) do
end
create_table "plantings", force: true do |t|
- t.integer "garden_id", null: false
- t.integer "crop_id", null: false
+ t.integer "garden_id", null: false
+ t.integer "crop_id", null: false
t.date "planted_at"
t.integer "quantity"
t.text "description"
@@ -405,8 +405,9 @@ ActiveRecord::Schema.define(version: 20150209105410) do
t.string "sunniness"
t.string "planted_from"
t.integer "owner_id"
- t.boolean "finished", default: false
+ t.boolean "finished", default: false
t.date "finished_at"
+ t.integer "days_before_maturity"
end
add_index "plantings", ["slug"], name: "index_plantings_on_slug", unique: true, using: :btree
@@ -419,7 +420,6 @@ ActiveRecord::Schema.define(version: 20150209105410) do
t.datetime "updated_at", null: false
t.string "slug"
t.integer "forum_id"
- t.integer "parent_id"
end
add_index "posts", ["created_at", "author_id"], name: "index_updates_on_created_at_and_user_id", using: :btree
@@ -460,15 +460,9 @@ ActiveRecord::Schema.define(version: 20150209105410) do
t.text "description"
t.integer "quantity"
t.date "plant_before"
-<<<<<<< HEAD
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
- t.string "tradable_to", default: "nowhere"
-=======
- t.datetime "created_at"
- t.datetime "updated_at"
t.string "tradable_to", default: "nowhere"
->>>>>>> dev
t.string "slug"
t.integer "days_until_maturity_min"
t.integer "days_until_maturity_max"
diff --git a/db/seeds.rb b/db/seeds.rb
index 3fdd6226e..f1b8d67cb 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -39,71 +39,107 @@ end
def load_roles
puts "Creating admin role..."
- @admin = Role.create(:name => 'Admin')
+ @admin = Role.create(name: 'Admin')
puts "Creating crop wrangler role..."
- @wrangler = Role.create(:name => 'Crop Wrangler')
+ @wrangler = Role.create(name: 'Crop Wrangler')
end
def load_basic_account_types
puts "Adding 'free' and 'staff' account types..."
AccountType.create!(
- :name => "Free",
- :is_paid => false,
- :is_permanent_paid => false
+ name: "Free",
+ is_paid: false,
+ is_permanent_paid: false
)
AccountType.create!(
- :name => "Staff",
- :is_paid => true,
- :is_permanent_paid => true
+ name: "Staff",
+ is_paid: true,
+ is_permanent_paid: true
)
end
def load_test_users
puts "Loading test users..."
- (1..3).each do |i|
- @user = Member.create(
- :login_name => "test#{i}",
- :email => "test#{i}@example.com",
- :password => "password#{i}",
- :tos_agreement => true
- )
- @user.confirm!
- @user.save!
+
+ # Open suburb csv
+ source_path = Rails.root.join('db', 'seeds')
+ begin
+ suburb_file = File.open("#{source_path}/suburbs.csv")
+ rescue
+ puts "Warning: unable to open suburbs.csv"
end
+
+
+ # rake parameter (eg. 'rake db:seed member_size=10')
+ member_size = ENV['member_size'] ? ENV['member_size'].to_i : 3
+
+ (1..member_size).each do |i|
+ @user = Member.new(
+ login_name: "test#{i}",
+ email: "test#{i}@example.com",
+ password: "password#{i}",
+ tos_agreement: true
+ )
+ @user.skip_confirmation!
+ @user.save!
+
+ # Populate member location and garden location
+ if suburb_file
+ suburb_file.pos = 0 if suburb_file.eof?
+ row = CSV.parse(suburb_file.readline)
+
+ suburb,country,state,latitude,longitude = row[0]
+ # Using 'update_column' method instead of 'update' so that
+ # it avoids accessing Geocoding service for faster processing
+ @user.gardens.first.update_columns(location: suburb, latitude: latitude, longitude: longitude)
+ @user.update_columns(location: suburb, latitude: latitude, longitude: longitude)
+ end
+
+ # Create a planting by the member
+ Planting.create(
+ owner_id: @user.id,
+ garden_id: @user.gardens.first.id,
+ planted_at: Date.today,
+ crop_id: Crop.find(i % Crop.all.size + 1).id,
+ sunniness: select_random_item(Planting::SUNNINESS_VALUES),
+ planted_from: select_random_item(Planting::PLANTED_FROM_VALUES)
+ )
+ end
+
puts "Finished loading test users"
end
def load_admin_users
puts "Adding admin and crop wrangler members..."
- @admin_user = Member.create(
- :login_name => "admin1",
- :email => "admin1@example.com",
- :password => "password1",
- :tos_agreement => true
+ @admin_user = Member.new(
+ login_name: "admin1",
+ email: "admin1@example.com",
+ password: "password1",
+ tos_agreement: true
)
- @admin_user.confirm!
+ @admin_user.skip_confirmation!
@admin_user.roles << @admin
@admin_user.save!
- @wrangler_user = Member.create(
- :login_name => "wrangler1",
- :email => "wrangler1@example.com",
- :password => "password1",
- :tos_agreement => true
+ @wrangler_user = Member.new(
+ login_name: "wrangler1",
+ email: "wrangler1@example.com",
+ password: "password1",
+ tos_agreement: true
)
- @wrangler_user.confirm!
+ @wrangler_user.skip_confirmation!
@wrangler_user.roles << @wrangler
@wrangler_user.save!
end
def create_cropbot
- @cropbot_user = Member.create(
- :login_name => "cropbot",
- :email => Growstuff::Application.config.bot_email,
- :password => SecureRandom.urlsafe_base64(64),
- :tos_agreement => true
+ @cropbot_user = Member.new(
+ login_name: "cropbot",
+ email: Growstuff::Application.config.bot_email,
+ password: SecureRandom.urlsafe_base64(64),
+ tos_agreement: true
)
- @cropbot_user.confirm!
+ @cropbot_user.skip_confirmation!
@cropbot_user.roles << @wrangler
@cropbot_user.save!
@cropbot_user.account.account_type = AccountType.find_by_name("Staff")
@@ -113,31 +149,31 @@ end
def load_paid_account_types
puts "Adding 'paid' and 'seed' account types..."
@paid_account = AccountType.create!(
- :name => "Paid",
- :is_paid => true,
- :is_permanent_paid => false
+ name: "Paid",
+ is_paid: true,
+ is_permanent_paid: false
)
@seed_account = AccountType.create!(
- :name => "Seed",
- :is_paid => true,
- :is_permanent_paid => true
+ name: "Seed",
+ is_paid: true,
+ is_permanent_paid: true
)
end
def load_products
puts "Adding products..."
Product.create!(
- :name => "Annual subscription",
- :description => "Paid account, 1 year",
- :min_price => 3000,
- :account_type_id => @paid_account.id,
- :paid_months => 12
+ name: "Annual subscription",
+ description: "Paid account, 1 year",
+ min_price: 3000,
+ account_type_id: @paid_account.id,
+ paid_months: 12
)
Product.create!(
- :name => "Seed account",
- :description => "Paid account, in perpetuity",
- :min_price => 15000,
- :account_type_id => @seed_account.id,
+ name: "Seed account",
+ description: "Paid account, in perpetuity",
+ min_price: 15000,
+ account_type_id: @seed_account.id,
)
end
@@ -162,6 +198,8 @@ def load_plant_parts
end
end
-
+def select_random_item(array)
+ array[rand(0..array.size-1) % array.size]
+end
load_data
diff --git a/db/seeds/suburbs.csv b/db/seeds/suburbs.csv
new file mode 100644
index 000000000..461f33a24
--- /dev/null
+++ b/db/seeds/suburbs.csv
@@ -0,0 +1,570 @@
+Downer,Australian Capital Territory,ACT,-35.244,149.1435
+O'Connor,Australian Capital Territory,ACT,-35.2564,149.1125
+Watson,Australian Capital Territory,ACT,-35.2347,149.1594
+Dickson,Australian Capital Territory,ACT,-35.2528,149.1417
+Lyneham,Australian Capital Territory,ACT,-35.2398,149.1307
+Hackett,Australian Capital Territory,ACT,-35.2495,149.1635
+Ainslie,Australian Capital Territory,ACT,-35.2622,149.1478
+Red Hill,Australian Capital Territory,ACT,-35.3334,149.1206
+Griffith,Australian Capital Territory,ACT,-35.3253,149.1371
+Forrest,Australian Capital Territory,ACT,-35.315,149.1286
+Manuka,Australian Capital Territory,ACT,-35.3126,149.1278
+Kingston,Australian Capital Territory,ACT,-35.3152,149.1466
+Narrabundah,Australian Capital Territory,ACT,-35.3357,149.1492
+Causeway,Australian Capital Territory,ACT,-35.3126,149.1278
+Garran,Australian Capital Territory,ACT,-35.331,149.0899
+Hughes,Australian Capital Territory,ACT,-35.3327,149.0949
+Curtin,Australian Capital Territory,ACT,-35.3246,149.0776
+Lyons,Australian Capital Territory,ACT,-35.3406,149.074
+Woden,Australian Capital Territory,ACT,-35.3481,149.0905
+O'Malley,Australian Capital Territory,ACT,-35.3525,149.1128
+Phillip,Australian Capital Territory,ACT,-35.3503,149.0915
+Swinger Hill,Australian Capital Territory,ACT,-35.3481,149.0905
+Chifley,Australian Capital Territory,ACT,-35.3534,149.0768
+Farrer,Australian Capital Territory,ACT,-35.3767,149.105
+Isaacs,Australian Capital Territory,ACT,-35.3686,149.1156
+Torrens,Australian Capital Territory,ACT,-35.372,149.0877
+Pearce,Australian Capital Territory,ACT,-35.3622,149.0834
+Mawson,Australian Capital Territory,ACT,-35.3634,149.0986
+Civic Square,Australian Capital Territory,ACT,-35.31,149.1933
+Pialligo,Australian Capital Territory,ACT,-35.3043,149.1792
+Fyshwick,Australian Capital Territory,ACT,-35.3333,149.1667
+Canberra Airport,Australian Capital Territory,ACT,-35.3172,149.1753
+Symonston,Australian Capital Territory,ACT,-35.3516,149.1592
+Majura,Australian Capital Territory,ACT,-35.2667,149.2
+Canberra Bc,Australian Capital Territory,ACT,-35.2778,149.0111
+Canberra Mc,Australian Capital Territory,ACT,-35.2498,149.0591
+Wright,Australian Capital Territory,ACT,-35.3503,149.0155
+Coombs,Australian Capital Territory,ACT,-35.3503,149.0155
+Rivett,Australian Capital Territory,ACT,-35.3471,149.0379
+Stromlo,Australian Capital Territory,ACT,-35.3503,149.0155
+Duffy,Australian Capital Territory,ACT,-35.3346,149.0319
+Coree,Australian Capital Territory,ACT,-35.3503,149.0155
+Chapman,Australian Capital Territory,ACT,-35.3562,149.0374
+Uriarra Village,Australian Capital Territory,ACT,-35.3503,149.0155
+Waramanga,Australian Capital Territory,ACT,-35.353,149.0621
+Weston Creek,Australian Capital Territory,ACT,-35.4171,148.7769
+Uriarra,Australian Capital Territory,ACT,-35.4171,148.7769
+Weston,Australian Capital Territory,ACT,-35.4171,148.7769
+Fisher,Australian Capital Territory,ACT,-35.4171,148.7769
+Stirling,Australian Capital Territory,ACT,-35.4171,148.7769
+Holder,Australian Capital Territory,ACT,-35.4171,148.7769
+Mount Stromlo,Australian Capital Territory,ACT,-35.4171,148.7769
+Braddon,Australian Capital Territory,ACT,-35.2708,149.1357
+Campbell,Australian Capital Territory,ACT,-35.2891,149.1538
+Turner,Australian Capital Territory,ACT,-35.2688,149.1247
+Reid,Australian Capital Territory,ACT,-35.2858,149.1391
+Scullin,Australian Capital Territory,ACT,-35.2346,149.039
+Aranda,Australian Capital Territory,ACT,-35.2582,149.0804
+Cook,Australian Capital Territory,ACT,-35.2601,149.0657
+Jamison Centre,Australian Capital Territory,ACT,-35.2498,149.0591
+Macquarie,Australian Capital Territory,ACT,-35.2513,149.0636
+Hawker,Australian Capital Territory,ACT,-35.2471,149.0367
+Page,Australian Capital Territory,ACT,-35.2386,149.0499
+Weetangera,Australian Capital Territory,ACT,-35.2498,149.0591
+Melba,Australian Capital Territory,ACT,-35.2102,149.0541
+Spence,Australian Capital Territory,ACT,-35.2101,149.034
+Higgins,Australian Capital Territory,ACT,-35.2324,149.0272
+Holt,Australian Capital Territory,ACT,-35.2244,149.0119
+Latham,Australian Capital Territory,ACT,-35.2165,149.0314
+Kippax Centre,Australian Capital Territory,ACT,-35.2101,149.034
+Flynn,Australian Capital Territory,ACT,-35.2059,149.0439
+Florey,Australian Capital Territory,ACT,-35.2259,149.05
+Fraser,Australian Capital Territory,ACT,-35.1917,149.0453
+Kippax,Australian Capital Territory,ACT,-35.2101,149.034
+Dunlop,Australian Capital Territory,ACT,-35.194,149.0198
+Macgregor,Australian Capital Territory,ACT,-35.2098,149.011
+Charnwood,Australian Capital Territory,ACT,-35.2002,149.0341
+Belconnen,Australian Capital Territory,ACT,-35.2167,149.0833
+Belconnen DC,Australian Capital Territory,ACT,-35.2199,149.0869
+Giralang,Australian Capital Territory,ACT,-35.2109,149.096
+Belconnen,Australian Capital Territory,ACT,-35.2167,149.0833
+Kaleen,Australian Capital Territory,ACT,-35.2181,149.1052
+Bruce,Australian Capital Territory,ACT,-35.2407,149.0466
+Evatt,Australian Capital Territory,ACT,-35.2119,149.0689
+University Of Canberra,Australian Capital Territory,ACT,-35.2498,149.0591
+Mckellar,Australian Capital Territory,ACT,-35.2407,149.0466
+Lawson,Australian Capital Territory,ACT,-35.2498,149.0591
+Hall,Australian Capital Territory,ACT,-35.1906,148.9137
+Oaks Estate,Australian Capital Territory,ACT,-35.3397,149.2121
+Kowen,Australian Capital Territory,ACT,-35.3914,149.2166
+Tharwa,Australian Capital Territory,ACT,-35.5714,149.1275
+Hume,Australian Capital Territory,ACT,-35.3855,149.1658
+Paddys River,Australian Capital Territory,ACT,-35.3914,149.2166
+Beard,Australian Capital Territory,ACT,-35.3914,149.2166
+Tuggeranong,Australian Capital Territory,ACT,-35.4158,149.0649
+Greenway,Australian Capital Territory,ACT,-35.4158,149.0649
+Tuggeranong Dc,Australian Capital Territory,ACT,-35.4333,149.15
+Kambah,Australian Capital Territory,ACT,-35.3862,149.058
+Kambah Village,Australian Capital Territory,ACT,-35.3862,149.058
+Erindale Centre,Australian Capital Territory,ACT,-35.3998,149.0888
+Wanniassa,Australian Capital Territory,ACT,-35.3978,149.0909
+Oxley,Australian Capital Territory,ACT,-35.4095,149.0786
+Fadden,Australian Capital Territory,ACT,-35.4019,149.1176
+Monash,Australian Capital Territory,ACT,-35.4158,149.0906
+Macarthur,Australian Capital Territory,ACT,-35.4086,149.132
+Gowrie,Australian Capital Territory,ACT,-35.4119,149.109
+Calwell,Australian Capital Territory,ACT,-35.4404,149.1071
+Gilmore,Australian Capital Territory,ACT,-35.4324,149.1099
+Theodore,Australian Capital Territory,ACT,-35.4496,149.1197
+Richardson,Australian Capital Territory,ACT,-35.4279,149.1138
+Chisholm,Australian Capital Territory,ACT,-35.422,149.1248
+Isabella Plains,Australian Capital Territory,ACT,-35.428,149.094
+Bonython,Australian Capital Territory,ACT,-35.4333,149.0782
+Gordon,Australian Capital Territory,ACT,-35.4568,149.085
+Banks,Australian Capital Territory,ACT,-35.4719,149.0997
+Conder,Australian Capital Territory,ACT,-35.4593,149.1042
+Crace,Australian Capital Territory,ACT,-35.2028,149.1074
+Mitchell,Australian Capital Territory,ACT,-35.2145,149.1293
+Gungahlin,Australian Capital Territory,ACT,-35.1867,149.1362
+Casey,Australian Capital Territory,ACT,-35.167,149.0947
+Kinlyside,Australian Capital Territory,ACT,-35.1842,149.1131
+Franklin,Australian Capital Territory,ACT,-35.1995,149.1433
+Ngunnawal,Australian Capital Territory,ACT,-35.1728,149.1115
+Taylor,Australian Capital Territory,ACT,-35.1842,149.1131
+Palmerston,Australian Capital Territory,ACT,-35.1945,149.1194
+Nicholls,Australian Capital Territory,ACT,-35.1873,149.0965
+Ginninderra Village,Australian Capital Territory,ACT,-35.1875,149.1244
+Forde,Australian Capital Territory,ACT,-35.1682,149.1461
+Moncrieff,Australian Capital Territory,ACT,-35.179,149.1435
+Harrison,Australian Capital Territory,ACT,-35.1991,149.1563
+Jacka,Australian Capital Territory,ACT,-35.179,149.1435
+Amaroo,Australian Capital Territory,ACT,-35.1696,149.128
+Bonner,Australian Capital Territory,ACT,-35.179,149.1435
+Sydney,New South Wales,NSW,-33.8678,151.2073
+Moree,New South Wales,NSW,-29.3965,149.5878
+Kempsey,New South Wales,NSW,-31.079,152.8309
+Seven Oaks,New South Wales,NSW,-31.0123,152.7651
+Clybucca,New South Wales,NSW,-30.95,152.95
+Lower Creek,New South Wales,NSW,-30.9307,152.6368
+Collombatti,New South Wales,NSW,-30.9812,152.8251
+Deep Creek,New South Wales,NSW,-31.0123,152.7651
+Hickeys Creek,New South Wales,NSW,-30.9,152.6
+Gladstone,New South Wales,NSW,-30.9307,152.6368
+Smithtown,New South Wales,NSW,-31.0186,152.9503
+Mungay Creek,New South Wales,NSW,-31.0123,152.7651
+Comara,New South Wales,NSW,-30.9307,152.6368
+Crescent Head,New South Wales,NSW,-31.1887,152.973
+Millbank,New South Wales,NSW,-30.9307,152.6368
+Pola Creek,New South Wales,NSW,-31.0123,152.7651
+Kinchela,New South Wales,NSW,-30.9667,153
+Verges Creek,New South Wales,NSW,-31.0878,152.8997
+Turners Flat,New South Wales,NSW,-31.0167,152.7
+Yessabah,New South Wales,NSW,-31.0123,152.7651
+Sherwood,New South Wales,NSW,-31.0667,152.7333
+Bellbrook,New South Wales,NSW,-30.8167,152.5167
+Hampden Hall,New South Wales,NSW,-31.0123,152.7651
+Old Station,New South Wales,NSW,-31.0123,152.7651
+Belmore River,New South Wales,NSW,-31.1167,152.9833
+Frederickton,New South Wales,NSW,-31.0375,152.8753
+Aldavilla,New South Wales,NSW,-31.0833,152.7667
+East Kempsey,New South Wales,NSW,-31.0123,152.7651
+Euroka,New South Wales,NSW,-31.077,152.8005
+Toorooka,New South Wales,NSW,-30.9307,152.6368
+Willi Willi,New South Wales,NSW,-30.9333,152.45
+Temagog,New South Wales,NSW,-31.0123,152.7651
+Mooneba,New South Wales,NSW,-31.05,152.6833
+South Kempsey,New South Wales,NSW,-31.079,152.8309
+Wittitrin,New South Wales,NSW,-31.1333,152.6667
+Rainbow Reach,New South Wales,NSW,-31.0123,152.7651
+Yarravel,New South Wales,NSW,-31.043,152.7619
+Hat Head,New South Wales,NSW,-31.0555,153.0472
+Burnt Bridge,New South Wales,NSW,-31.1,152.8167
+Moparrabah,New South Wales,NSW,-31.0123,152.7651
+Austral Eden,New South Wales,NSW,-31.0333,152.9167
+Bellimbopinni,New South Wales,NSW,-30.9307,152.6368
+Dondingalong,New South Wales,NSW,-31.1332,152.7514
+Corangula,New South Wales,NSW,-31.0123,152.7651
+Carrai,New South Wales,NSW,-30.9307,152.6368
+Summer Island,New South Wales,NSW,-31.0123,152.7651
+West Kempsey,New South Wales,NSW,-31.0123,152.7651
+Skillion Flat,New South Wales,NSW,-31.0167,152.7333
+Barraganyatti,New South Wales,NSW,-30.85,152.9333
+Telegraph Point,New South Wales,NSW,-31.3333,152.8
+Cooperabung,New South Wales,NSW,-31.3,152.8
+Yarrahapinni,New South Wales,NSW,-30.8281,152.9538
+Tamban,New South Wales,NSW,-30.8667,152.8333
+Grassy Head,New South Wales,NSW,-31.1374,152.7419
+Allgomera,New South Wales,NSW,-30.8182,152.7955
+Bonville,New South Wales,NSW,-30.3761,153.0349
+Upper Rollands Plains,New South Wales,NSW,-31.25,152.6333
+Rollands Plains,New South Wales,NSW,-31.1272,152.7256
+Eungai Rail,New South Wales,NSW,-30.8463,152.9006
+Fishermans Reach,New South Wales,NSW,-31.0274,152.8364
+Stuarts Point,New South Wales,NSW,-30.8208,152.9933
+Bril Bril,New South Wales,NSW,-31.0274,152.8364
+Eungai Creek,New South Wales,NSW,-30.8333,152.8833
+Hacks Ferry,New South Wales,NSW,-31.0274,152.8364
+Kundabung,New South Wales,NSW,-31.2,152.85
+Kippara,New South Wales,NSW,-31.0274,152.8364
+Gum Scrub,New South Wales,NSW,-31.1272,152.7256
+Marlo Merrican,New South Wales,NSW,-31.0274,152.8364
+Crossmaglen,New South Wales,NSW,-31.1374,152.7419
+Ballengarra,New South Wales,NSW,-31.1272,152.7256
+Mid North Coast Mc,New South Wales,NSW,-31.1374,152.7419
+Mid North Coast Msc,New South Wales,NSW,-31.1374,152.7419
+Stewarts River,New South Wales,NSW,-31.7333,152.65
+Deauville,New South Wales,NSW,-31.6915,152.7267
+Lakewood,New South Wales,NSW,-31.6321,152.7582
+North Haven,New South Wales,NSW,-31.7131,152.6781
+Crowdy Bay National Park,New South Wales,NSW,-31.788,152.7311
+Moorland,New South Wales,NSW,-31.7131,152.6781
+West Haven,New South Wales,NSW,-31.6344,152.7825
+Herons Creek,New South Wales,NSW,-31.5833,152.7333
+Camden Head,New South Wales,NSW,-31.6469,152.8346
+Waitui,New South Wales,NSW,-31.6915,152.7267
+Johns River,New South Wales,NSW,-31.75,152.7
+Dunbogan,New South Wales,NSW,-31.65,152.8167
+Glen Niven,Queensland,QLD,-28.6,151.9667
+The Summit,Queensland,QLD,-28.5833,151.9667
+Applethorpe,Queensland,QLD,-28.6167,151.9667
+Pikedale,Queensland,QLD,-28.65,151.6333
+Kyoomba,Queensland,QLD,-28.7421,151.6647
+Mingoola,Queensland,QLD,-28.9833,151.5167
+Mount Tully,Queensland,QLD,-28.7241,151.825
+Cannon Creek,Queensland,QLD,-28.5833,151.8667
+Stanthorpe,Queensland,QLD,-28.6572,151.9337
+Greenlands,Queensland,QLD,-28.7241,151.825
+Broadwater,Queensland,QLD,-28.7241,151.825
+Springdale,Queensland,QLD,-28.7241,151.825
+Thorndale,Queensland,QLD,-28.7241,151.825
+Pikes Creek,Queensland,QLD,-28.7241,151.825
+Eukey,Queensland,QLD,-28.7667,151.9833
+Sugarloaf,Queensland,QLD,-28.7241,151.825
+Storm King,Queensland,QLD,-28.7241,151.825
+Glenlyon,Queensland,QLD,-28.7241,151.825
+Dalcouth,Queensland,QLD,-28.7241,151.825
+Severnlea,Queensland,QLD,-28.7,151.9167
+Amiens,Queensland,QLD,-28.5833,151.8167
+Nundubbermere,Queensland,QLD,-28.7241,151.825
+Fletcher,Queensland,QLD,-28.7667,151.85
+Glen Aplin,Queensland,QLD,-28.7643,151.8918
+Wyberba,Queensland,QLD,-28.85,151.8667
+Ballandean,Queensland,QLD,-28.8576,151.8345
+Lyra,Queensland,QLD,-28.8333,151.8667
+Girraween,Queensland,QLD,-28.8278,151.8556
+Somme,Queensland,QLD,-28.8278,151.8556
+Wallangarra,Queensland,QLD,-28.9239,151.9282
+Limevale,Queensland,QLD,-28.7333,151.2
+Riverton,Queensland,QLD,-28.7884,151.01
+Glenarbon,Queensland,QLD,-28.7884,151.01
+Texas,Queensland,QLD,-28.7884,151.01
+Beebo,Queensland,QLD,-28.7884,151.01
+Watsons Crossing,Queensland,QLD,-28.7884,151.01
+Maidenhead,Queensland,QLD,-28.7884,151.01
+Silver Spur,Queensland,QLD,-28.7884,151.01
+Smithlea,Queensland,QLD,-28.7884,151.01
+Bonshaw,Queensland,QLD,-28.7884,151.01
+Coolmunda,Queensland,QLD,-28.4084,151.2129
+Inglewood,Queensland,QLD,-28.4789,151.1134
+Bybera,Queensland,QLD,-28.4789,151.1134
+Terrica,Queensland,QLD,-28.4789,151.1134
+Warroo,Queensland,QLD,-28.4789,151.1134
+Greenup,Queensland,QLD,-28.4789,151.1134
+Brush Creek,Queensland,QLD,-28.4789,151.1134
+Whetstone,Queensland,QLD,-28.4789,151.1134
+Mosquito Creek,Queensland,QLD,-28.4789,151.1134
+Yelarbon,Queensland,QLD,-28.5725,150.7513
+Kurumbul,Queensland,QLD,-28.2692,150.6904
+Wyaga,Queensland,QLD,-28.194,150.3565
+Lundavra,Queensland,QLD,-28.194,150.3565
+Goodar,Queensland,QLD,-28.194,150.3565
+Goondiwindi,Queensland,QLD,-28.5464,150.3073
+Billa Billa,Queensland,QLD,-28.194,150.3565
+Yagaburne,Queensland,QLD,-28.194,150.3565
+Callandoon,Queensland,QLD,-28.194,150.3565
+Calingunee,Queensland,QLD,-28.194,150.3565
+Kindon,Queensland,QLD,-28.194,150.3565
+Wondalli,Queensland,QLD,-28.194,150.3565
+Kingsthorpe,Queensland,QLD,-27.4756,151.8141
+Acland,Queensland,QLD,-27.3,151.6833
+Biddeston,Queensland,QLD,-27.5667,151.7167
+Muldu,Queensland,QLD,-27.4617,151.6957
+Aubigny,Queensland,QLD,-27.5167,151.65
+Oakey,Queensland,QLD,-27.4331,151.7206
+Yargullen,Queensland,QLD,-27.4617,151.6957
+Balgowan,Queensland,QLD,-27.4617,151.6957
+Rosalie Plains,Queensland,QLD,-27.4617,151.6957
+Silverleigh,Queensland,QLD,-27.4617,151.6957
+Mount Irving,Queensland,QLD,-27.4617,151.6957
+Kelvinhaugh,Queensland,QLD,-27.4617,151.6957
+Amamoor Creek,Queensland,QLD,-26.1931,152.5564
+Bells Bridge,Queensland,QLD,-26.1258,152.5387
+St Mary,Queensland,QLD,-26.1931,152.5564
+Tuchekoi,Queensland,QLD,-26.2008,152.6451
+Mcintosh Creek,Queensland,QLD,-26.1931,152.5564
+Woondum,Queensland,QLD,-26.25,152.7333
+Neusa Vale,Queensland,QLD,-26.1931,152.5564
+Cedar Pocket,Queensland,QLD,-26.2008,152.6451
+Widgee Crossing North,Queensland,QLD,-26.1931,152.5564
+Veteran,Queensland,QLD,-26.2008,152.6451
+Kandanga,Queensland,QLD,-26.3833,152.6667
+The Palms,Queensland,QLD,-26.205,152.5865
+Greens Creek,Queensland,QLD,-26.1931,152.5564
+Coondoo,Queensland,QLD,-26.1667,152.8833
+Ross Creek,Queensland,QLD,-26.1931,152.5564
+Dagun,Queensland,QLD,-26.3167,152.6833
+Bella Creek,Queensland,QLD,-26.1931,152.5564
+Langshaw,Queensland,QLD,-26.3,152.5667
+Kia Ora,Queensland,QLD,-26.1931,152.5564
+Willalo,South Australia,SA,-33.4,138.8833
+Whyte Yarcowie,South Australia,SA,-33.2047,139.0367
+Canowie Belt,South Australia,SA,-33.1833,138.75
+Terowie,South Australia,SA,-33.1667,138.9
+Franklyn,South Australia,SA,-32.9379,138.9062
+Mannanarie,South Australia,SA,-33.05,138.6167
+Ucolta,South Australia,SA,-32.95,138.9667
+Peterborough,South Australia,SA,-32.9721,138.8407
+Sunnybrae,South Australia,SA,-32.8905,138.9224
+Hardy,South Australia,SA,-32.8905,138.9224
+Cavenagh,South Australia,SA,-32.8905,138.9224
+Parnaroo,South Australia,SA,-32.9833,139.1333
+Oodla Wirra,South Australia,SA,-32.8833,139.0667
+Minvalara,South Australia,SA,-32.9,138.75
+Paratoo,South Australia,SA,-32.7,139.3667
+Dawson,South Australia,SA,-32.8,138.9667
+Erskine,South Australia,SA,-32.7333,138.85
+Yatina,South Australia,SA,-32.9333,138.6667
+Pekina,South Australia,SA,-32.8333,138.55
+Morchard,South Australia,SA,-32.8452,138.6651
+Orroroo,South Australia,SA,-32.7344,138.6139
+Amyton,South Australia,SA,-32.6,138.3333
+Hammond,South Australia,SA,-32.8452,138.6651
+Yalpara,South Australia,SA,-32.5333,138.9333
+Tarcowie,South Australia,SA,-32.8452,138.6651
+Eurelia,South Australia,SA,-32.55,138.5667
+Johnburgh,South Australia,SA,-32.45,138.7
+Black Rock,South Australia,SA,-32.8333,138.7
+Willowie,South Australia,SA,-32.6833,138.3333
+Walloway,South Australia,SA,-32.6333,138.5833
+Minburra,South Australia,SA,-32.6695,138.5539
+Coomooroo,South Australia,SA,-32.6695,138.5539
+Cradock,South Australia,SA,-32.3697,138.6443
+Yanyarrie,South Australia,SA,-32.3042,138.5417
+Carrieton,South Australia,SA,-32.3697,138.6443
+Belton,South Australia,SA,-32.2333,138.7
+Moockra,South Australia,SA,-32.4667,138.4333
+Quorn,South Australia,SA,-32.3468,138.0418
+Willochra,South Australia,SA,-32.2333,138.1333
+Saltia,South Australia,SA,-32.3489,138.125
+Bruce,South Australia,SA,-32.4667,138.2
+Stephenston,South Australia,SA,-32.3489,138.125
+Yarrah,South Australia,SA,-32.3489,138.125
+Hawker,South Australia,SA,-31.8892,138.42
+Kanyaka,South Australia,SA,-31.8892,138.42
+Barndioota,South Australia,SA,-31.8892,138.42
+Manna Hill,South Australia,SA,-32.325,140.0441
+Waukaringa,South Australia,SA,-32.3,139.4333
+Cockburn,South Australia,SA,-32.325,140.0441
+Nackara,South Australia,SA,-32.8,139.2333
+Yunta,South Australia,SA,-32.325,140.0441
+Mingary,South Australia,SA,-32.1333,140.7333
+Olary,South Australia,SA,-32.325,140.0441
+Auburn,South Australia,SA,-34.0269,138.6852
+Undalya,South Australia,SA,-34.0667,138.6833
+Leasingham,South Australia,SA,-33.9942,138.6248
+Watervale,South Australia,SA,-33.9942,138.6248
+Clare,South Australia,SA,-33.8332,138.6106
+Spring Farm,South Australia,SA,-33.8972,138.5785
+Hoyleton,South Australia,SA,-33.8532,138.5559
+Barinia,South Australia,SA,-33.8972,138.5785
+Benbournie,South Australia,SA,-33.8972,138.5785
+Stanley Flat,South Australia,SA,-33.8972,138.5785
+Sevenhill,South Australia,SA,-33.8972,138.5785
+Polish Hill River,South Australia,SA,-33.8972,138.5785
+Hill River,South Australia,SA,-33.8972,138.5785
+Kybunga,South Australia,SA,-33.8972,138.5785
+Gillentown,South Australia,SA,-33.8972,138.5785
+Boconnoc Park,South Australia,SA,-33.8972,138.5785
+Armagh,South Australia,SA,-33.825,138.5748
+Spring Gully,South Australia,SA,-33.8972,138.5785
+Emu Flat,South Australia,SA,-33.8972,138.5785
+Penwortham,South Australia,SA,-33.8972,138.5785
+Spalding,South Australia,SA,-33.4979,138.6075
+Andrews,South Australia,SA,-34.6763,138.662
+Broughton River Valley,South Australia,SA,-34.0871,138.6347
+Euromina,South Australia,SA,-34.0871,138.6347
+Mayfield,South Australia,SA,-34.0871,138.6347
+Washpool,South Australia,SA,-34.0871,138.6347
+Hacklins Corner,South Australia,SA,-34.0871,138.6347
+Hilltown,South Australia,SA,-33.8458,138.6125
+Barabba,South Australia,SA,-34.35,138.5833
+Owen,South Australia,SA,-34.272,138.5444
+Pinery,South Australia,SA,-34.3,138.45
+Risdon Park,South Australia,SA,-33.1966,137.994
+Lonnavale,Tasmania,TAS,-42.9754,146.8397
+Crabtree,Tasmania,TAS,-42.9633,147.0786
+Glaziers Bay,Tasmania,TAS,-43.1458,146.9984
+Wattle Grove,Tasmania,TAS,-43.2109,146.8676
+Waterloo,Tasmania,TAS,-43.2109,146.8676
+Strathblane,Tasmania,TAS,-43.2109,146.8676
+Lower Wattle Grove,Tasmania,TAS,-43.1269,147.0275
+Lower Longley,Tasmania,TAS,-42.9833,147.1333
+Catamaran,Tasmania,TAS,-43.2109,146.8676
+Petcheys Bay,Tasmania,TAS,-43.2109,146.8676
+Raminea,Tasmania,TAS,-43.2109,146.8676
+Cygnet,Tasmania,TAS,-43.1533,147.0725
+Abels Bay,Tasmania,TAS,-43.1696,147.1296
+Eggs And Bacon Bay,Tasmania,TAS,-43.2455,147.1047
+Nicholls Rivulet,Tasmania,TAS,-43.1696,147.1296
+Gardners Bay,Tasmania,TAS,-43.1696,147.1296
+Charlotte Cove,Tasmania,TAS,-43.189,147.148
+Randalls Bay,Tasmania,TAS,-43.1696,147.1296
+Verona Sands,Tasmania,TAS,-43.1696,147.1296
+Garden Island Creek,Tasmania,TAS,-43.25,147.1667
+Deep Bay,Tasmania,TAS,-43.2082,147.134
+Franklin,Tasmania,TAS,-43.0888,147.0091
+Brooks Bay,Tasmania,TAS,-43.1708,146.9784
+Geeveston,Tasmania,TAS,-43.1634,146.9255
+Surges Bay,Tasmania,TAS,-43.2775,146.4256
+Surveyors Bay,Tasmania,TAS,-43.1708,146.9784
+Castle Forbes Bay,Tasmania,TAS,-43.2775,146.4256
+Port Huon,Tasmania,TAS,-43.1554,146.9634
+Cairns Bay,Tasmania,TAS,-43.2775,146.4256
+Police Point,Tasmania,TAS,-43.2775,146.4256
+Dover,Tasmania,TAS,-43.2774,146.9734
+Stonor,Tasmania,TAS,-42.4,147.3833
+Swanston,Tasmania,TAS,-42.3482,147.4726
+Andover,Tasmania,TAS,-42.3333,147.45
+Rhyndaston,Tasmania,TAS,-42.3325,147.4857
+Oatlands,Tasmania,TAS,-42.3325,147.4857
+York Plains,Tasmania,TAS,-42.3325,147.4857
+Woodsdale,Tasmania,TAS,-42.4667,147.5667
+Tunbridge,Tasmania,TAS,-42.3325,147.4857
+Parattah,Tasmania,TAS,-42.35,147.4
+Woodbury,Tasmania,TAS,-42.3325,147.4857
+Baden,Tasmania,TAS,-42.3325,147.4857
+Mount Seymour,Tasmania,TAS,-42.3325,147.4857
+Lemont,Tasmania,TAS,-42.3325,147.4857
+Antill Ponds,Tasmania,TAS,-42.3325,147.4857
+Tunnack,Tasmania,TAS,-42.45,147.45
+Orford,Tasmania,TAS,-42.3064,147.9158
+Spring Beach,Tasmania,TAS,-42.5864,147.9145
+Dolphin Sands,Tasmania,TAS,-42.4221,147.8876
+Swansea,Tasmania,TAS,-42.3064,147.9158
+Runnymede,Tasmania,TAS,-42.3064,147.9158
+Little Swanport,Tasmania,TAS,-42.3225,147.9578
+Rheban,Tasmania,TAS,-42.6278,147.9236
+Triabunna,Tasmania,TAS,-42.5018,147.9136
+South Kingsville,Victoria,VIC,-37.8302,144.8709
+Spotswood,Victoria,VIC,-37.8299,144.8878
+Newport,Victoria,VIC,-37.8443,144.8848
+Williamstown North,Victoria,VIC,-37.857,144.8977
+Williamstown,Victoria,VIC,-37.857,144.8977
+Altona,Victoria,VIC,-37.8696,144.8304
+Seaholme,Victoria,VIC,-37.864,144.845
+Robinson,Victoria,VIC,-37.7867,144.8548
+Braybrook,Victoria,VIC,-37.7867,144.8548
+Glengala,Victoria,VIC,-37.775,144.8333
+Sunshine,Victoria,VIC,-37.7833,144.8333
+Sunshine North,Victoria,VIC,-37.775,144.8333
+Albion,Victoria,VIC,-37.7667,144.8333
+Sunshine West,Victoria,VIC,-37.775,144.8333
+St Albans,Victoria,VIC,-37.745,144.8005
+Kings Park,Victoria,VIC,-37.7337,144.772
+Albanvale,Victoria,VIC,-37.7461,144.7686
+Kealba,Victoria,VIC,-37.7371,144.8283
+Deer Park East,Victoria,VIC,-37.7764,144.8016
+Ardeer,Victoria,VIC,-37.7759,144.8014
+Ravenhall,Victoria,VIC,-37.7541,144.7651
+Deer Park,Victoria,VIC,-37.7667,144.7833
+Burnside Heights,Victoria,VIC,-37.7541,144.7651
+Caroline Springs,Victoria,VIC,-37.7412,144.7363
+Deer Park North,Victoria,VIC,-37.7541,144.7651
+Cairnlea,Victoria,VIC,-37.7593,144.7878
+Burnside,Victoria,VIC,-37.7494,144.753
+Mambourin,Victoria,VIC,-37.8291,144.5622
+Mount Cottrell,Victoria,VIC,-37.8167,144.5833
+Wyndham Vale,Victoria,VIC,-37.8415,144.541
+Altona East,Victoria,VIC,-37.8349,144.8474
+Altona North,Victoria,VIC,-37.8349,144.8474
+Altona Gate,Victoria,VIC,-37.8349,144.8474
+Laverton North,Victoria,VIC,-37.8259,144.6886
+Williams Landing,Victoria,VIC,-37.7963,144.7565
+Seabrook,Victoria,VIC,-37.8809,144.7587
+Altona Meadows,Victoria,VIC,-37.8739,144.772
+Laverton,Victoria,VIC,-37.862,144.7698
+Hoppers Crossing,Victoria,VIC,-37.8826,144.7003
+Tarneit,Victoria,VIC,-37.8667,144.6667
+Truganina,Victoria,VIC,-37.8167,144.75
+Cocoroc,Victoria,VIC,-37.8887,144.726
+Point Cook,Victoria,VIC,-37.9148,144.7509
+Quandong,Victoria,VIC,-37.8887,144.726
+Werribee,Victoria,VIC,-37.9,144.6667
+Gillieston,Victoria,VIC,-36.4516,145.181
+Mooroopna North West,Victoria,VIC,-36.4455,145.1411
+Cooma,Victoria,VIC,-36.4516,145.181
+Waranga,Victoria,VIC,-36.6,145.1167
+Girgarre East,Victoria,VIC,-36.4333,145.0667
+Byrneside,Victoria,VIC,-36.4167,145.1833
+Merrigum,Victoria,VIC,-36.3724,145.1322
+Yalca,Victoria,VIC,-35.9833,145.3167
+Nathalia,Victoria,VIC,-36.0577,145.2041
+Yielima,Victoria,VIC,-35.9333,145.2167
+Kotupna,Victoria,VIC,-36.15,145.15
+Picola,Victoria,VIC,-35.9818,145.0847
+Barmah,Victoria,VIC,-36.0167,144.9667
+Lower Moira,Victoria,VIC,-36.0833,144.9833
+Picola West,Victoria,VIC,-36.0333,145.0278
+Katunga,Victoria,VIC,-35.9666,145.4269
+Ulupna,Victoria,VIC,-35.8833,145.4
+Strathmerton,Victoria,VIC,-35.8774,145.4452
+Mywee,Victoria,VIC,-35.8667,145.5
+Bearii,Victoria,VIC,-35.8857,145.3453
+Cobram,Victoria,VIC,-35.9207,145.6407
+Koonoomoo,Victoria,VIC,-35.9503,145.6546
+Yarroweyah,Victoria,VIC,-35.9333,145.55
+Muckatah,Victoria,VIC,-36.0167,145.65
+Cobram,Victoria,VIC,-35.9207,145.6407
+Cobram East,Victoria,VIC,-35.9746,145.7364
+Dookie,Victoria,VIC,-36.3273,145.6897
+Yabba North,Victoria,VIC,-36.3077,145.6839
+Mount Major,Victoria,VIC,-36.2755,145.7146
+Youanmite,Victoria,VIC,-36.3077,145.6839
+Nalinga,Victoria,VIC,-36.4167,145.7167
+Waggarandall,Victoria,VIC,-36.25,145.8
+Yabba South,Victoria,VIC,-36.2755,145.7146
+Dookie College,Victoria,VIC,-36.0413,145.6097
+Katamatite,Victoria,VIC,-36.0759,145.6872
+Katamatite East,Victoria,VIC,-36.0759,145.6872
+Reedy Creek,Victoria,VIC,-37.2667,145.1333
+Waterford Park,Victoria,VIC,-37.3002,145.0668
+Strath Creek,Victoria,VIC,-37.2333,145.2167
+Clonbinane,Victoria,VIC,-37.292,145.1406
+Broadford,Victoria,VIC,-37.2028,145.0484
+Sunday Creek,Victoria,VIC,-37.2602,145.1482
+Tyaak,Victoria,VIC,-37.2167,145.1333
+Sugarloaf Creek,Victoria,VIC,-37.2602,145.1482
+Hazeldene,Victoria,VIC,-37.292,145.1406
+Tallarook,Victoria,VIC,-37.0937,145.1
+Northwood,Victoria,VIC,-36.9667,145.1167
+Caveat,Victoria,VIC,-37.0605,145.2132
+Highlands,Victoria,VIC,-37.1,145.4
+Hilldene,Victoria,VIC,-37.0333,145.0667
+Whiteheads Creek,Victoria,VIC,-37.0468,145.2864
+Seymour South,Victoria,VIC,-37.0605,145.2132
+Dropmore,Victoria,VIC,-37.0605,145.2132
+Kerrisdale,Victoria,VIC,-37.0517,145.3285
+Seymour,Victoria,VIC,-37.0517,145.3285
+Trawool,Victoria,VIC,-37.0517,145.3285
+Seymour,Victoria,VIC,-37.0266,145.1392
+Puckapunyal,Victoria,VIC,-36.9949,145.0401
+Puckapunyal Milpo,Victoria,VIC,-36.9604,145.0527
+Mangalore,Victoria,VIC,-36.9333,145.1833
+Avenel,Victoria,VIC,-36.9452,145.3379
+Upton Hill,Victoria,VIC,-36.9009,145.2337
+Locksley,Victoria,VIC,-36.9011,145.4139
+Longwood,Victoria,VIC,-36.9011,145.4139
+Strathbogie,Victoria,VIC,-36.85,145.75
+Moglonemby,Victoria,VIC,-36.65,145.5333
+Euroa,Victoria,VIC,-36.7555,145.5708
+Guthridge,Victoria,VIC,-38.106,147.0608
+Wurruk,Victoria,VIC,-38.1167,147.0333
+Cobains,Victoria,VIC,-38.0833,147.15
+Bundalaguah,Victoria,VIC,-38.0333,147.0167
+Flynn,Western Australia,WA,-31.9264,116.7354
+Balladong,Western Australia,WA,-31.9264,116.7354
+Cold Harbour,Western Australia,WA,-31.9264,116.7354
+Narraloggan,Western Australia,WA,-31.9264,116.7354
+Wilberforce,Western Australia,WA,-31.9264,116.7354
+Kelmscott Dc,Western Australia,WA,-32.1167,116.0056
\ No newline at end of file
diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb
index dba081e44..bb665e810 100644
--- a/lib/haml/filters/growstuff_markdown.rb
+++ b/lib/haml/filters/growstuff_markdown.rb
@@ -2,7 +2,10 @@ require 'bluecloth'
module Haml::Filters
module GrowstuffMarkdown
- CROP_REGEX = /\[([^\[\]]+?)\]\(crop\)/
+ CROP_REGEX = /(? Growstuff::Application.config.host)
+ url = Rails.application.routes.url_helpers.crop_url(crop, host: Growstuff::Application.config.host)
"[#{crop_str}](#{url})"
else
crop_str
end
end
+ # turn [jane](member) into [jane](http://growstuff.org/members/jane)
+ expanded = expanded.gsub(MEMBER_REGEX) do |m|
+ member_str = $1
+ # find member case-insensitively
+ member = Member.where('lower(login_name) = ?', member_str.downcase).first
+ if member
+ url = Rails.application.routes.url_helpers.member_url(member, only_path: true)
+ "[#{member_str}](#{url})"
+ else
+ member_str
+ end
+ end
+
+ # turn @jane into [@jane](http://growstuff.org/members/jane)
+ expanded = expanded.gsub(MEMBER_AT_REGEX) do |m|
+ member_str = $1
+ # find member case-insensitively
+ member = Member.where('lower(login_name) = ?', member_str[1..-1].downcase).first
+ if member
+ url = Rails.application.routes.url_helpers.member_url(member, only_path: true)
+ "[#{member_str}](#{url})"
+ else
+ member_str
+ end
+ end
+
+ expanded = expanded.gsub(MEMBER_ESCAPE_AT_REGEX, "")
+
return BlueCloth.new(expanded).to_html
end
diff --git a/lib/tasks/growstuff.rake b/lib/tasks/growstuff.rake
index bfb7b8642..58372327a 100644
--- a/lib/tasks/growstuff.rake
+++ b/lib/tasks/growstuff.rake
@@ -3,7 +3,7 @@ namespace :growstuff do
desc "Add an admin user, by name"
# usage: rake growstuff:admin_user name=skud
- task :admin_user => :environment do
+ task admin_user: :environment do
member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:admin_user name=whoever (login name is case-sensitive)"
admin = Role.find('admin')
member.roles << admin
@@ -12,7 +12,7 @@ namespace :growstuff do
desc "Add a crop wrangler user, by name"
# usage: rake growstuff:cropwrangler_user name=skud
- task :cropwrangler_user => :environment do
+ task cropwrangler_user: :environment do
member = Member.find_by_login_name(ENV['name']) or raise "Usage: rake growstuff:cropwrangler_user name=whoever (login name is case-sensitive)"
cw = Role.find('crop-wrangler')
member.roles << cw
@@ -21,7 +21,7 @@ namespace :growstuff do
desc "Upload crops from a CSV file"
# usage: rake growstuff:import_crops file=filename.csv
- task :import_crops => :environment do
+ task import_crops: :environment do
require 'csv'
@file = ENV['file'] or raise "Usage: rake growstuff:import_crops file=file.csv"
@@ -38,7 +38,7 @@ namespace :growstuff do
desc "Send planting reminder email"
# usage: rake growstuff:send_planting_reminder
- task :send_planting_reminder => :environment do
+ task send_planting_reminder: :environment do
# Heroku scheduler only lets us run things daily, so this checks
# whether it's the right day to actually do the deed.
# Note that Heroku scheduler runs on UTC.
@@ -56,7 +56,7 @@ namespace :growstuff do
desc "Depopulate Null Island"
# this fixes up anyone who has erroneously wound up with a 0,0 lat/long
- task :depopulate_null_island => :environment do
+ task depopulate_null_island: :environment do
Member.find_each do |m|
if m.location and (m.latitude == nil and m.longitude == nil)
m.geocode
@@ -69,7 +69,7 @@ namespace :growstuff do
namespace :oneoff do
desc "May 2013: replace any empty notification subjects with (no subject)"
- task :empty_subjects => :environment do
+ task empty_subjects: :environment do
# this is inefficient as it checks every Notification, but the
# site is small and there aren't many of them, so it shouldn't matter
@@ -81,7 +81,7 @@ namespace :growstuff do
end
desc "May 2013: replace any empty garden names with Garden"
- task :empty_garden_names => :environment do
+ task empty_garden_names: :environment do
# this is inefficient as it checks every Garden, but the
# site is small and there aren't many of them, so it shouldn't matter
@@ -96,48 +96,48 @@ namespace :growstuff do
desc "June 2013: create account types and products."
- task :setup_shop => :environment do
+ task setup_shop: :environment do
puts "Adding account types..."
AccountType.find_or_create_by(
- :name => "Free",
- :is_paid => false,
- :is_permanent_paid => false
+ name: "Free",
+ is_paid: false,
+ is_permanent_paid: false
)
@paid_account = AccountType.find_or_create_by(
- :name => "Paid",
- :is_paid => true,
- :is_permanent_paid => false
+ name: "Paid",
+ is_paid: true,
+ is_permanent_paid: false
)
@seed_account = AccountType.find_or_create_by(
- :name => "Seed",
- :is_paid => true,
- :is_permanent_paid => true
+ name: "Seed",
+ is_paid: true,
+ is_permanent_paid: true
)
@staff_account = AccountType.find_or_create_by(
- :name => "Staff",
- :is_paid => true,
- :is_permanent_paid => true
+ name: "Staff",
+ is_paid: true,
+ is_permanent_paid: true
)
puts "Adding products..."
Product.find_or_create_by(
- :name => "Annual subscription",
- :description => "An annual subscription gives you access to paid account features for one year. Does not auto-renew.",
- :min_price => 3000,
- :account_type_id => @paid_account.id,
- :paid_months => 12
+ name: "Annual subscription",
+ description: "An annual subscription gives you access to paid account features for one year. Does not auto-renew.",
+ min_price: 3000,
+ account_type_id: @paid_account.id,
+ paid_months: 12
)
Product.find_or_create_by(
- :name => "Seed account",
- :description => "A seed account helps Growstuff grow in its early days. It gives you all the features of a paid account, in perpetuity. This account type never expires.",
- :min_price => 15000,
- :account_type_id => @seed_account.id,
+ name: "Seed account",
+ description: "A seed account helps Growstuff grow in its early days. It gives you all the features of a paid account, in perpetuity. This account type never expires.",
+ min_price: 15000,
+ account_type_id: @seed_account.id,
)
puts "Giving each member an account record..."
Member.all.each do |m|
unless m.account
- Account.create(:member_id => m.id)
+ Account.create(member_id: m.id)
end
end
@@ -152,7 +152,7 @@ namespace :growstuff do
end
desc "June 2013: replace nil account_types with free accounts"
- task :nil_account_type => :environment do
+ task nil_account_type: :environment do
free = AccountType.find_by_name("Free")
raise "Free account type not found: run rake growstuff:oneoff:setup_shop"\
@@ -166,7 +166,7 @@ namespace :growstuff do
end
desc "July 2013: replace nil seed.tradable_to with nowhere"
- task :tradable_to_nowhere => :environment do
+ task tradable_to_nowhere: :environment do
Seed.all.each do |s|
unless s.tradable_to
@@ -177,7 +177,7 @@ namespace :growstuff do
end
desc "August 2013: set up plantings_count cache on crop"
- task :reset_crop_plantings_count => :environment do
+ task reset_crop_plantings_count: :environment do
Crop.find_each do |c|
Crop.reset_counters c.id, :plantings
@@ -185,7 +185,7 @@ namespace :growstuff do
end
desc "August 2013: set default creator on existing crops"
- task :set_default_crop_creator => :environment do
+ task set_default_crop_creator: :environment do
cropbot = Member.find_by_login_name("cropbot")
raise "cropbot not found: create cropbot member on site or run rake db:seed" unless cropbot
@@ -207,7 +207,7 @@ namespace :growstuff do
end
desc "August 2013: set planting owner"
- task :set_planting_owner => :environment do
+ task set_planting_owner: :environment do
Planting.find_each do |p|
p.owner = p.garden.owner
p.save
@@ -215,14 +215,14 @@ namespace :growstuff do
end
desc "August 2013: initialize member planting counter"
- task :initialize_member_planting_count => :environment do
+ task initialize_member_planting_count: :environment do
Member.find_each do |m|
Member.reset_counters m.id, :plantings
end
end
desc "October 2013: set garden locations to member locations"
- task :initialize_garden_locations => :environment do
+ task initialize_garden_locations: :environment do
Member.located.find_each do |m|
m.gardens.each do |g|
if g.location.blank?
@@ -236,7 +236,7 @@ namespace :growstuff do
end
desc "October 2013: import initial plant parts"
- task :import_plant_parts => :environment do
+ task import_plant_parts: :environment do
plant_parts = [
'fruit',
'flower',
@@ -257,7 +257,7 @@ namespace :growstuff do
end
desc "July 2014: set planting_count to 0 by default, not nil"
- task :zero_plantings_count => :environment do
+ task zero_plantings_count: :environment do
Crop.find_each do |c|
if c.plantings_count.nil?
c.plantings_count = 0
@@ -267,7 +267,7 @@ namespace :growstuff do
end
desc "August 2014: fix ping to pint in database"
- task :ping_to_pint => :environment do
+ task ping_to_pint: :environment do
Harvest.find_each do |h|
if h.unit == "ping"
h.unit = "pint"
@@ -277,21 +277,21 @@ namespace :growstuff do
end
desc "October 2014: remove unused photos"
- task :remove_unused_photos => :environment do
+ task remove_unused_photos: :environment do
Photo.find_each do |p|
p.destroy_if_unused
end
end
desc "October 2014: generate crops_posts records for existing posts"
- task :generate_crops_posts_records => :environment do
+ task generate_crops_posts_records: :environment do
Post.find_each do |p|
p.save
end
end
desc "October 2014: add alternate names for crops"
- task :add_alternate_names => :environment do
+ task add_alternate_names: :environment do
require 'csv'
file = "db/seeds/alternate_names_201410.csv"
puts "Loading alternate names from #{file}..."
@@ -316,7 +316,7 @@ namespace :growstuff do
end
desc "January 2015: fill in si_weight column"
- task :populate_si_weight => :environment do
+ task populate_si_weight: :environment do
Harvest.find_each do |h|
h.set_si_weight
h.save
@@ -324,7 +324,7 @@ namespace :growstuff do
end
desc "January 2015: build Elasticsearch index"
- task :elasticsearch_create_index => :environment do
+ task elasticsearch_create_index: :environment do
Crop.__elasticsearch__.create_index! force: true
Crop.import
end
diff --git a/lib/tasks/hooks.rake b/lib/tasks/hooks.rake
index 036032414..93d599831 100644
--- a/lib/tasks/hooks.rake
+++ b/lib/tasks/hooks.rake
@@ -1,5 +1,5 @@
desc "Install git hooks"
task :hooks do
FileUtils.symlink '../../script/pre-commit.sh', '.git/hooks/pre-commit',
- :force => true
+ force: true
end
diff --git a/lib/tasks/testing.rake b/lib/tasks/testing.rake
index 1f7f000ef..a7908d590 100644
--- a/lib/tasks/testing.rake
+++ b/lib/tasks/testing.rake
@@ -2,7 +2,7 @@ require 'rake'
begin
require 'rspec/core/rake_task'
task(:spec).clear
- RSpec::Core::RakeTask.new(:spec => 'db:test:prepare') do |t|
+ RSpec::Core::RakeTask.new(spec: 'db:test:prepare') do |t|
t.verbose = false
end
rescue LoadError
diff --git a/public/robots.txt b/public/robots.txt
deleted file mode 100644
index 085187fa5..000000000
--- a/public/robots.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
-#
-# To ban all spiders from the entire site uncomment the next two lines:
-# User-Agent: *
-# Disallow: /
diff --git a/script/deploy-tasks.sh b/script/deploy-tasks.sh
index e8461294c..481f221f6 100755
--- a/script/deploy-tasks.sh
+++ b/script/deploy-tasks.sh
@@ -2,6 +2,9 @@
# tasks to run at deploy time, usually after 'rake db:migrate'
+# Permanent tasks
+rake assets:precompile
+
# When adding tasks, do so in chronological order, and note the date
# when it was added. This will help us know which ones have been run
# and can safely be commented out or removed.
@@ -10,17 +13,7 @@
# echo "YYYY-MM-DD - do something or other"
# rake growstuff:oneoff:something
-echo "2014-12-01 - load lots of new crops"
-rake growstuff:import_crops file=db/seeds/crops-12-mint.csv
-rake growstuff:import_crops file=db/seeds/crops-13-brassicas.csv
-rake growstuff:import_crops file=db/seeds/crops-14-london-workingbee.csv
-rake growstuff:import_crops file=db/seeds/crops-15-squashes.csv
+# One-off tasks
-echo "2014-12-01 - load alternate names for crops"
-rake growstuff:oneoff:add_alternate_names
-
-echo "2015-01-28 - populate the harvest si_weight field"
-rake growstuff:oneoff:populate_si_weight
-
-echo "2015-01-30 - build Elasticsearch index"
-rake growstuff:oneoff:elasticsearch_create_index
+# echo "2015-01-30 - build Elasticsearch index"
+# rake growstuff:oneoff:elasticsearch_create_index
diff --git a/script/heroku_maintenance.rb b/script/heroku_maintenance.rb
index cf23b398f..4fd898148 100755
--- a/script/heroku_maintenance.rb
+++ b/script/heroku_maintenance.rb
@@ -3,7 +3,7 @@
require 'heroku-api'
require 'yaml'
-heroku = Heroku::API.new(:api_key => ENV['HEROKU_API_KEY'])
+heroku = Heroku::API.new(api_key: ENV['HEROKU_API_KEY'])
branch = ENV['TRAVIS_BRANCH']
travis_config = YAML.load_file('.travis.yml')
if travis_config['deploy']['app'].has_key? branch
diff --git a/spec/controllers/account_types_controller_spec.rb b/spec/controllers/account_types_controller_spec.rb
index a22146a79..eca67cfbc 100644
--- a/spec/controllers/account_types_controller_spec.rb
+++ b/spec/controllers/account_types_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe AccountTypesController do
diff --git a/spec/controllers/accounts_controller_spec.rb b/spec/controllers/accounts_controller_spec.rb
index eb2ff7f65..d3ea69f87 100644
--- a/spec/controllers/accounts_controller_spec.rb
+++ b/spec/controllers/accounts_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe AccountsController do
diff --git a/spec/controllers/admin/orders_controller_spec.rb b/spec/controllers/admin/orders_controller_spec.rb
index 08dfb9933..28fe0203a 100644
--- a/spec/controllers/admin/orders_controller_spec.rb
+++ b/spec/controllers/admin/orders_controller_spec.rb
@@ -1,3 +1,20 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
+
require 'rails_helper'
describe Admin::OrdersController do
@@ -7,13 +24,13 @@ describe Admin::OrdersController do
describe "GET search" do
it "assigns @orders" do
order = FactoryGirl.create(:order)
- get :search, {:search_by => 'order_id', :search_text => order.id}
+ get :search, {search_by: 'order_id', search_text: order.id}
assigns(:orders).should eq([order])
end
it "sets an error message if nothing found" do
order = FactoryGirl.create(:order)
- get :search, {:search_by => 'order_id', :search_text => 'foo'}
+ get :search, {search_by: 'order_id', search_text: 'foo'}
flash[:alert].should match /Couldn't find order with/
end
end
diff --git a/spec/controllers/admin_controller_spec.rb b/spec/controllers/admin_controller_spec.rb
index fc31f80b9..d939b9f6b 100644
--- a/spec/controllers/admin_controller_spec.rb
+++ b/spec/controllers/admin_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe AdminController do
diff --git a/spec/controllers/authentications_controller_spec.rb b/spec/controllers/authentications_controller_spec.rb
index 4fc5b98a5..e3dd39447 100644
--- a/spec/controllers/authentications_controller_spec.rb
+++ b/spec/controllers/authentications_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe AuthenticationsController do
@@ -6,7 +22,7 @@ describe AuthenticationsController do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_member) { @member }
- @auth = FactoryGirl.create(:authentication, :member => @member)
+ @auth = FactoryGirl.create(:authentication, member: @member)
request.env['omniauth.auth'] = {
'provider' => 'foo',
'uid' => 'bar',
diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb
index 0e10ffe42..3e60a642b 100644
--- a/spec/controllers/comments_controller_spec.rb
+++ b/spec/controllers/comments_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe CommentsController do
@@ -10,12 +26,12 @@ describe CommentsController do
def valid_attributes
@post = FactoryGirl.create(:post)
- { :post_id => @post.id, :author_id => @member.id, :body => "some text" }
+ { post_id: @post.id, author_id: @member.id, body: "some text" }
end
describe "GET RSS feed" do
it "returns an RSS feed" do
- get :index, :format => "rss"
+ get :index, format: "rss"
response.should be_success
response.should render_template("comments/index")
response.content_type.should eq("application/rss+xml")
@@ -25,14 +41,14 @@ describe CommentsController do
describe "GET new" do
it "picks up post from params" do
post = FactoryGirl.create(:post)
- get :new, {:post_id => post.id}
+ get :new, {post_id: post.id}
assigns(:post).should eq(post)
end
it "assigns the old comments as @comments" do
post = FactoryGirl.create(:post)
- old_comment = FactoryGirl.create(:comment, :post => post)
- get :new, {:post_id => post.id}
+ old_comment = FactoryGirl.create(:comment, post: post)
+ get :new, {post_id: post.id}
assigns(:comments).should eq [old_comment]
end
@@ -45,9 +61,9 @@ describe CommentsController do
describe "GET edit" do
it "assigns previous comments as @comments" do
post = FactoryGirl.create(:post)
- old_comment = FactoryGirl.create(:comment, :post => post)
- comment = FactoryGirl.create(:comment, :post => post, :author => @member)
- get :edit, {:id => comment.to_param}
+ old_comment = FactoryGirl.create(:comment, post: post)
+ comment = FactoryGirl.create(:comment, post: post, author: @member)
+ get :edit, {id: comment.to_param}
assigns(:comments).should eq([comment, old_comment])
end
end
@@ -56,7 +72,7 @@ describe CommentsController do
describe "with valid params" do
it "redirects to the comment's post" do
comment = Comment.create! valid_attributes
- put :update, {:id => comment.to_param, :comment => valid_attributes}
+ put :update, {id: comment.to_param, comment: valid_attributes}
response.should redirect_to(comment.post)
end
end
@@ -66,7 +82,7 @@ describe CommentsController do
it "redirects to the post the comment was on" do
comment = Comment.create! valid_attributes
post = comment.post
- delete :destroy, {:id => comment.to_param}
+ delete :destroy, {id: comment.to_param}
response.should redirect_to(post)
end
end
diff --git a/spec/controllers/crops_controller_spec.rb b/spec/controllers/crops_controller_spec.rb
index 54226c27c..894858057 100644
--- a/spec/controllers/crops_controller_spec.rb
+++ b/spec/controllers/crops_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe CropsController do
@@ -6,9 +22,9 @@ describe CropsController do
def valid_attributes
{
- :name => "Tomato",
- :en_wikipedia_url => 'http://en.wikipedia.org/wiki/Tomato',
- :approval_status => 'approved'
+ name: "Tomato",
+ en_wikipedia_url: 'http://en.wikipedia.org/wiki/Tomato',
+ approval_status: 'approved'
}
end
@@ -39,7 +55,7 @@ describe CropsController do
describe "GET RSS feed" do
it "returns an RSS feed" do
- get :index, :format => "rss"
+ get :index, format: "rss"
response.should be_success
response.should render_template("crops/index")
response.content_type.should eq("application/rss+xml")
diff --git a/spec/controllers/forums_controller_spec.rb b/spec/controllers/forums_controller_spec.rb
index 369919ff6..6d52321a5 100644
--- a/spec/controllers/forums_controller_spec.rb
+++ b/spec/controllers/forums_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe ForumsController do
diff --git a/spec/controllers/gardens_controller_spec.rb b/spec/controllers/gardens_controller_spec.rb
index 2bba8a2f8..4e9d0fc1c 100644
--- a/spec/controllers/gardens_controller_spec.rb
+++ b/spec/controllers/gardens_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe GardensController do
@@ -6,7 +22,7 @@ describe GardensController do
def valid_attributes
member = FactoryGirl.create(:member)
- {:name => 'My Garden', :owner_id => member.id }
+ {name: 'My Garden', owner_id: member.id }
end
end
diff --git a/spec/controllers/harvests_controller_spec.rb b/spec/controllers/harvests_controller_spec.rb
index efd762368..80822c564 100644
--- a/spec/controllers/harvests_controller_spec.rb
+++ b/spec/controllers/harvests_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe HarvestsController do
@@ -6,8 +22,9 @@ describe HarvestsController do
def valid_attributes
{
- :owner_id => subject.current_member.id,
- :crop_id => FactoryGirl.create(:crop).id
+ owner_id: subject.current_member.id,
+ crop_id: FactoryGirl.create(:crop).id,
+ plant_part_id: FactoryGirl.create(:plant_part).id
}
end
@@ -17,8 +34,8 @@ describe HarvestsController do
@member2 = FactoryGirl.create(:member)
@tomato = FactoryGirl.create(:tomato)
@maize = FactoryGirl.create(:maize)
- @harvest1 = FactoryGirl.create(:harvest, :owner_id => @member1.id, :crop_id => @tomato.id)
- @harvest2 = FactoryGirl.create(:harvest, :owner_id => @member2.id, :crop_id => @maize.id)
+ @harvest1 = FactoryGirl.create(:harvest, owner_id: @member1.id, crop_id: @tomato.id)
+ @harvest2 = FactoryGirl.create(:harvest, owner_id: @member2.id, crop_id: @maize.id)
end
it "assigns all harvests as @harvests" do
@@ -27,19 +44,19 @@ describe HarvestsController do
end
it "picks up owner from params and shows owner's harvests only" do
- get :index, {:owner => @member1.slug}
+ get :index, {owner: @member1.slug}
assigns(:owner).should eq @member1
assigns(:harvests).should eq [@harvest1]
end
it "picks up crop from params and shows the harvests for the crop only" do
- get :index, {:crop => @maize.name}
+ get :index, {crop: @maize.name}
assigns(:crop).should eq @maize
assigns(:harvests).should eq [@harvest2]
end
it "generates a csv" do
- get :index, {:format => "csv"}
+ get :index, {format: "csv"}
response.status.should eq 200
end
end
@@ -47,7 +64,7 @@ describe HarvestsController do
describe "GET show" do
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
- get :show, {:id => harvest.to_param}
+ get :show, {id: harvest.to_param}
assigns(:harvest).should eq(harvest)
end
end
@@ -62,7 +79,7 @@ describe HarvestsController do
describe "GET edit" do
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
- get :edit, {:id => harvest.to_param}
+ get :edit, {id: harvest.to_param}
assigns(:harvest).should eq(harvest)
end
end
@@ -71,18 +88,18 @@ describe HarvestsController do
describe "with valid params" do
it "creates a new Harvest" do
expect {
- post :create, {:harvest => valid_attributes}
+ post :create, {harvest: valid_attributes}
}.to change(Harvest, :count).by(1)
end
it "assigns a newly created harvest as @harvest" do
- post :create, {:harvest => valid_attributes}
+ post :create, {harvest: valid_attributes}
assigns(:harvest).should be_a(Harvest)
assigns(:harvest).should be_persisted
end
it "redirects to the created harvest" do
- post :create, {:harvest => valid_attributes}
+ post :create, {harvest: valid_attributes}
response.should redirect_to(Harvest.last)
end
end
@@ -91,14 +108,14 @@ describe HarvestsController do
it "assigns a newly created but unsaved harvest as @harvest" do
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
- post :create, {:harvest => { "crop_id" => "invalid value" }}
+ post :create, {harvest: { "crop_id" => "invalid value" }}
assigns(:harvest).should be_a_new(Harvest)
end
it "re-renders the 'new' template" do
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
- post :create, {:harvest => { "crop_id" => "invalid value" }}
+ post :create, {harvest: { "crop_id" => "invalid value" }}
response.should render_template("new")
end
end
@@ -113,18 +130,18 @@ describe HarvestsController do
# receives the :update message with whatever params are
# submitted in the request.
Harvest.any_instance.should_receive(:update).with({ "crop_id" => "1" })
- put :update, {:id => harvest.to_param, :harvest => { "crop_id" => "1" }}
+ put :update, {id: harvest.to_param, harvest: { "crop_id" => "1" }}
end
it "assigns the requested harvest as @harvest" do
harvest = Harvest.create! valid_attributes
- put :update, {:id => harvest.to_param, :harvest => valid_attributes}
+ put :update, {id: harvest.to_param, harvest: valid_attributes}
assigns(:harvest).should eq(harvest)
end
it "redirects to the harvest" do
harvest = Harvest.create! valid_attributes
- put :update, {:id => harvest.to_param, :harvest => valid_attributes}
+ put :update, {id: harvest.to_param, harvest: valid_attributes}
response.should redirect_to(harvest)
end
end
@@ -134,7 +151,7 @@ describe HarvestsController do
harvest = Harvest.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
- put :update, {:id => harvest.to_param, :harvest => { "crop_id" => "invalid value" }}
+ put :update, {id: harvest.to_param, harvest: { "crop_id" => "invalid value" }}
assigns(:harvest).should eq(harvest)
end
@@ -142,7 +159,7 @@ describe HarvestsController do
harvest = Harvest.create! valid_attributes
# Trigger the behavior that occurs when invalid params are submitted
Harvest.any_instance.stub(:save).and_return(false)
- put :update, {:id => harvest.to_param, :harvest => { "crop_id" => "invalid value" }}
+ put :update, {id: harvest.to_param, harvest: { "crop_id" => "invalid value" }}
response.should render_template("edit")
end
end
@@ -152,13 +169,13 @@ describe HarvestsController do
it "destroys the requested harvest" do
harvest = Harvest.create! valid_attributes
expect {
- delete :destroy, {:id => harvest.to_param}
+ delete :destroy, {id: harvest.to_param}
}.to change(Harvest, :count).by(-1)
end
it "redirects to the harvests list" do
harvest = Harvest.create! valid_attributes
- delete :destroy, {:id => harvest.to_param}
+ delete :destroy, {id: harvest.to_param}
response.should redirect_to(harvests_url)
end
end
diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb
index da5edc384..8d4aa3569 100644
--- a/spec/controllers/home_controller_spec.rb
+++ b/spec/controllers/home_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe HomeController do
diff --git a/spec/controllers/member_controller_spec.rb b/spec/controllers/member_controller_spec.rb
index 35d5b0c6d..be178341e 100644
--- a/spec/controllers/member_controller_spec.rb
+++ b/spec/controllers/member_controller_spec.rb
@@ -1,12 +1,28 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe MembersController do
before :each do
@member = FactoryGirl.create(:member)
- @posts = [ FactoryGirl.create(:post, :author => @member) ]
- @twitter_auth = FactoryGirl.create(:authentication, :member => @member)
- @flickr_auth = FactoryGirl.create(:flickr_authentication, :member => @member)
+ @posts = [ FactoryGirl.create(:post, author: @member) ]
+ @twitter_auth = FactoryGirl.create(:authentication, member: @member)
+ @flickr_auth = FactoryGirl.create(:flickr_authentication, member: @member)
end
describe "GET index" do
@@ -18,7 +34,7 @@ describe MembersController do
describe "GET JSON index" do
it "provides JSON for members" do
- get :index, :format => 'json'
+ get :index, format: 'json'
response.should be_success
end
end
@@ -26,39 +42,39 @@ describe MembersController do
describe "GET show" do
it "provides JSON for member profile" do
- get :show, { :id => @member.id , :format => 'json' }
+ get :show, { id: @member.id , format: 'json' }
response.should be_success
end
it "assigns @posts with the member's posts" do
- get :show, {:id => @member.id}
+ get :show, {id: @member.id}
assigns(:posts).should eq(@posts)
end
it "assigns @twitter_auth" do
- get :show, {:id => @member.id}
+ get :show, {id: @member.id}
assigns(:twitter_auth).should eq(@twitter_auth)
end
it "assigns @flickr_auth" do
- get :show, {:id => @member.id}
+ get :show, {id: @member.id}
assigns(:flickr_auth).should eq(@flickr_auth)
end
it "doesn't show completely nonsense members" do
- lambda { get :show, {:id => 9999} }.should raise_error
+ lambda { get :show, {id: 9999} }.should raise_error(ActiveRecord::RecordNotFound)
end
it "doesn't show unconfirmed members" do
@member2 = FactoryGirl.create(:unconfirmed_member)
- lambda { get :show, {:id => @member2.id} }.should raise_error
+ lambda { get :show, {id: @member2.id} }.should raise_error(ActiveRecord::RecordNotFound)
end
end
describe "GET member's RSS feed" do
it "returns an RSS feed" do
- get :show, { :id => @member.to_param, :format => "rss" }
+ get :show, { id: @member.to_param, format: "rss" }
response.should be_success
response.should render_template("members/show")
response.content_type.should eq("application/rss+xml")
diff --git a/spec/controllers/notifications_controller_spec.rb b/spec/controllers/notifications_controller_spec.rb
index d55b7df26..a7737dad2 100644
--- a/spec/controllers/notifications_controller_spec.rb
+++ b/spec/controllers/notifications_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe NotificationsController do
@@ -31,7 +47,7 @@ describe NotificationsController do
describe "GET index" do
it "assigns all notifications as @notifications" do
- notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id)
+ notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
get :index, {}
assigns(:notifications).should eq([notification])
end
@@ -39,36 +55,34 @@ describe NotificationsController do
describe "GET show" do
it "assigns the requested notification as @notification" do
- notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id)
- get :show, {:id => notification.to_param}
+ notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
+ get :show, {id: notification.to_param}
assigns(:notification).should eq(notification)
end
- it "assigns the reply link for a PM" do
- notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id, :post_id => nil)
- subject = "Re: " + notification.subject
-
- get :show, {:id => notification.to_param}
- assigns(:reply_link).should_not be_nil
- assigns(:reply_link).should eq new_notification_url(
- :recipient_id => notification.sender_id,
- :subject => subject
- )
- end
-
it "assigns the reply link for a post comment" do
- notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id)
+ notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
- get :show, {:id => notification.to_param}
+ get :show, {id: notification.to_param}
assigns(:reply_link).should_not be_nil
assigns(:reply_link).should eq new_comment_url(
- :post_id => notification.post.id
+ post_id: notification.post.id
)
end
+ it "marks notifications as read" do
+ notification = FactoryGirl.create(:notification, recipient_id: subject.current_member.id)
+ get :show, {id: notification.to_param}
+ # we need to fetch it from the db again, can't test against the old one
+ n = Notification.find(notification.id)
+ n.read.should eq true
+ end
+ end
+
+ describe "GET reply" do
it "marks notifications as read" do
notification = FactoryGirl.create(:notification, :recipient_id => subject.current_member.id)
- get :show, {:id => notification.to_param}
+ get :reply, {:id => notification.to_param}
# we need to fetch it from the db again, can't test against the old one
n = Notification.find(notification.id)
n.read.should eq true
@@ -78,7 +92,7 @@ describe NotificationsController do
describe "GET new" do
it "assigns a recipient" do
@recipient = FactoryGirl.create(:member)
- get :new, {:recipient_id => @recipient.id }
+ get :new, {recipient_id: @recipient.id }
assigns(:recipient).should be_an_instance_of(Member)
end
end
@@ -87,7 +101,7 @@ describe NotificationsController do
describe "with valid params" do
it "redirects to the recipient's profile" do
@recipient = FactoryGirl.create(:member)
- post :create, { :notification => { :recipient_id => @recipient.id, :subject => 'foo' } }
+ post :create, { notification: { recipient_id: @recipient.id, subject: 'foo' } }
response.should redirect_to(notifications_path)
end
end
diff --git a/spec/controllers/order_items_controller_spec.rb b/spec/controllers/order_items_controller_spec.rb
index c8d23a4fd..f081c85b7 100644
--- a/spec/controllers/order_items_controller_spec.rb
+++ b/spec/controllers/order_items_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe OrderItemsController do
@@ -8,22 +24,22 @@ describe OrderItemsController do
@member = FactoryGirl.create(:member)
sign_in @member
@product = FactoryGirl.create(:product)
- @order = FactoryGirl.create(:order, :member => @member)
+ @order = FactoryGirl.create(:order, member: @member)
@order_item = FactoryGirl.create(:order_item,
- :order => @order,
- :product => @product,
- :price => @product.min_price
+ order: @order,
+ product: @product,
+ price: @product.min_price
)
end
describe "POST create" do
it "redirects to order" do
- @order = FactoryGirl.create(:order, :member => @member)
- post :create, {:order_item => {
- :order_id => @order.id,
- :product_id => @product.id,
- :price => @product.min_price
+ @order = FactoryGirl.create(:order, member: @member)
+ post :create, {order_item: {
+ order_id: @order.id,
+ product_id: @product.id,
+ price: @product.min_price
}}
response.should redirect_to(OrderItem.last.order)
end
@@ -33,9 +49,9 @@ describe OrderItemsController do
sign_in @member
@product = FactoryGirl.create(:product)
expect {
- post :create, {:order_item => {
- :product_id => @product.id,
- :price => @product.min_price
+ post :create, {order_item: {
+ product_id: @product.id,
+ price: @product.min_price
}}
}.to change(Order, :count).by(1)
OrderItem.last.order.should be_an_instance_of Order
@@ -43,13 +59,13 @@ describe OrderItemsController do
describe "with non-int price" do
it "converts 3.33 to 333 cents" do
- @order = FactoryGirl.create(:order, :member => @member)
- @product = FactoryGirl.create(:product, :min_price => 1)
+ @order = FactoryGirl.create(:order, member: @member)
+ @product = FactoryGirl.create(:product, min_price: 1)
expect {
- post :create, {:order_item => {
- :order_id => @order.id,
- :product_id => @product.id,
- :price => 3.33
+ post :create, {order_item: {
+ order_id: @order.id,
+ product_id: @product.id,
+ price: 3.33
}}
}.to change(OrderItem, :count).by(1)
OrderItem.last.price.should eq 333
diff --git a/spec/controllers/orders_controller_spec.rb b/spec/controllers/orders_controller_spec.rb
index d01f37f92..81e74a5b5 100644
--- a/spec/controllers/orders_controller_spec.rb
+++ b/spec/controllers/orders_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe OrdersController do
@@ -16,8 +32,8 @@ describe OrdersController do
it 'sets the referral_code' do
member = FactoryGirl.create(:member)
sign_in member
- order = Order.create!(:member_id => member.id)
- get :checkout, {:id => order.to_param, :referral_code => 'FOOBAR'}
+ order = Order.create!(member_id: member.id)
+ get :checkout, {id: order.to_param, referral_code: 'FOOBAR'}
order.reload
order.referral_code.should eq 'FOOBAR'
end
@@ -25,8 +41,8 @@ describe OrdersController do
it "redirects to Paypal" do
member = FactoryGirl.create(:member)
sign_in member
- order = Order.create!(:member_id => member.id)
- get :checkout, {:id => order.to_param}
+ order = Order.create!(member_id: member.id)
+ get :checkout, {id: order.to_param}
response.status.should eq 302
response.redirect_url.should match /paypal\.com/
end
@@ -36,8 +52,8 @@ describe OrdersController do
it "assigns the requested order as @order" do
member = FactoryGirl.create(:member)
sign_in member
- order = Order.create!(:member_id => member.id)
- get :complete, {:id => order.to_param}
+ order = Order.create!(member_id: member.id)
+ get :complete, {id: order.to_param}
assigns(:order).should eq(order)
end
end
@@ -46,8 +62,8 @@ describe OrdersController do
it "redirects to the shop" do
member = FactoryGirl.create(:member)
sign_in member
- order = Order.create!(:member_id => member.id)
- delete :destroy, {:id => order.id}
+ order = Order.create!(member_id: member.id)
+ delete :destroy, {id: order.id}
response.should redirect_to(shop_url)
end
end
diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb
index e231c8b96..e73ba5317 100644
--- a/spec/controllers/photos_controller_spec.rb
+++ b/spec/controllers/photos_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe PhotosController do
@@ -31,31 +47,31 @@ describe PhotosController do
end
it "assigns the flickr auth as @flickr_auth" do
- @auth = FactoryGirl.create(:flickr_authentication, :member => @member)
+ @auth = FactoryGirl.create(:flickr_authentication, member: @member)
get :new, {}
assigns(:flickr_auth).should be_an_instance_of(Authentication)
end
it "assigns a planting id" do
- get :new, { :type => "planting", :id => 5 }
+ get :new, { type: "planting", id: 5 }
assigns(:id).should eq "5"
assigns(:type).should eq "planting"
end
it "assigns a harvest id" do
- get :new, { :type => "harvest", :id => 5 }
+ get :new, { type: "harvest", id: 5 }
assigns(:id).should eq "5"
assigns(:type).should eq "harvest"
end
it "assigns a garden id" do
- get :new, { :type => "garden", :id => 5 }
+ get :new, { type: "garden", id: 5 }
assigns(:id).should eq "5"
assigns(:type).should eq "garden"
end
it "assigns the current set as @current_set" do
- get :new, { :set => 'foo' }
+ get :new, { set: 'foo' }
assigns(:current_set).should eq "foo"
end
@@ -64,12 +80,12 @@ describe PhotosController do
describe "POST create" do
before(:each) do
Photo.any_instance.stub(:flickr_metadata).and_return( {
- :title => "A Heartbreaking work of staggering genius",
- :license_name => "CC-BY",
- :license_url => "http://example.com/aybpl",
- :thumbnail_url => "http://example.com/thumb.jpg",
- :fullsize_url => "http://example.com/full.jpg",
- :link_url => "http://example.com"
+ title: "A Heartbreaking work of staggering genius",
+ license_name: "CC-BY",
+ license_url: "http://example.com/aybpl",
+ thumbnail_url: "http://example.com/thumb.jpg",
+ fullsize_url: "http://example.com/full.jpg",
+ link_url: "http://example.com"
})
end
@@ -78,63 +94,63 @@ describe PhotosController do
it "attaches the photo to a planting" do
member = FactoryGirl.create(:member)
controller.stub(:current_member) { member }
- garden = FactoryGirl.create(:garden, :owner => member)
- planting = FactoryGirl.create(:planting, :garden => garden, :owner => member)
- photo = FactoryGirl.create(:photo, :owner => member)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "planting",
- :id => planting.id }
+ garden = FactoryGirl.create(:garden, owner: member)
+ planting = FactoryGirl.create(:planting, garden: garden, owner: member)
+ photo = FactoryGirl.create(:photo, owner: member)
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "planting",
+ id: planting.id }
Photo.last.plantings.first.should eq planting
end
it "doesn't attach a photo to a planting twice" do
member = FactoryGirl.create(:member)
controller.stub(:current_member) { member }
- garden = FactoryGirl.create(:garden, :owner => member)
- planting = FactoryGirl.create(:planting, :garden => garden, :owner => member)
- photo = FactoryGirl.create(:photo, :owner => member)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "planting",
- :id => planting.id }
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "planting",
- :id => planting.id }
- Photo.last.plantings.count.should eq 1
+ garden = FactoryGirl.create(:garden, owner: member)
+ planting = FactoryGirl.create(:planting, garden: garden, owner: member)
+ photo = FactoryGirl.create(:photo, owner: member)
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "planting",
+ id: planting.id }
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "planting",
+ id: planting.id }
+ Photo.last.plantings.size.should eq 1
end
it "attaches the photo to a harvest" do
member = FactoryGirl.create(:member)
controller.stub(:current_member) { member }
- harvest = FactoryGirl.create(:harvest, :owner => member)
- photo = FactoryGirl.create(:photo, :owner => member)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "harvest",
- :id => harvest.id }
+ harvest = FactoryGirl.create(:harvest, owner: member)
+ photo = FactoryGirl.create(:photo, owner: member)
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "harvest",
+ id: harvest.id }
Photo.last.harvests.first.should eq harvest
end
it "doesn't attach a photo to a harvest twice" do
member = FactoryGirl.create(:member)
controller.stub(:current_member) { member }
- harvest = FactoryGirl.create(:harvest, :owner => member)
- photo = FactoryGirl.create(:photo, :owner => member)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "harvest",
- :id => harvest.id }
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "harvest",
- :id => harvest.id }
- Photo.last.harvests.count.should eq 1
+ harvest = FactoryGirl.create(:harvest, owner: member)
+ photo = FactoryGirl.create(:photo, owner: member)
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "harvest",
+ id: harvest.id }
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "harvest",
+ id: harvest.id }
+ Photo.last.harvests.size.should eq 1
end
end
describe "for the second time" do
it "does not add a photo twice" do
expect {
- post :create, {:photo => { :flickr_photo_id => 1 } }
+ post :create, {photo: { flickr_photo_id: 1 } }
}.to change(Photo, :count).by(1)
expect {
- post :create, {:photo => { :flickr_photo_id => 1 } }
+ post :create, {photo: { flickr_photo_id: 1 } }
}.to change(Photo, :count).by(0)
end
end
@@ -143,23 +159,23 @@ describe PhotosController do
it "creates the planting/photo link" do
member = FactoryGirl.create(:member)
controller.stub(:current_member) { member }
- garden = FactoryGirl.create(:garden, :owner => member)
- planting = FactoryGirl.create(:planting, :garden => garden, :owner => member)
- photo = FactoryGirl.create(:photo, :owner => member)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "planting",
- :id => planting.id }
+ garden = FactoryGirl.create(:garden, owner: member)
+ planting = FactoryGirl.create(:planting, garden: garden, owner: member)
+ photo = FactoryGirl.create(:photo, owner: member)
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "planting",
+ id: planting.id }
Photo.last.plantings.first.should eq planting
end
it "creates the harvest/photo link" do
member = FactoryGirl.create(:member)
controller.stub(:current_member) { member }
- harvest = FactoryGirl.create(:harvest, :owner => member)
- photo = FactoryGirl.create(:photo, :owner => member)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "harvest",
- :id => harvest.id }
+ harvest = FactoryGirl.create(:harvest, owner: member)
+ photo = FactoryGirl.create(:photo, owner: member)
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "harvest",
+ id: harvest.id }
Photo.last.harvests.first.should eq harvest
end
end
@@ -169,9 +185,9 @@ describe PhotosController do
# members will be auto-created, and different
planting = FactoryGirl.create(:planting)
photo = FactoryGirl.create(:photo)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "planting",
- :id => planting.id }
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "planting",
+ id: planting.id }
Photo.last.plantings.first.should_not eq planting
end
@@ -179,9 +195,9 @@ describe PhotosController do
# members will be auto-created, and different
harvest = FactoryGirl.create(:harvest)
photo = FactoryGirl.create(:photo)
- post :create, {:photo => { :flickr_photo_id => photo.flickr_photo_id },
- :type => "harvest",
- :id => harvest.id }
+ post :create, {photo: { flickr_photo_id: photo.flickr_photo_id },
+ type: "harvest",
+ id: harvest.id }
Photo.last.harvests.first.should_not eq harvest
end
end
diff --git a/spec/controllers/places_controller_spec.rb b/spec/controllers/places_controller_spec.rb
index 0c83c206a..4c8c34d3c 100644
--- a/spec/controllers/places_controller_spec.rb
+++ b/spec/controllers/places_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe PlacesController do
@@ -12,12 +28,12 @@ describe PlacesController do
end
it "assigns place name" do
- get :show, { :place => @member_london.location }
+ get :show, { place: @member_london.location }
assigns(:place).should eq @member_london.location
end
it "assigns nearby members" do
- get :show, { :place => @member_london.location }
+ get :show, { place: @member_london.location }
assigns(:nearby_members).should eq [@member_london, @member_south_pole]
end
@@ -25,7 +41,7 @@ describe PlacesController do
describe "GET search" do
it "redirects to the new place" do
- get :search, { :new_place => "foo" }
+ get :search, { new_place: "foo" }
response.should redirect_to place_path("foo")
end
end
diff --git a/spec/controllers/plant_parts_controller_spec.rb b/spec/controllers/plant_parts_controller_spec.rb
index e813e0f38..75b2ad53d 100644
--- a/spec/controllers/plant_parts_controller_spec.rb
+++ b/spec/controllers/plant_parts_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe PlantPartsController do
diff --git a/spec/controllers/plantings_controller_spec.rb b/spec/controllers/plantings_controller_spec.rb
index aa6fcbe4e..68514b634 100644
--- a/spec/controllers/plantings_controller_spec.rb
+++ b/spec/controllers/plantings_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe PlantingsController do
@@ -6,8 +22,8 @@ describe PlantingsController do
def valid_attributes
{
- :garden_id => FactoryGirl.create(:garden, :owner => subject.current_member).id,
- :crop_id => FactoryGirl.create(:crop).id
+ garden_id: FactoryGirl.create(:garden, owner: subject.current_member).id,
+ crop_id: FactoryGirl.create(:crop).id
}
end
@@ -17,8 +33,8 @@ describe PlantingsController do
@member2 = FactoryGirl.create(:member)
@tomato = FactoryGirl.create(:tomato)
@maize = FactoryGirl.create(:maize)
- @planting1 = FactoryGirl.create(:planting, :crop => @tomato, :owner => @member1)
- @planting2 = FactoryGirl.create(:planting, :crop => @maize, :owner => @member2)
+ @planting1 = FactoryGirl.create(:planting, crop: @tomato, owner: @member1)
+ @planting2 = FactoryGirl.create(:planting, crop: @maize, owner: @member2)
end
it "assigns all plantings as @plantings" do
@@ -27,13 +43,13 @@ describe PlantingsController do
end
it "picks up owner from params and shows owner's plantings only" do
- get :index, {:owner => @member1.slug}
+ get :index, {owner: @member1.slug}
assigns(:owner).should eq @member1
assigns(:plantings).should eq [@planting1]
end
it "picks up crop from params and shows the plantings for the crop only" do
- get :index, {:crop => @maize.name}
+ get :index, {crop: @maize.name}
assigns(:crop).should eq @maize
assigns(:plantings).should eq [@planting2]
end
@@ -43,7 +59,7 @@ describe PlantingsController do
it "picks up crop from params" do
crop = FactoryGirl.create(:crop)
- get :new, {:crop_id => crop.id}
+ get :new, {crop_id: crop.id}
assigns(:crop).should eq(crop)
end
@@ -54,8 +70,8 @@ describe PlantingsController do
it "picks up garden from params" do
member = FactoryGirl.create(:member)
- garden = FactoryGirl.create(:garden, :owner => member)
- get :new, {:garden_id => garden.id}
+ garden = FactoryGirl.create(:garden, owner: member)
+ get :new, {garden_id: garden.id}
assigns(:garden).should eq(garden)
end
@@ -70,7 +86,7 @@ describe PlantingsController do
end
it "sets the owner automatically" do
- post :create, { :planting => valid_attributes }
+ post :create, { planting: valid_attributes }
assigns(:planting).owner.should eq subject.current_member
end
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index 8121b318e..b53a67f40 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe PostsController do
@@ -6,12 +22,12 @@ describe PostsController do
def valid_attributes
member = FactoryGirl.create(:member)
- { :author_id => member.id, :subject => "blah", :body => "blah blah" }
+ { author_id: member.id, subject: "blah", body: "blah blah" }
end
describe "GET RSS feed" do
it "returns an RSS feed" do
- get :index, :format => "rss"
+ get :index, format: "rss"
response.should be_success
response.should render_template("posts/index")
response.content_type.should eq("application/rss+xml")
@@ -21,7 +37,7 @@ describe PostsController do
describe "GET RSS feed for individual post" do
it "returns an RSS feed" do
post = Post.create! valid_attributes
- get :show, { :format => "rss", :id => post.slug }
+ get :show, { format: "rss", id: post.slug }
response.should be_success
response.should render_template("posts/show")
response.content_type.should eq("application/rss+xml")
diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb
index 5804ad09d..f8ca75083 100644
--- a/spec/controllers/products_controller_spec.rb
+++ b/spec/controllers/products_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe ProductsController do
@@ -6,9 +22,9 @@ describe ProductsController do
def valid_attributes
{
- :name => "product name",
- :description => 'some description',
- :min_price => 9.99
+ name: "product name",
+ description: 'some description',
+ min_price: 9.99
}
end
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index 8c0a669b4..ac9990254 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe RegistrationsController do
@@ -16,13 +32,13 @@ describe RegistrationsController do
end
it "picks up the twitter auth" do
- @auth = FactoryGirl.create(:authentication, :member => @member)
+ @auth = FactoryGirl.create(:authentication, member: @member)
get :edit
assigns(:twitter_auth).should eq @auth
end
it "picks up the flickr auth" do
- @auth = FactoryGirl.create(:flickr_authentication, :member => @member)
+ @auth = FactoryGirl.create(:flickr_authentication, member: @member)
get :edit
assigns(:flickr_auth).should eq @auth
end
diff --git a/spec/controllers/robots_controller_spec.rb b/spec/controllers/robots_controller_spec.rb
new file mode 100644
index 000000000..16220cfe2
--- /dev/null
+++ b/spec/controllers/robots_controller_spec.rb
@@ -0,0 +1,56 @@
+require 'rails_helper'
+
+describe RobotsController do
+ describe '#robots' do
+ let(:production_filename) { 'config/robots.txt' }
+ let(:staging_filename) { 'config/robots.staging.txt' }
+
+ before do
+ @request.host = "#{ subdomain }.localhost.com"
+ end
+
+ context 'subdomain is staging' do
+ let(:subdomain) { 'staging' }
+
+ it 'loads the staging robots.txt file' do
+ get :robots
+
+ expect(response).to be_success
+ expect(response.body).to eq(File.read(staging_filename))
+ end
+ end
+
+ context 'subdomain is www' do
+ let(:subdomain) { 'www' }
+
+ it 'loads the production robots.txt file' do
+ get :robots
+
+ expect(response).to be_success
+ expect(response.body).to eq(File.read(production_filename))
+ end
+ end
+
+ context 'subdomain is not present' do
+ let(:subdomain) { '' }
+
+ it 'loads the production robots.txt file' do
+ get :robots
+
+ expect(response).to be_success
+ expect(response.body).to eq(File.read(production_filename))
+ end
+ end
+
+ context 'subdomain is nonsense' do
+ let(:subdomain) { '1874ajnfien' }
+
+ it 'loads the production robots.txt file' do
+ get :robots
+
+ expect(response).to be_success
+ expect(response.body).to eq(File.read(production_filename))
+ end
+ end
+ end
+end
diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb
index f34bb79e3..7a5e5fce8 100644
--- a/spec/controllers/roles_controller_spec.rb
+++ b/spec/controllers/roles_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe RolesController do
diff --git a/spec/controllers/scientific_names_controller_spec.rb b/spec/controllers/scientific_names_controller_spec.rb
index 45dd92066..ab40494fb 100644
--- a/spec/controllers/scientific_names_controller_spec.rb
+++ b/spec/controllers/scientific_names_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe ScientificNamesController do
@@ -9,12 +25,12 @@ describe ScientificNamesController do
end
def valid_attributes
- { :scientific_name => 'Solanum lycopersicum', :crop_id => @crop.id }
+ { scientific_name: 'Solanum lycopersicum', crop_id: @crop.id }
end
describe "GET new" do
it "assigns crop if specified" do
- get :new, { :crop_id => 1 }
+ get :new, { crop_id: 1 }
assigns(:crop).should be_an_instance_of Crop
end
diff --git a/spec/controllers/seeds_controller_spec.rb b/spec/controllers/seeds_controller_spec.rb
index 7b0da6593..bfb880477 100644
--- a/spec/controllers/seeds_controller_spec.rb
+++ b/spec/controllers/seeds_controller_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe SeedsController do
describe "GET index" do
it "picks up owner from params" do
owner = FactoryGirl.create(:member)
- get :index, {:owner => owner.slug}
+ get :index, {owner: owner.slug}
assigns(:owner).should eq(owner)
end
end
diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb
index 626757b52..a02d4fbad 100644
--- a/spec/controllers/shop_controller_spec.rb
+++ b/spec/controllers/shop_controller_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe ShopController do
@@ -26,7 +42,7 @@ describe ShopController do
it "assigns @order as current_order if there is one" do
@member = FactoryGirl.create(:member)
sign_in @member
- @order = FactoryGirl.create(:order, :member => @member)
+ @order = FactoryGirl.create(:order, member: @member)
get :index, {}
assigns(:order).should eq @order
end
diff --git a/spec/custom_matchers.rb b/spec/custom_matchers.rb
new file mode 100644
index 000000000..6d52388bb
--- /dev/null
+++ b/spec/custom_matchers.rb
@@ -0,0 +1,7 @@
+require 'rspec/expectations'
+
+RSpec::Matchers.define :have_optional do | expected |
+ match do |actual|
+ actual.has_selector? "#{expected} + span", text: '(Optional)'
+ end
+end
diff --git a/spec/factories/crop.rb b/spec/factories/crop.rb
index 4be8c4f09..c2ba35046 100644
--- a/spec/factories/crop.rb
+++ b/spec/factories/crop.rb
@@ -54,6 +54,10 @@ FactoryGirl.define do
factory :uppercasecrop do
name "Swiss chard"
end
+
+ factory :autoloaded_crop do
+ creator "cropbot"
+ end
#for testing crop request
factory :crop_request do
diff --git a/spec/factories/harvests.rb b/spec/factories/harvests.rb
index 71356388a..20a3affcd 100644
--- a/spec/factories/harvests.rb
+++ b/spec/factories/harvests.rb
@@ -12,4 +12,12 @@ FactoryGirl.define do
weight_unit "kg"
description "A lovely harvest"
end
+
+ trait :long_description do
+ description "This is a very long description that is so very long that it will need to be cut off"
+ end
+
+ trait :no_description do
+ description ""
+ end
end
diff --git a/spec/features/admin/account_types_spec.rb b/spec/features/admin/account_types_spec.rb
index b56144344..dac241586 100644
--- a/spec/features/admin/account_types_spec.rb
+++ b/spec/features/admin/account_types_spec.rb
@@ -1,51 +1,58 @@
require 'rails_helper'
-feature "account types" do
+feature "account types", js: true do
context "admin user" do
- before(:each) do
- @member = FactoryGirl.create(:admin_member)
- visit root_path
- click_link 'Sign in'
- fill_in 'Login', :with => @member.login_name
- fill_in 'Password', :with => @member.password
- click_button 'Sign in'
+ let(:member) { create :admin_member }
+ let(:account_type) { create :account_type }
+
+ background do
+ login_as member
end
- scenario "navigating to account type admin" do
+ scenario "navigating to account type admin with JavaScript on" do
visit root_path
+ # Extra click for the expandable login menu
+ click_link member.login_name
click_link "Admin"
- current_path.should eq admin_path
+ expect(current_path).to eq admin_path
click_link "Account types"
- current_path.should eq account_types_path
+ expect(current_path).to eq account_types_path
+ end
+
+ scenario "navigating to account type admin without JavaScript - Accessility version", js: false do
+ visit root_path
+ # Extra link not needed as menu is already expanded
+ click_link "Admin"
+ expect(current_path).to eq admin_path
+ click_link "Account types"
+ expect(current_path).to eq account_types_path
end
scenario "adding an account type" do
visit account_types_path
click_link "New Account type"
- current_path.should eq new_account_type_path
- fill_in 'Name', :with => 'Guest'
+ expect(current_path).to eq new_account_type_path
+ fill_in 'Name', with: 'Guest'
click_button 'Save'
- current_path.should eq account_type_path(AccountType.last)
- page.should have_content 'Account type was successfully created'
+ expect(current_path).to eq account_type_path(AccountType.last)
+ expect(page).to have_content 'Account type was successfully created'
end
scenario 'editing account type' do
- a = FactoryGirl.create(:account_type)
- visit account_type_path(a)
+ visit account_type_path account_type
click_link 'Edit'
- fill_in 'Name', :with => 'Something else'
+ fill_in 'Name', with: 'Something else'
click_button 'Save'
- current_path.should eq account_type_path(a)
- page.should have_content 'Account type was successfully updated'
- page.should have_content 'Something else'
+ expect(current_path).to eq account_type_path(account_type)
+ expect(page).to have_content 'Account type was successfully updated'
+ expect(page).to have_content 'Something else'
end
scenario 'deleting account type' do
- a = FactoryGirl.create(:account_type)
- visit account_type_path(a)
+ visit account_type_path account_type
click_link 'Delete'
- current_path.should eq account_types_path
- page.should have_content 'Account type was successfully deleted'
+ expect(current_path).to eq account_types_path
+ expect(page).to have_content 'Account type was successfully deleted'
end
end
end
diff --git a/spec/features/admin/forums_spec.rb b/spec/features/admin/forums_spec.rb
index e9f8a43f9..a385289a6 100644
--- a/spec/features/admin/forums_spec.rb
+++ b/spec/features/admin/forums_spec.rb
@@ -1,56 +1,64 @@
require 'rails_helper'
-feature "forums" do
- context "admin user" do
- before(:each) do
- @member = FactoryGirl.create(:admin_member)
- visit root_path
- click_link 'Sign in'
- fill_in 'Login', :with => @member.login_name
- fill_in 'Password', :with => @member.password
- click_button 'Sign in'
+feature "forums", js: true do
+ context "as an admin user" do
+ let(:member) { create :admin_member }
+ let(:forum) { create :forum }
+
+ background do
+ login_as member
end
- scenario "navigating to forum admin" do
+ scenario "navigating to forum admin without js", js: false do
visit root_path
click_link "Admin"
- current_path.should eq admin_path
+ expect(current_path).to eq admin_path
within 'ul#admin_links' do
click_link "Forums"
end
- current_path.should eq forums_path
- page.should have_content "New forum"
+ expect(current_path).to eq forums_path
+ expect(page).to have_content "New forum"
+ end
+
+ scenario "navigating to forum admin with js" do
+ visit root_path
+ click_link member.login_name
+ click_link "Admin"
+ expect(current_path).to eq admin_path
+ within 'ul#admin_links' do
+ click_link "Forums"
+ end
+ expect(current_path).to eq forums_path
+ expect(page).to have_content "New forum"
end
scenario "adding a forum" do
visit forums_path
click_link "New forum"
- current_path.should eq new_forum_path
- fill_in 'Name', :with => 'Discussion'
- fill_in 'Description', :with => "this is a new forum"
+ expect(current_path).to eq new_forum_path
+ fill_in 'Name', with: 'Discussion'
+ fill_in 'Description', with: "this is a new forum"
click_button 'Save'
- current_path.should eq forum_path(Forum.last)
- page.should have_content 'Forum was successfully created'
+ expect(current_path).to eq forum_path(Forum.last)
+ expect(page).to have_content 'Forum was successfully created'
end
scenario 'editing forum' do
- f = FactoryGirl.create(:forum)
- visit forum_path(f)
+ visit forum_path forum
click_link 'Edit'
- fill_in 'Name', :with => 'Something else'
+ fill_in 'Name', with: 'Something else'
click_button 'Save'
- f.reload
- current_path.should eq forum_path(f)
- page.should have_content 'Forum was successfully updated'
- page.should have_content 'Something else'
+ forum.reload
+ expect(current_path).to eq forum_path(forum)
+ expect(page).to have_content 'Forum was successfully updated'
+ expect(page).to have_content 'Something else'
end
scenario 'deleting forum' do
- f = FactoryGirl.create(:forum)
- visit forum_path(f)
+ visit forum_path forum
click_link 'Delete'
- current_path.should eq forums_path
- page.should have_content 'Forum was successfully deleted'
+ expect(current_path).to eq forums_path
+ expect(page).to have_content 'Forum was successfully deleted'
end
end
end
diff --git a/spec/features/admin/products.rb b/spec/features/admin/products.rb
deleted file mode 100644
index 2e85ead60..000000000
--- a/spec/features/admin/products.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-require 'rails_helper'
-
-feature "products" do
- context "admin user" do
- let(:member) { FactoryGirl.create(:admin_member) }
- background do
- login_as(member)
- end
-
- scenario "navigating to product admin" do
- visit admin_path
- click_link "Products"
- current_path.should eq products_path
- end
-
- scenario "adding a product" do
- visit products_path
- click_link "New Product"
- current_path.should eq new_product_path
- fill_in 'Name', :with => 'Special offer'
- # note that failing to fill in a mandatory field has a messy error. This is not a priority defect but should be raised at some point.
- fill_in 'Minimum price', :with => '150'
- click_button 'Save'
- current_path.should eq product_path(Product.last)
- page.should have_content 'Product was successfully created'
- end
-
- scenario 'editing product' do
- p = FactoryGirl.create(:product)
- visit product_path(p)
- click_link 'Edit'
- fill_in 'Name', :with => 'Something else'
- click_button 'Save'
- current_path.should eq product_path(p)
- page.should have_content 'Product was successfully updated'
- page.should have_content 'Something else'
- end
-
- scenario 'deleting product'
- # this isn't possible. Should it be?
- end
-end
diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb
new file mode 100644
index 000000000..0fc9bdb5a
--- /dev/null
+++ b/spec/features/admin/products_spec.rb
@@ -0,0 +1,43 @@
+require 'rails_helper'
+
+feature "products" do
+ context "admin user" do
+ let(:member) { create :admin_member }
+ let(:product) { create :product }
+
+ background do
+ login_as member
+ end
+
+ scenario "navigating to product admin" do
+ visit admin_path
+ click_link "Products"
+ expect(current_path).to eq products_path
+ end
+
+ scenario "adding a product" do
+ visit products_path
+ click_link "New Product"
+ expect(current_path).to eq new_product_path
+ fill_in 'Name', with: 'Special offer'
+ # note that failing to fill in a mandatory field has a messy error. This is not a priority defect but should be raised at some point.
+ fill_in 'Minimum price', with: '150'
+ click_button 'Save'
+ expect(current_path).to eq product_path(Product.last)
+ expect(page).to have_content 'Product was successfully created'
+ end
+
+ scenario 'editing product' do
+ visit product_path product
+ click_link 'Edit'
+ fill_in 'Name', with: 'Something else'
+ click_button 'Save'
+ expect(current_path).to eq product_path(product)
+ expect(page).to have_content 'Product was successfully updated'
+ expect(page).to have_content 'Something else'
+ end
+
+ scenario 'deleting product'
+ # this isn't possible. Should it be?
+ end
+end
diff --git a/spec/features/cms_spec.rb b/spec/features/cms_spec.rb
index fb3f2ca93..ad10acd12 100644
--- a/spec/features/cms_spec.rb
+++ b/spec/features/cms_spec.rb
@@ -1,37 +1,26 @@
-require 'spec_helper'
+require 'rails_helper'
feature "cms admin" do
- before(:each) do
- @member = FactoryGirl.create(:member)
- @admin_member = FactoryGirl.create(:admin_member)
- end
+ let(:member) { create :member }
+ let(:admin_member) { create :admin_member }
scenario "can't view CMS admin if not signed in" do
visit comfy_admin_cms_path
- current_path.should == root_path
- page.should have_content("Please sign in as an admin user")
+ expect(current_path).to eq root_path
+ expect(page).to have_content "Please sign in as an admin user"
end
scenario "can't view CMS admin if not an admin member" do
# sign in as an ordinary member
- visit root_path
- click_link 'navbar-signin'
- fill_in 'Login', :with => @member.email
- fill_in 'Password', :with => @member.password
- click_button 'Sign in'
+ login_as member
visit comfy_admin_cms_path
- current_path.should == root_path
- page.should have_content("Please sign in as an admin user")
+ expect(current_path).to eq root_path
+ expect(page).to have_content "Please sign in as an admin user"
end
scenario "admin members can view CMS admin area" do
- visit root_path
- # now we sign in as an admin member
- click_link 'navbar-signin'
- fill_in 'Login', :with => @admin_member.email
- fill_in 'Password', :with => @admin_member.password
- click_button 'Sign in'
+ login_as admin_member
visit comfy_admin_cms_path
- current_path.should match /#{comfy_admin_cms_path}/ # match any CMS admin page
+ expect(current_path).to match /#{comfy_admin_cms_path}/ # match any CMS admin page
end
-end
+end
\ No newline at end of file
diff --git a/spec/features/comments/commenting_a_comment_spec.rb b/spec/features/comments/commenting_a_comment_spec.rb
new file mode 100644
index 000000000..49183c274
--- /dev/null
+++ b/spec/features/comments/commenting_a_comment_spec.rb
@@ -0,0 +1,33 @@
+require 'rails_helper'
+
+feature 'Commenting on a post' do
+ let(:member) { create :member }
+ let(:post) { create :post, author: member }
+
+ background do
+ login_as member
+ visit new_comment_path post_id: post.id
+ end
+
+ scenario "creating a comment" do
+ fill_in "comment_body", with: "This is a sample test for comment"
+ click_button "Post comment"
+ expect(page).to have_content "Comment was successfully created"
+ expect(page).to have_content "Posted by"
+ end
+
+ context "editing a comment" do
+ let(:existing_comment) { create :comment, post: post, author: member }
+
+ background do
+ visit edit_comment_path existing_comment
+ end
+
+ scenario "saving edit" do
+ fill_in "comment_body", with: "Testing edit for comment"
+ click_button "Post comment"
+ expect(page).to have_content "Comment was successfully updated"
+ expect(page).to have_content "edited at"
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/features/crops/alternate_name_spec.rb b/spec/features/crops/alternate_name_spec.rb
index 8ec2a21fe..de8843708 100644
--- a/spec/features/crops/alternate_name_spec.rb
+++ b/spec/features/crops/alternate_name_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
-feature "Alternate names" do
- let!(:alternate_eggplant) { FactoryGirl.create(:alternate_eggplant) }
+feature "Alternate names", js: true do
+ let!(:alternate_eggplant) { create :alternate_eggplant }
let(:crop) { alternate_eggplant.crop }
scenario "Display alternate names on crop page" do
@@ -16,11 +16,11 @@ feature "Alternate names" do
end
context "User is a crop wrangler" do
- let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
- let(:member){crop_wranglers.first}
+ let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
+ let(:member) { crop_wranglers.first }
- before :each do
- login_as(member)
+ background do
+ login_as member
end
scenario "Crop wranglers can edit alternate names" do
@@ -28,7 +28,7 @@ feature "Alternate names" do
expect(page.status_code).to equal 200
expect(page).to have_content "CROP WRANGLER"
expect(page).to have_content alternate_eggplant.name
- expect(page).to have_link "Edit", :href => edit_alternate_name_path(alternate_eggplant)
+ expect(page).to have_link "Edit", href: edit_alternate_name_path(alternate_eggplant)
within('.alternate_names') { click_on "Edit" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -42,7 +42,7 @@ feature "Alternate names" do
scenario "Crop wranglers can delete alternate names" do
visit crop_path(alternate_eggplant.crop)
expect(page).to have_link "Delete",
- href: alternate_name_path(alternate_eggplant)
+ href: alternate_name_path(alternate_eggplant)
within('.alternate_names') { click_on "Delete" }
expect(page.status_code).to equal 200
expect(page).to_not have_content alternate_eggplant.name
@@ -52,7 +52,7 @@ feature "Alternate names" do
scenario "Crop wranglers can add alternate names" do
visit crop_path(crop)
expect(page).to have_link "Add",
- href: new_alternate_name_path(crop_id: crop.id)
+ href: new_alternate_name_path(crop_id: crop.id)
within('.alternate_names') { click_on "Add" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -69,6 +69,14 @@ feature "Alternate names" do
expect(page).to have_content alternate_eggplant.crop.name
end
- end
+ context "When alternate name is rejected" do
+ let(:rejected_crop) { create :rejected_crop }
+ let(:pending_alt_name) { create :alternate_name, crop: rejected_crop }
+ scenario "Displays crop rejection message" do
+ visit alternate_name_path(pending_alt_name)
+ expect(page).to have_content "This crop was rejected for the following reason: Totally fake"
+ end
+ end
+ end
end
diff --git a/spec/features/crops/browse_crops_spec.rb b/spec/features/crops/browse_crops_spec.rb
index 5df5dbd36..1345d8738 100644
--- a/spec/features/crops/browse_crops_spec.rb
+++ b/spec/features/crops/browse_crops_spec.rb
@@ -2,8 +2,10 @@ require 'rails_helper'
feature "browse crops" do
- let(:tomato) { FactoryGirl.create(:tomato) }
- let(:maize) { FactoryGirl.create(:maize) }
+ let(:tomato) { create :tomato }
+ let(:maize) { create :maize }
+ let(:pending_crop) { create :crop_request }
+ let(:rejected_crop) { create :rejected_crop }
scenario "has a form for sorting by" do
visit crops_path
@@ -16,4 +18,13 @@ feature "browse crops" do
expect(page).to have_content crop1.name
end
+ scenario "pending crops are not listed" do
+ visit crops_path
+ expect(page).not_to have_content pending_crop.name
+ end
+
+ scenario "rejected crops are not listed" do
+ visit crops_path
+ expect(page).not_to have_content rejected_crop.name
+ end
end
diff --git a/spec/features/crops/creating_a_crop_spec.rb b/spec/features/crops/creating_a_crop_spec.rb
new file mode 100644
index 000000000..d234818b8
--- /dev/null
+++ b/spec/features/crops/creating_a_crop_spec.rb
@@ -0,0 +1,34 @@
+require 'rails_helper'
+
+feature "Crop - " do
+ let!(:crop_wrangler) { create :crop_wrangling_member }
+ let!(:member) { create :member }
+
+ background do
+ login_as member
+ visit new_crop_path
+ end
+
+ scenario "creating a crop with multiple scientific and alternate name", :js do
+ within "form#new_crop" do
+ fill_in "crop_name", with: "Philippine flower"
+ fill_in "en_wikipedia_url", with: "https://en.wikipedia.org/wiki/Jasminum_sambac"
+ click_button "add-sci_name-row"
+ fill_in "sci_name[1]", with: "Jasminum sambac 1"
+ fill_in "sci_name[2]", with: "Jasminum sambac 2"
+ fill_in "alt_name[1]", with: "Sampaguita"
+ click_button "add-alt_name-row"
+ click_button "add-alt_name-row"
+ fill_in "alt_name[2]", with: "Manol"
+ click_button "add-alt_name-row"
+ fill_in "alt_name[3]", with: "Jazmin"
+ fill_in "alt_name[4]", with: "Matsurika"
+ fill_in "request_notes", with: "This is the Philippine national flower."
+ click_button "Save"
+ end
+
+ expect(page).to have_content "Crop was successfully requested."
+ expect(page).to have_content "Jasminum sambac 2"
+ expect(page).to have_content "Matsurika"
+ end
+end
\ No newline at end of file
diff --git a/spec/features/crops/crop_detail_page_spec.rb b/spec/features/crops/crop_detail_page_spec.rb
index 437d3e786..d48d60f41 100644
--- a/spec/features/crops/crop_detail_page_spec.rb
+++ b/spec/features/crops/crop_detail_page_spec.rb
@@ -1,11 +1,95 @@
require 'rails_helper'
-feature "crop detail page" do
+feature "crop detail page", js: true do
+ let(:crop) { create :crop }
+
+ subject { visit crop_path(crop) }
- let(:crop) { FactoryGirl.create(:crop) }
+ context "varieties" do
+ scenario "The crop DOES NOT have varieties" do
+ visit crop_path(crop)
+
+ within ".varieties" do
+ expect(page).to have_no_selector('li', text: /tomato/i)
+ expect(page).to have_no_selector('button', text: /Show+/i)
+ end
+ end
+
+ scenario "The crop has one variety" do
+ create :crop, name: 'Roma tomato 1', parent: crop
+
+ subject
+
+ within ".varieties" do
+ # It lists all 2 items (note: including the top level item.)
+ expect(page).to have_selector('li', text: /tomato/i, count: 2)
+ # It DOES NOT have "Show all/less" toggle link
+ expect(page).to have_no_selector('button', text: /Show+/i)
+ end
+ end
+
+ context "many" do
+ let!(:roma1) { create :crop, name: 'Roma tomato 1', parent: crop }
+ let!(:roma2) { create :crop, name: 'Roma tomato 2', parent: crop }
+ let!(:roma3) { create :crop, name: 'Roma tomato 3', parent: crop }
+ let!(:roma4) { create :crop, name: 'Roma tomato 4', parent: crop }
+
+ scenario "The crop has 4 varieties" do
+
+ subject
+
+ within ".varieties" do
+ # It lists all 5 items (note: including the top level item.)
+ expect(page).to have_selector('li', text: /tomato/i, count: 5)
+ # It DOES NOT have "Show all/less" toggle link
+ expect(page).to have_no_selector('button', text: /Show+/i)
+ end
+ end
+
+ scenario "The crop has 5 varieties, including grandchild", js: true do
+ create :crop, name: 'Roma tomato child 1', parent: roma4
+
+ subject
+
+ within ".varieties" do
+
+ # It lists the first 5 items (note: including the top level item.)
+ # It HAS have "Show all" toggle link but not "Show less" link
+ expect(page).to have_selector('li', text: /tomato/i, count: 5)
+ expect(page).to have_selector('li', text: 'Roma tomato 4')
+ expect(page).to have_no_selector('li', text: 'Roma tomato child 1')
+ # It shows the total number (5) correctly
+ expect(page).to have_selector('button', text: /Show all 5 +/i)
+ expect(page).to have_no_selector('button', text: /Show less+/i)
+
+ # Clik "Show all" link
+ page.find('button', text: /Show all+/).click
+
+ # It lists all 6 items (note: including the top level item.)
+ # It HAS have "Show less" toggle link but not "Show all" link
+ expect(page).to have_selector('li', text: /tomato/i, count: 6)
+ expect(page).to have_selector('li', text: 'Roma tomato 4')
+ expect(page).to have_selector('li', text: 'Roma tomato child 1')
+ expect(page).to have_no_selector('button', text: /Show all+/i)
+ expect(page).to have_selector('button', text: /Show less+/i)
+
+ # Clik "Show less" link
+ page.find('button', text: /Show less+/).click
+
+ # It lists 5 items (note: including the top level item.)
+ # It HAS have "Show all" toggle link but not "Show less" link
+ expect(page).to have_selector('li', text: /tomato/i, count: 5)
+ expect(page).to have_selector('li', text: 'Roma tomato 4')
+ expect(page).to have_no_selector('li', text: 'Roma tomato child 1')
+ expect(page).to have_selector('button', text: /Show all 5 +/i)
+ expect(page).to have_no_selector('button', text: /Show less+/i)
+ end
+ end
+ end
+ end
context "signed in member" do
- let(:member) { FactoryGirl.create(:member) }
+ let(:member) { create :member }
background do
login_as(member)
@@ -13,27 +97,23 @@ feature "crop detail page" do
context "action buttons" do
- background do
- visit crop_path(crop)
- end
+ background { subject }
scenario "has a link to plant the crop" do
- expect(page).to have_link "Plant this", :href => new_planting_path(:crop_id => crop.id)
+ expect(page).to have_link "Plant this", href: new_planting_path(crop_id: crop.id)
end
scenario "has a link to harvest the crop" do
- expect(page).to have_link "Harvest this", :href => new_harvest_path(:crop_id => crop.id)
+ expect(page).to have_link "Harvest this", href: new_harvest_path(crop_id: crop.id)
end
scenario "has a link to add seeds" do
- expect(page).to have_link "Add seeds to stash", :href => new_seed_path(:crop_id => crop.id)
+ expect(page).to have_link "Add seeds to stash", href: new_seed_path(crop_id: crop.id)
end
end
context "SEO" do
- background do
- visit crop_path(crop)
- end
+ background { subject }
scenario "has seed heading with SEO" do
expect(page).to have_content "Find #{ crop.name } seeds"
@@ -53,9 +133,35 @@ feature "crop detail page" do
scenario "has a link to Wikipedia with SEO" do
expect(page).to have_content "Learn more about #{ crop.name }"
- expect(page).to have_link "Wikipedia (English)", crop.en_wikipedia_url
+ expect(page).to have_link "Wikipedia (English)", href: crop.en_wikipedia_url
end
end
end
+
+ context "seed quantity for a crop" do
+ let(:member) { create :member }
+ let(:seed) { create :seed, crop: crop, quantity: 20, owner: member }
+
+ scenario "User not signed in" do
+ visit crop_path(seed.crop)
+ expect(page).to_not have_content "You have 20 seeds of this crop"
+ expect(page).to_not have_content "You don't have any seeds of this crop"
+ expect(page).to_not have_link "View your seeds"
+ end
+
+ scenario "User signed in" do
+ login_as(member)
+ visit crop_path(seed.crop)
+ expect(page).to have_content "You have 20 seeds of this crop."
+ expect(page).to have_link "View your seeds"
+ end
+
+ scenario "click link to your owned seeds" do
+ login_as(member)
+ visit crop_path(seed.crop)
+ click_link "View your seeds"
+ expect(current_path).to eq seeds_by_owner_path(owner: member.slug)
+ end
+ end
end
diff --git a/spec/features/crops/crop_search_spec.rb b/spec/features/crops/crop_search_spec.rb
index 48e68dfc2..f2f86980c 100644
--- a/spec/features/crops/crop_search_spec.rb
+++ b/spec/features/crops/crop_search_spec.rb
@@ -4,7 +4,7 @@ feature "crop search" do
scenario "search results show the search term in title" do
visit root_path
within "form#navbar-search" do
- fill_in "search", with: "tomato"
+ fill_in "term", with: "tomato"
click_button "Search"
end
expect(page).to have_css "h1", text: "Crops matching \"tomato\""
diff --git a/spec/features/crops/crop_wranglers_spec.rb b/spec/features/crops/crop_wranglers_spec.rb
index 1b2af3f06..620034fb2 100644
--- a/spec/features/crops/crop_wranglers_spec.rb
+++ b/spec/features/crops/crop_wranglers_spec.rb
@@ -1,88 +1,86 @@
require 'rails_helper'
-feature "crop wranglers" do
+feature "crop wranglers", js: true do
context "signed in wrangler" do
- let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
- let(:wrangler){crop_wranglers.first}
- let!(:crops) { FactoryGirl.create_list(:crop, 2) }
- let!(:requested_crop) { FactoryGirl.create(:crop_request) }
- let!(:rejected_crop) { FactoryGirl.create(:rejected_crop) }
+ let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
+ let(:wrangler) { crop_wranglers.first }
+ let!(:crops) { create_list :crop, 2 }
+ let!(:requested_crop) { create :crop_request }
+ let!(:rejected_crop) { create :rejected_crop }
+
+ background { login_as wrangler }
- background do
- login_as(wrangler)
- end
-
scenario "sees crop wranglers listed on the crop wrangler page" do
visit root_path
+ click_link wrangler.login_name
click_link 'Crop Wrangling'
within '.crop_wranglers' do
expect(page).to have_content 'Crop Wranglers:'
crop_wranglers.each do |crop_wrangler|
- page.should have_link crop_wrangler.login_name, :href => member_path(crop_wrangler)
+ expect(page).to have_link crop_wrangler.login_name, href: member_path(crop_wrangler)
end
end
end
-
+
scenario "can see list of crops with extra detail of who created a crop" do
visit root_path
+ click_link wrangler.login_name
click_link 'Crop Wrangling'
within '#recently-added-crops' do
expect(page).to have_content "#{crops.first.creator.login_name}"
end
end
-
+
scenario "visiting a crop can see wrangler links" do
visit crop_path(crops.first)
expect(page).to have_content 'You are a CROP WRANGLER'
expect(page).to have_link 'Edit crop'
expect(page).to have_link 'Delete crop'
end
-
+
scenario "can create a new crop" do
visit root_path
+ click_link wrangler.login_name
click_link 'Crop Wrangling'
click_link 'Add Crop'
fill_in 'Name', with: "aubergine"
- fill_in 'Wikipedia URL', with: "http://en.wikipedia.org/wiki/Maize"
- fill_in 'crop_scientific_names_attributes_0_scientific_name', with: "planticus maximus"
+ fill_in 'en_wikipedia_url', with: "http://en.wikipedia.org/wiki/Maize"
+ fill_in 'sci_name[1]', with: "planticus maximus"
click_on 'Save'
expect(page).to have_content 'Crop was successfully created'
expect(page).to have_content 'planticus maximus'
end
scenario "View pending crops" do
- visit wrangle_crops_path(:approval_status => "pending")
- within "#pending-crops" do
- click_link "Ultra berry"
- end
+ visit crop_path(requested_crop)
expect(page).to have_content "This crop is currently pending approval."
expect(page).to have_content "Please approve this even though it's fake."
end
scenario "View rejected crops" do
- visit wrangle_crops_path(:approval_status => "rejected")
- within "#rejected-crops" do
- click_link "Fail bean"
- end
+ visit crop_path(rejected_crop)
expect(page).to have_content "This crop was rejected for the following reason: Totally fake"
end
-
+
end
-
+
context "signed in non-wrangler" do
- let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
- let(:member) { FactoryGirl.create(:member) }
+ let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
+ let(:member) { create :member }
- background do
- login_as(member)
- end
+ background { login_as member }
- scenario "can't see wrangling page" do
+ scenario "can't see wrangling page without js", js: false do
visit root_path
expect(page).not_to have_link "Crop Wrangling"
end
-
+
+ scenario "can't see wrangling page with js" do
+ visit root_path
+ click_link member.login_name
+ expect(page).not_to have_link "Crop Wrangling"
+ end
end
end
diff --git a/spec/features/crops/crop_wrangling_button_spec.rb b/spec/features/crops/crop_wrangling_button_spec.rb
index 26ef46e30..ede88f003 100644
--- a/spec/features/crops/crop_wrangling_button_spec.rb
+++ b/spec/features/crops/crop_wrangling_button_spec.rb
@@ -1,33 +1,28 @@
require 'rails_helper'
feature "crop wrangling button" do
+ let(:crop_wrangler) { create :crop_wrangling_member }
+ let(:member) { create :member }
- let(:crop_wrangler) { FactoryGirl.create(:crop_wrangling_member) }
-
- context "crop wrangling button" do
-
- background do
- login_as(crop_wrangler)
- visit crops_path
- end
-
- scenario "has a link to crop wrangling page" do
- expect(page).to have_link "Wrangle Crops", :href => wrangle_crops_path
- end
-
+ context "crop wrangling button" do
+ background do
+ login_as crop_wrangler
+ visit crops_path
end
- let(:member) { FactoryGirl.create(:member) }
-
- context "crop wrangling button" do
-
- background do
- login_as(member)
- visit crops_path
- end
-
- scenario "has no link to crop wrangling page" do
- expect(page).to have_no_link "Wrangle Crops", :href => wrangle_crops_path
- end
+ scenario "has a link to crop wrangling page" do
+ expect(page).to have_link "Wrangle Crops", href: wrangle_crops_path
end
end
+
+ context "crop wrangling button" do
+ background do
+ login_as member
+ visit crops_path
+ end
+
+ scenario "has no link to crop wrangling page" do
+ expect(page).to have_no_link "Wrangle Crops", href: wrangle_crops_path
+ end
+ end
+end
diff --git a/spec/features/crops/inflections_spec.rb b/spec/features/crops/inflections_spec.rb
index 93c1f0e24..244945d35 100644
--- a/spec/features/crops/inflections_spec.rb
+++ b/spec/features/crops/inflections_spec.rb
@@ -1,7 +1,6 @@
require 'spec_helper'
feature "irregular crop inflections" do
-
# We're just testing a couple of representative crops to
# check that inflection works: you don't need to add
# every crop here.
@@ -9,5 +8,4 @@ feature "irregular crop inflections" do
expect("kale".pluralize).to eq "kale"
expect("broccoli".pluralize).to eq "broccoli"
end
-
end
diff --git a/spec/features/crops/request_new_crop_spec.rb b/spec/features/crops/request_new_crop_spec.rb
index 0a1cac2a7..3d2f76e5f 100644
--- a/spec/features/crops/request_new_crop_spec.rb
+++ b/spec/features/crops/request_new_crop_spec.rb
@@ -1,50 +1,46 @@
require 'rails_helper'
feature "Requesting a new crop" do
-
context "As a regular member" do
+ let(:member) { create :member }
+ let!(:wrangler) { create :crop_wrangling_member }
- let(:member) { FactoryGirl.create(:member) }
- let!(:wrangler) { FactoryGirl.create(:crop_wrangling_member) }
-
- before { login_as member }
+ background do
+ login_as member
+ end
scenario "Submit request" do
visit new_crop_path
fill_in "Name", with: "Couch potato"
- fill_in "Comments", with: "Couch potatoes are real for real."
+ fill_in "request_notes", with: "Couch potatoes are real for real."
click_button "Save"
expect(page).to have_content "Crop was successfully requested."
end
-
end
context "As a crop wrangler" do
+ let(:wrangler) { create :crop_wrangling_member }
+ let!(:crop) { create :crop_request }
+ let!(:already_approved) { create :crop }
- let(:wrangler) { FactoryGirl.create(:crop_wrangling_member) }
- let!(:crop) { FactoryGirl.create(:crop_request) }
- let!(:already_approved) { FactoryGirl.create(:crop) }
-
- before { login_as wrangler }
+ background { login_as wrangler }
scenario "Approve a request" do
visit edit_crop_path(crop)
- select "approved", from: "Approval Status"
+ select "approved", from: "Approval status"
click_button "Save"
expect(page).to have_content "En wikipedia url is not a valid English Wikipedia URL"
- fill_in "Wikipedia URL", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi"
+ fill_in "en_wikipedia_url", with: "http://en.wikipedia.org/wiki/Aung_San_Suu_Kyi"
click_button "Save"
expect(page).to have_content "Crop was successfully updated."
end
scenario "Rejecting a crop" do
visit edit_crop_path(crop)
- select "rejected", from: "Approval Status"
+ select "rejected", from: "Approval status"
select "not edible", from: "Reason for rejection"
click_button "Save"
expect(page).to have_content "Crop was successfully updated."
end
-
end
-
-end
\ No newline at end of file
+end
diff --git a/spec/features/following_spec.rb b/spec/features/following_spec.rb
index 891a38b02..92e0f535c 100644
--- a/spec/features/following_spec.rb
+++ b/spec/features/following_spec.rb
@@ -1,9 +1,8 @@
require 'rails_helper'
-feature "follows", :js => true do
-
+feature "follows", :js do
context "when signed out" do
- let(:member) { FactoryGirl.create(:member) }
+ let(:member) { create :member }
scenario "follow buttons on member profile page" do
visit member_path(member)
@@ -13,8 +12,8 @@ feature "follows", :js => true do
end
context "when signed in" do
- let(:member) { FactoryGirl.create(:member) }
- let(:other_member) { FactoryGirl.create(:member) }
+ let(:member) { create :member }
+ let(:other_member) { create :member }
background do
login_as(member)
@@ -32,13 +31,13 @@ feature "follows", :js => true do
end
scenario "has a follow button" do
- expect(page).to have_link "Follow", :href => follows_path(:followed_id => other_member.id)
+ expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id)
end
scenario "has correct message and unfollow button" do
click_link 'Follow'
expect(page).to have_content "Followed #{other_member.login_name}"
- expect(page).to have_link "Unfollow", :href => follow_path(member.get_follow(other_member))
+ expect(page).to have_link "Unfollow", href: follow_path(member.get_follow(other_member))
end
scenario "has a followed member listed in the following page" do
@@ -48,9 +47,7 @@ feature "follows", :js => true do
end
scenario "does not die when passed an authenticity_token" do
- visit member_follows_path(
- member,
- :params => {:authenticity_token => "Ultima ratio regum"})
+ visit member_follows_path member, params: { authenticity_token: "Ultima ratio regum" }
expect(page.status_code).to equal 200
end
@@ -59,7 +56,7 @@ feature "follows", :js => true do
click_link 'Unfollow'
expect(page).to have_content "Unfollowed #{other_member.login_name}"
visit member_path(other_member) # unfollowing redirects to root
- expect(page).to have_link "Follow", :href => follows_path(:followed_id => other_member.id)
+ expect(page).to have_link "Follow", href: follows_path(followed_id: other_member.id)
end
scenario "has member in following list" do
@@ -80,10 +77,8 @@ feature "follows", :js => true do
visit member_follows_path(member)
expect(page).not_to have_content "#{other_member.login_name}"
visit member_followers_path(other_member)
- expect(page).not_to have_content "#{member.login_name}"
+ expect(page).to have_content "#{member.login_name}"
end
-
end
-
end
end
diff --git a/spec/features/footer_spec.rb b/spec/features/footer_spec.rb
index 400b153a4..8a2c21bbd 100644
--- a/spec/features/footer_spec.rb
+++ b/spec/features/footer_spec.rb
@@ -1,12 +1,17 @@
require 'rails_helper'
-feature "footer" do
+feature "footer", js: true do
+
+ before { visit root_path }
scenario "footer is on home page" do
- visit root_path
expect(page).to have_css 'footer'
end
+ it 'has the Open Service link and graphic' do
+ expect(page).to have_selector 'a[href="http://opendefinition.org/ossd/"]'
+ end
+
# NB: not testing specific content in the footer since I'm going to put them
# in the CMS and they'll be variable.
end
diff --git a/spec/features/gardens/adding_gardens_spec.rb b/spec/features/gardens/adding_gardens_spec.rb
new file mode 100644
index 000000000..da2bd0481
--- /dev/null
+++ b/spec/features/gardens/adding_gardens_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+require 'custom_matchers'
+
+feature "Gardens", :js do
+ let(:member) { FactoryGirl.create :member }
+
+ background do
+ login_as member
+ visit new_garden_path
+ end
+
+ it "has the required fields help text" do
+ expect(page).to have_content "* denotes a required field"
+ end
+
+ it "displays required and optional fields properly" do
+ expect(page).to have_selector ".form-group.required", text: "Name"
+ expect(page).to have_optional 'textarea#garden_description'
+ expect(page).to have_optional 'input#garden_location'
+ expect(page).to have_optional 'input#garden_area'
+ end
+
+ scenario "Create new garden" do
+ fill_in "Name", with: "New garden"
+ click_button "Save"
+ expect(page).to have_content "Garden was successfully created"
+ expect(page).to have_content "New garden"
+ end
+
+ scenario "Refuse to create new garden with negative area" do
+ visit new_garden_path
+ fill_in "Name", with: "Negative Garden"
+ fill_in "Area", with: -5
+ click_button "Save"
+ expect(page).not_to have_content "Garden was successfully created"
+ expect(page).to have_content "Area must be greater than or equal to 0"
+ end
+end
diff --git a/spec/features/gardens_spec.rb b/spec/features/gardens_spec.rb
index 8f311804e..90f2f9ed7 100644
--- a/spec/features/gardens_spec.rb
+++ b/spec/features/gardens_spec.rb
@@ -1,12 +1,13 @@
require 'rails_helper'
-feature "Planting a crop", :js => true do
- let!(:garden) { FactoryGirl.create(:garden) }
- let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) }
-
+feature "Planting a crop", js: true do
+ let!(:garden) { create :garden }
+ let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
+ let!(:tomato) { create :tomato }
+ let!(:finished_planting) { create :finished_planting, garden: garden, crop: tomato }
background do
- login_as(garden.owner)
+ login_as garden.owner
end
scenario "View gardens" do
@@ -29,7 +30,7 @@ feature "Planting a crop", :js => true do
scenario "Create new garden" do
visit new_garden_path
- fill_in "Name", :with => "New garden"
+ fill_in "Name", with: "New garden"
click_button "Save"
expect(page).to have_content "Garden was successfully created"
expect(page).to have_content "New garden"
@@ -37,19 +38,31 @@ feature "Planting a crop", :js => true do
scenario "Refuse to create new garden with negative area" do
visit new_garden_path
- fill_in "Name", :with => "Negative Garden"
- fill_in "Area", :with => -5
+ fill_in "Name", with: "Negative Garden"
+ fill_in "Area", with: -5
click_button "Save"
expect(page).not_to have_content "Garden was successfully created"
expect(page).to have_content "Area must be greater than or equal to 0"
end
+ context "Clicking edit from the index page" do
+
+ background do
+ visit gardens_path
+ end
+
+ scenario "button on index to edit garden" do
+ first(".panel-title").click_link("edit_garden_glyphicon")
+ expect(page).to have_content 'Edit garden'
+ end
+ end
+
scenario "Edit garden" do
visit new_garden_path
- fill_in "Name", :with => "New garden"
+ fill_in "Name", with: "New garden"
click_button "Save"
click_link "Edit garden"
- fill_in "Name", :with => "Different name"
+ fill_in "Name", with: "Different name"
click_button "Save"
expect(page).to have_content "Garden was successfully updated"
expect(page).to have_content "Different name"
@@ -57,7 +70,7 @@ feature "Planting a crop", :js => true do
scenario "Delete garden" do
visit new_garden_path
- fill_in "Name", :with => "New garden"
+ fill_in "Name", with: "New garden"
click_button "Save"
visit garden_path(Garden.last)
click_link "Delete garden"
@@ -66,10 +79,13 @@ feature "Planting a crop", :js => true do
end
describe "Making a planting inactive from garden show" do
- let(:path) { garden_path(garden) }
+ let(:path) { garden_path garden }
let(:link_text) { "Mark as finished" }
-
it_behaves_like "append date"
end
+ scenario "List only active plantings on a garden" do
+ visit gardens_path
+ expect(page).not_to have_content finished_planting.crop_name
+ end
end
diff --git a/spec/features/harvests/browse_harvests_spec.rb b/spec/features/harvests/browse_harvests_spec.rb
new file mode 100644
index 000000000..0b4d07f6a
--- /dev/null
+++ b/spec/features/harvests/browse_harvests_spec.rb
@@ -0,0 +1,35 @@
+require 'rails_helper'
+
+feature "browse harvests" do
+ let!(:member) { create :member }
+
+ background do
+ login_as member
+ end
+
+ feature 'blank optional fields' do
+ let!(:harvest) { create :harvest, :no_description }
+
+ before (:each) do
+ visit harvests_path
+ end
+
+ scenario 'read more' do
+ expect(page).not_to have_link "Read more"
+ end
+
+ end
+
+ feature "filled in optional fields" do
+ let!(:harvest) { create :harvest, :long_description }
+
+ before (:each) do
+ visit harvests_path
+ end
+
+ scenario 'read more' do
+ expect(page).to have_link "Read more"
+ end
+
+ end
+end
diff --git a/spec/features/harvests/harvesting_a_crop_spec.rb b/spec/features/harvests/harvesting_a_crop_spec.rb
index c1148cf4b..888e74bfb 100644
--- a/spec/features/harvests/harvesting_a_crop_spec.rb
+++ b/spec/features/harvests/harvesting_a_crop_spec.rb
@@ -1,35 +1,71 @@
require 'rails_helper'
+require 'custom_matchers'
-feature "Harvesting a crop", :js => true do
- let(:member) { FactoryGirl.create(:member) }
- let!(:maize) { FactoryGirl.create(:maize) }
+feature "Harvesting a crop", :js do
+ let(:member) { create :member }
+ let!(:maize) { create :maize }
+ let!(:plant_part) { create :plant_part }
background do
- login_as(member)
+ login_as member
visit new_harvest_path
- sync_elasticsearch([maize])
+ sync_elasticsearch [maize]
end
it_behaves_like "crop suggest", "harvest", "crop"
- scenario "Creating a new harvest", :js => true do
- fill_autocomplete "crop", :with => "mai"
+ it "has the required fields help text" do
+ expect(page).to have_content "* denotes a required field"
+ end
+
+ it "displays required and optional fields properly" do
+ expect(page).to have_selector ".form-group.required", text: "What did you harvest?"
+ expect(page).to have_optional 'input#harvest_quantity'
+ expect(page).to have_optional 'input#harvest_weight_quantity'
+ expect(page).to have_optional 'textarea#harvest_description'
+ end
+
+ scenario "Creating a new harvest", :js do
+ fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
+
within "form#new_harvest" do
- fill_in "When?", :with => "2014-06-15"
- fill_in "How many?", :with => 42
- fill_in "Weighing (in total):", :with => 42
- fill_in "Notes", :with => "It's killer."
+ select plant_part.name, from: 'harvest[plant_part_id]'
+ fill_in "When?", with: "2014-06-15"
+ fill_in "How many?", with: 42
+ fill_in "Weighing (in total):", with: 42
+ fill_in "Notes", with: "It's killer."
click_button "Save"
end
expect(page).to have_content "Harvest was successfully created"
end
+ context "Clicking edit from the index page" do
+ let!(:harvest) { create :harvest, crop: maize, owner: member }
+
+ background do
+ visit harvests_path
+ end
+
+ scenario "button on index to edit harvest" do
+ click_link "edit_harvest_glyphicon"
+ expect(current_path).to eq edit_harvest_path(harvest)
+ expect(page).to have_content 'Editing harvest'
+ end
+ end
+
+ scenario "Clicking link to owner's profile" do
+ visit harvests_by_owner_path(member)
+ click_link "View #{member}'s profile >>"
+ expect(current_path).to eq member_path member
+ end
+
scenario "Harvesting from crop page" do
visit crop_path(maize)
click_link "Harvest this"
within "form#new_harvest" do
+ select plant_part.name, from: 'harvest[plant_part_id]'
expect(page).to have_selector "input[value='maize']"
click_button "Save"
end
@@ -39,7 +75,7 @@ feature "Harvesting a crop", :js => true do
end
context "Editing a harvest" do
- let(:existing_harvest) { FactoryGirl.create(:harvest, :crop => maize, :owner => member) }
+ let(:existing_harvest) { create :harvest, crop: maize, owner: member }
background do
visit harvest_path(existing_harvest)
@@ -53,8 +89,5 @@ feature "Harvesting a crop", :js => true do
expect(page).to have_content "Harvest was successfully updated"
expect(page).to have_content "maize"
end
-
end
-
end
-
diff --git a/spec/features/locale_spec.rb b/spec/features/locale_spec.rb
index 36b07b5c9..74cf208be 100644
--- a/spec/features/locale_spec.rb
+++ b/spec/features/locale_spec.rb
@@ -1,16 +1,13 @@
require 'rails_helper'
-feature "Changing locales" do
+feature "Changing locales", js: true do
- after do
- I18n.locale = :en
- end
+ after { I18n.locale = :en }
scenario "Locale can be set with a query param" do
visit root_path
expect(page).to have_content("a community of food gardeners.")
- visit root_path(:locale => 'ja')
+ visit root_path(locale: 'ja')
expect(page).to have_content("はガーデナーのコミュニティです。")
end
-
end
diff --git a/spec/features/member_profile_spec.rb b/spec/features/member_profile_spec.rb
index 2c7343a8d..0551e3873 100644
--- a/spec/features/member_profile_spec.rb
+++ b/spec/features/member_profile_spec.rb
@@ -1,18 +1,18 @@
require 'rails_helper'
-feature "member profile" do
+feature "member profile", js: true do
context "signed out member" do
- let(:member) { FactoryGirl.create(:member) }
+ let(:member) { create :member }
scenario "basic details on member profile page" do
visit member_path(member)
- expect(page).to have_css("h1", :text => member.login_name)
+ expect(page).to have_css("h1", text: member.login_name)
expect(page).to have_content member.bio
expect(page).to have_content "Member since: #{member.created_at.to_s(:date)}"
expect(page).to have_content "Account type: Free account"
expect(page).to have_content "#{member.login_name}'s gardens"
- expect(page).to have_link "More about this garden...", :href => garden_path(member.gardens.first)
+ expect(page).to have_link "More about this garden...", href: garden_path(member.gardens.first)
end
scenario "no bio" do
@@ -29,25 +29,25 @@ feature "member profile" do
context "location" do
scenario "member has set location" do
- london_member = FactoryGirl.create(:london_member)
+ london_member = create :london_member
visit member_path(london_member)
- expect(page).to have_css("h1>small", :text => london_member.location)
+ expect(page).to have_css("h1>small", text: london_member.location)
expect(page).to have_css("#membermap")
- expect(page).to have_content "See other members near #{london_member.location}"
+ expect(page).to have_content "See other members, plantings, seeds and more near #{london_member.location}"
end
scenario "member has not set location" do
visit member_path(member)
expect(page).not_to have_css("h1>small")
expect(page).not_to have_css("#membermap")
- expect(page).not_to have_content "See other members near"
+ expect(page).not_to have_content "See other members"
end
end
context "email privacy" do
scenario "public email address" do
- public_member = FactoryGirl.create(:public_member)
+ public_member = create :public_member
visit member_path(public_member)
expect(page).to have_content public_member.email
end
@@ -59,7 +59,7 @@ feature "member profile" do
context "email privacy" do
scenario "public email address" do
- public_member = FactoryGirl.create(:public_member)
+ public_member = create :public_member
visit member_path(public_member)
expect(page).to have_content public_member.email
end
@@ -81,58 +81,74 @@ feature "member profile" do
end
scenario "with some activity" do
- FactoryGirl.create_list(:planting, 2, :owner => member)
- FactoryGirl.create_list(:harvest, 3, :owner => member)
- FactoryGirl.create_list(:seed, 4, :owner => member)
- FactoryGirl.create_list(:post, 5, :author => member)
+ create_list :planting, 2, owner: member
+ create_list :harvest, 3, owner: member
+ create_list :seed, 4, owner: member
+ create_list :post, 5, author: member
visit member_path(member)
- expect(page).to have_link "2 plantings", :href => plantings_by_owner_path(:owner => member)
- expect(page).to have_link "3 harvests", :href => harvests_by_owner_path(:owner => member)
- expect(page).to have_link "4 seeds", :href => seeds_by_owner_path(:owner => member)
- expect(page).to have_link "5 posts", :href => posts_by_author_path(:author => member)
+ expect(page).to have_link "2 plantings", href: plantings_by_owner_path(owner: member)
+ expect(page).to have_link "3 harvests", href: harvests_by_owner_path(owner: member)
+ expect(page).to have_link "4 seeds", href: seeds_by_owner_path(owner: member)
+ expect(page).to have_link "5 posts", href: posts_by_author_path(author: member)
end
end
scenario "twitter link" do
- twitter_auth = FactoryGirl.create(:authentication, :member => member)
+ twitter_auth = create :authentication, member: member
visit member_path(member)
- expect(page).to have_link twitter_auth.name, :href => "http://twitter.com/#{twitter_auth.name}"
+ expect(page).to have_link twitter_auth.name, href: "http://twitter.com/#{twitter_auth.name}"
end
scenario "flickr link" do
- flickr_auth = FactoryGirl.create(:flickr_authentication, :member => member)
+ flickr_auth = create :flickr_authentication, member: member
visit member_path(member)
- expect(page).to have_link flickr_auth.name, :href => "http://flickr.com/photos/#{flickr_auth.uid}"
+ expect(page).to have_link flickr_auth.name, href: "http://flickr.com/photos/#{flickr_auth.uid}"
end
-
end
context "signed in member" do
- let(:member) { FactoryGirl.create(:member) }
- let(:other_member) { FactoryGirl.create(:member) }
+ let(:member) { create :member }
+ let(:other_member) { create :member }
+ let(:admin_member) { create :admin_member }
+ let(:crop_wrangler) { create :crop_wrangling_member }
background do
login_as(member)
end
+ scenario "admin user's page" do
+ visit member_path(admin_member)
+ expect(page).to have_text "Admin"
+ end
+
+ scenario "crop wrangler's page" do
+ visit member_path(crop_wrangler)
+ expect(page).to have_text "Crop Wrangler"
+ end
+
+ scenario "ordinary user's page" do
+ visit member_path(other_member)
+ expect(page).to_not have_text "Crop Wrangler"
+ expect(page).to_not have_text "Admin"
+ end
+
context "your own profile page" do
background do
visit member_path(member)
end
scenario "has a link to create new garden" do
- expect(page).to have_link "New Garden", :href => new_garden_path
+ expect(page).to have_link "New Garden", href: new_garden_path
end
scenario "has a button to edit profile" do
- expect(page).to have_link "Edit profile", :href => edit_member_registration_path
+ expect(page).to have_link "Edit profile", href: edit_member_registration_path
end
scenario "has a button to upgrade account" do
- expect(page).to have_link "Upgrade account", :href => shop_path
+ expect(page).to have_link "Upgrade account", href: shop_path
end
-
end
context "someone else's profile page" do
@@ -141,9 +157,8 @@ feature "member profile" do
end
scenario "has a private message button" do
- expect(page).to have_link "Send message", :href => new_notification_path(:recipient_id => other_member.id)
+ expect(page).to have_link "Send message", href: new_notification_path(recipient_id: other_member.id)
end
-
end
context "home page" do
@@ -152,9 +167,8 @@ feature "member profile" do
end
scenario "does not have a button to edit profile" do
- expect(page).to_not have_link "Edit profile", :href => edit_member_registration_path
+ expect(page).to_not have_link "Edit profile", href: edit_member_registration_path
end
end
-
end
end
diff --git a/spec/features/members_list_spec.rb b/spec/features/members_list_spec.rb
index 68cbb6d1f..99e15820a 100644
--- a/spec/features/members_list_spec.rb
+++ b/spec/features/members_list_spec.rb
@@ -1,18 +1,17 @@
require 'rails_helper'
feature "members list" do
-
context "list all members" do
- let! (:member1) { FactoryGirl.create(:member, :login_name => "Archaeopteryx", :confirmed_at => Time.zone.parse('2013-02-10')) }
- let! (:member2) { FactoryGirl.create(:member, :login_name => "Zephyrosaurus", :confirmed_at => Time.zone.parse('2014-01-11')) }
- let! (:member3) { FactoryGirl.create(:member, :login_name => "Testingname", :confirmed_at => Time.zone.parse('2014-05-09')) }
+ let!(:member1) { create :member, login_name: "Archaeopteryx", confirmed_at: Time.zone.parse('2013-02-10') }
+ let!(:member2) { create :member, login_name: "Zephyrosaurus", confirmed_at: Time.zone.parse('2014-01-11') }
+ let!(:member3) { create :member, login_name: "Testingname", confirmed_at: Time.zone.parse('2014-05-09') }
scenario "default alphabetical sort" do
visit members_path
expect(page).to have_css "#sort"
expect(page).to have_selector "form"
click_button('Show')
- all_links = page.all("#maincontainer p")
+ all_links = page.all("#maincontainer p.login-name")
expect(all_links.first).to have_text member1.login_name
expect(all_links.last).to have_text member2.login_name
end
@@ -21,15 +20,11 @@ feature "members list" do
visit members_path
expect(page).to have_css "#sort"
expect(page).to have_selector "form"
- select("recently", :from => 'sort')
+ select("recently", from: 'sort')
click_button('Show')
- all_links = page.all("#maincontainer p")
+ all_links = page.all("#maincontainer p.login-name")
expect(all_links.first).to have_text member3.login_name
expect(all_links.last).to have_text member1.login_name
-
end
-
-
end
-
-end
+end
\ No newline at end of file
diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb
new file mode 100644
index 000000000..9949a619d
--- /dev/null
+++ b/spec/features/notifications_spec.rb
@@ -0,0 +1,52 @@
+require 'rails_helper'
+
+feature "Notifications", :js do
+ let(:sender) { create :member }
+ let(:recipient) { create :member }
+
+ context "On existing notification" do
+ let!(:notification) {
+ create :notification,
+ sender: sender,
+ recipient: recipient,
+ body: "Notification body",
+ post_id: nil
+ }
+
+ background do
+ login_as recipient
+ visit notification_path(notification)
+ end
+
+ scenario "Replying to the notification" do
+ click_link "Reply"
+ expect(page).to have_content "Notification body"
+
+ fill_in 'notification_body', with: "Response body"
+ click_button "Send"
+
+ expect(page).to have_content "Message was successfully sent"
+ end
+ end
+
+ describe 'pagination' do
+ before do
+ 34.times { FactoryGirl.create :notification, recipient: recipient }
+ login_as recipient
+ visit notifications_path
+ end
+
+ it 'has page navigation' do
+ expect(page).to have_selector 'a[rel="next"]'
+ end
+
+ it 'paginates at 30 notifications per page' do
+ expect(page).to have_selector 'tr', count: 31
+ end
+
+ it 'navigates pages' do
+ first('a[rel="next"]').click
+ expect(page).to have_selector 'tr', count: 5
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/features/photos/show_photo_spec.rb b/spec/features/photos/show_photo_spec.rb
new file mode 100644
index 000000000..bf72f5fd6
--- /dev/null
+++ b/spec/features/photos/show_photo_spec.rb
@@ -0,0 +1,42 @@
+require 'rails_helper'
+
+feature "show photo page" do
+ let(:photo) { create :photo }
+
+ context "signed in member" do
+ let(:member) { create :member }
+
+ background { login_as member }
+
+ context "linked to planting" do
+ let(:planting) { create :planting }
+
+ scenario "shows linkback to planting" do
+ planting.photos << photo
+ visit photo_path(photo)
+ expect(page).to have_link "A planting by #{planting.owner}", href: planting_path(planting)
+ end
+ end
+
+ context "linked to harvest" do
+ let(:harvest) { create :harvest }
+
+ scenario "shows linkback to harvest" do
+ harvest.photos << photo
+ visit photo_path(photo)
+ expect(page).to have_link "A harvest by #{harvest.owner}", href: harvest_path(harvest)
+ end
+ end
+
+ context "linked to garden" do
+ let(:garden) { create :garden }
+
+ scenario "shows linkback to garden" do
+ garden.photos << photo
+ visit photo_path(photo)
+ expect(page).to have_link "A garden by #{garden.owner}", href: garden_path(garden)
+ end
+ end
+ end
+end
+
diff --git a/spec/features/places/searching_a_place_spec.rb b/spec/features/places/searching_a_place_spec.rb
new file mode 100644
index 000000000..e8562c244
--- /dev/null
+++ b/spec/features/places/searching_a_place_spec.rb
@@ -0,0 +1,61 @@
+require "rails_helper"
+
+feature "User searches" do
+ let(:member) { create :member, location: "Philippines" }
+ let!(:maize) { create :maize }
+ let(:garden) { create :garden, owner: member }
+ let!(:seed1) { create :seed, owner: member }
+ let!(:planting) { create :planting, garden: garden, owner: member, planted_at: Date.parse("2013-3-10") }
+
+ scenario "with a valid place" do
+ visit places_path
+ search_with "Philippines"
+ expect(page).to have_content "community near Philippines"
+ expect(page).to have_button "search_button"
+ expect(page).to have_content "Nearby members"
+ expect(page).to_not have_content "No results found"
+ end
+
+ scenario "with a blank search string" do
+ visit places_path
+ search_with ""
+ expect(page).to have_content "Please enter a valid location"
+ expect(page).to have_button "search_button"
+ end
+
+ describe "Nearby plantings, seed, and members" do
+ before do
+ login_as member
+ visit places_path
+ search_with "Philippines"
+ end
+
+ it "should show that there are nearby seeds, plantings, and members" do
+ expect(page).to have_content "Nearby members"
+ expect(page).to have_content "Seeds available for trade near Philippines"
+ expect(page).to have_content "Recent plantings near Philippines"
+ end
+
+ it "should go to members' index page" do
+ click_link 'View all members >>'
+ expect(current_path).to eq members_path
+ end
+
+ it "should go to plantings' index page" do
+ click_link 'View all plantings >>'
+ expect(current_path).to eq plantings_path
+ end
+
+ it "should go to seeds' index page" do
+ click_link 'View all seeds >>'
+ expect(current_path).to eq seeds_path
+ end
+ end
+
+ private
+
+ def search_with(search_string)
+ fill_in "new_place", with: search_string
+ click_button "search_button"
+ end
+end
\ No newline at end of file
diff --git a/spec/features/planting_reminder_spec.rb b/spec/features/planting_reminder_spec.rb
index 3d694c013..4cba3cb51 100644
--- a/spec/features/planting_reminder_spec.rb
+++ b/spec/features/planting_reminder_spec.rb
@@ -1,8 +1,8 @@
require 'rails_helper'
require 'capybara/email/rspec'
-feature "Planting reminder email", :js => true do
- let(:member) { FactoryGirl.create(:member) }
+feature "Planting reminder email", :js do
+ let(:member) { create :member }
let(:mail) { Notifier.planting_reminder(member) }
# Unfortunately, we can't use the default url options for ActionMailer as configured in
@@ -23,25 +23,18 @@ feature "Planting reminder email", :js => true do
scenario "doesn't list plantings" do
expect(mail).not_to have_content "most recent plantings you've told us about"
end
-
end
context "when member has some plantings" do
- before :each do
- @p1 = FactoryGirl.create(:planting,
- :garden => member.gardens.first,
- :owner => member
- )
- @p2 = FactoryGirl.create(:planting,
- :garden => member.gardens.first,
- :owner => member
- )
- end
+ # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present
+ # in the database before the email is generated: otherwise, they won't be present in the email.
+ let!(:p1) { create :planting, garden: member.gardens.first, owner: member }
+ let!(:p2) { create :planting, garden: member.gardens.first, owner: member }
scenario "lists plantings" do
expect(mail).to have_content "most recent plantings you've told us about"
- expect(mail).to have_link @p1.to_s, planting_url(@p1)
- expect(mail).to have_link @p2.to_s, planting_url(@p2)
+ expect(mail).to have_link p1.to_s, href: planting_url(p1)
+ expect(mail).to have_link p2.to_s, href: planting_url(p2)
expect(mail).to have_content "keep your garden records up to date"
end
end
@@ -54,26 +47,19 @@ feature "Planting reminder email", :js => true do
scenario "doesn't list plantings" do
expect(mail).not_to have_content "the last few things you harvested were"
end
-
end
context "when member has some harvests" do
- before :each do
- @h1 = FactoryGirl.create(:harvest,
- :owner => member
- )
- @h2 = FactoryGirl.create(:harvest,
- :owner => member
- )
- end
+ # Bangs are used on the following 2 let blocks in order to ensure that the plantings are present
+ # in the database before the spec is run.
+ let!(:h1) { create :harvest, owner: member }
+ let!(:h2) { create :harvest, owner: member }
scenario "lists harvests" do
expect(mail).to have_content "the last few things you harvested were"
- expect(mail).to have_link @h1.to_s, harvest_url(@h1)
- expect(mail).to have_link @h2.to_s, harvest_url(@h2)
+ expect(mail).to have_link h1.to_s, href: harvest_url(h1)
+ expect(mail).to have_link h2.to_s, href: harvest_url(h2)
expect(mail).to have_content "Harvested anything else lately?"
end
-
end
-
end
diff --git a/spec/features/plantings/planting_a_crop_spec.rb b/spec/features/plantings/planting_a_crop_spec.rb
index bda85fadc..5ecabef33 100644
--- a/spec/features/plantings/planting_a_crop_spec.rb
+++ b/spec/features/plantings/planting_a_crop_spec.rb
@@ -1,32 +1,154 @@
require "rails_helper"
+require 'custom_matchers'
-feature "Planting a crop", :js => true do
- let(:member) { FactoryGirl.create(:member) }
- let!(:maize) { FactoryGirl.create(:maize) }
- let(:garden) { FactoryGirl.create(:garden, owner: member) }
- let!(:planting) { FactoryGirl.create(:planting, garden: garden, planted_at: Date.parse("2013-3-10")) }
+feature "Planting a crop", :js do
+ let(:member) { create :member }
+ let!(:maize) { create :maize }
+ let(:garden) { create :garden, owner: member }
+ let!(:planting) { create :planting, garden: garden, planted_at: Date.parse("2013-3-10") }
background do
- login_as(member)
+ login_as member
visit new_planting_path
- sync_elasticsearch([maize])
+ sync_elasticsearch [maize]
end
it_behaves_like "crop suggest", "planting"
+ it "has the required fields help text" do
+ expect(page).to have_content "* denotes a required field"
+ end
+
+ it "displays required and optional fields properly" do
+ expect(page).to have_selector ".form-group.required", text: "What did you plant?"
+ expect(page).to have_selector ".form-group.required", text: "Where did you plant it?"
+ expect(page).to have_optional 'input#planting_planted_at'
+ expect(page).to have_optional 'input#planting_quantity'
+ expect(page).to have_optional 'select#planting_planted_from'
+ expect(page).to have_optional 'select#planting_sunniness'
+ expect(page).to have_optional 'textarea#planting_description'
+ expect(page).to have_optional 'input#planting_finished_at'
+ end
+
scenario "Creating a new planting" do
- fill_autocomplete "crop", :with => "mai"
+ fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
- fill_in "When", :with => "2014-06-15"
- fill_in "How many?", :with => 42
- select "cutting", :from => "Planted from:"
- select "semi-shade", :from => "Sun or shade?"
- fill_in "Tell us more about it", :with => "It's rad."
+ fill_in "When", with: "2014-06-15"
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "semi-shade", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
click_button "Save"
end
expect(page).to have_content "Planting was successfully created"
+ expect(page).to have_content "Progress: Not calculated, days before maturity unknown"
+ end
+
+ scenario "Clicking link to owner's profile" do
+ visit plantings_by_owner_path(member)
+ click_link "View #{member}'s profile >>"
+ expect(current_path).to eq member_path(member)
+ end
+
+ describe "Progress bar status on planting creation" do
+ before do
+ login_as member
+ visit new_planting_path
+
+ @a_past_date = 15.days.ago.strftime("%Y-%m-%d")
+ @right_now = Date.today.strftime("%Y-%m-%d")
+ @a_future_date = 1.years.from_now.strftime("%Y-%m-%d")
+ end
+
+ it "should show that it is not planted yet" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: @a_future_date
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "semi-shade", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
+ click_button "Save"
+ end
+
+ expect(page).to have_content "Planting was successfully created"
+ expect(page).to have_content "Progress: 0% - not planted yet"
+ end
+
+ it "should show that days before maturity is unknown" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: @a_past_date
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "semi-shade", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
+ click_button "Save"
+ end
+
+ expect(page).to have_content "Planting was successfully created"
+ expect(page).to have_content "Progress: Not calculated, days before maturity unknown"
+ expect(page).to have_content "Days until maturity: unknown"
+ end
+
+ it "should show that planting is in progress" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: @right_now
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "semi-shade", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
+ fill_in "Finished date", with: @a_future_date
+ click_button "Save"
+ end
+
+ expect(page).to have_content "Planting was successfully created"
+ expect(page).to_not have_content "Progress: 0% - not planted yet"
+ expect(page).to_not have_content "Progress: Not calculated, days before maturity unknown"
+ end
+
+ it "should show that planting is 100% complete (no date specified)" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: @right_now
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "semi-shade", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
+ check "Mark as finished"
+ click_button "Save"
+ end
+
+ expect(page).to have_content "Planting was successfully created"
+ expect(page).to have_content "Progress: 100%"
+ expect(page).to have_content "Yes (no date specified)"
+ expect(page).to have_content "Days until maturity: 0"
+ end
+
+ it "should show that planting is 100% complete (date specified)" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: @a_past_date
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "semi-shade", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
+ fill_in "Finished date", with: @right_now
+ click_button "Save"
+ end
+
+ expect(page).to have_content "Planting was successfully created"
+ expect(page).to have_content "Progress: 100%"
+ expect(page).to have_content "Days until maturity: 0"
+ end
end
scenario "Planting from crop page" do
@@ -41,31 +163,50 @@ feature "Planting a crop", :js => true do
expect(page).to have_content "maize"
end
+ scenario "Editing a planting to add details" do
+ visit planting_path(planting)
+ click_link "Edit"
+ fill_in "Tell us more about it", with: "Some extra notes"
+ click_button "Save"
+ expect(page).to have_content "Planting was successfully updated"
+ end
+
+ scenario "Editing a planting to fill in the finished date" do
+ visit planting_path(planting)
+ expect(page).to have_content "Progress: Not calculated, days before maturity unknown"
+ click_link "Edit"
+ check "finished"
+ fill_in "Finished date", with: "2015-06-25"
+ click_button "Save"
+ expect(page).to have_content "Planting was successfully updated"
+ expect(page).to_not have_content "Progress: Not calculated, days before maturity unknown"
+ end
+
scenario "Marking a planting as finished" do
- fill_autocomplete "crop", :with => "mai"
+ fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
- fill_in "When?", :with => "2014-07-01"
+ fill_in "When?", with: "2014-07-01"
check "Mark as finished"
- fill_in "Finished date", :with => "2014-08-30"
+ fill_in "Finished date", with: "2014-08-30"
# Trigger click instead of using Capybara"s uncheck
# because a date selection widget is overlapping
# the checkbox preventing interaction.
- page.find("#planting_finished").trigger("click")
+ find("#planting_finished").trigger 'click'
end
# Javascript removes the finished at date when the
# planting is marked unfinished.
- expect(page.find("#planting_finished_at").value).to eq("")
+ expect(find("#planting_finished_at").value).to eq("")
within "form#new_planting" do
- page.find("#planting_finished").trigger("click")
+ find("#planting_finished").trigger 'click'
end
# The finished at date was cached in Javascript in
# case the user clicks unfinished accidentally.
- expect(page.find("#planting_finished_at").value).to eq("2014-08-30")
+ expect(find("#planting_finished_at").value).to eq("2014-08-30")
within "form#new_planting" do
click_button "Save"
@@ -78,7 +219,7 @@ feature "Planting a crop", :js => true do
end
scenario "Marking a planting as finished without a date" do
- fill_autocomplete "crop", :with => "mai"
+ fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_planting" do
check "Mark as finished"
@@ -86,19 +227,55 @@ feature "Planting a crop", :js => true do
end
expect(page).to have_content "Planting was successfully created"
expect(page).to have_content "Finished: Yes (no date specified)"
+ expect(page).to have_content "Progress: 100%"
+ end
+
+ describe "Planting sunniness" do
+ it "should show the image sunniness_sun.png" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: "2015-10-15"
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ select "sun", from: "Sun or shade?"
+ fill_in "Tell us more about it", with: "It's rad."
+ check "Mark as finished"
+ click_button "Save"
+ end
+
+ expect(page).to have_css("img[src*='sunniness_sun.png']")
+ expect(page).to have_css("img[alt=sun]")
+ end
+
+ it "should show the image 'not specified.png'" do
+ fill_autocomplete "crop", with: "mai"
+ select_from_autocomplete "maize"
+ within "form#new_planting" do
+ fill_in "When", with: "2015-10-15"
+ fill_in "How many?", with: 42
+ select "cutting", from: "Planted from:"
+ fill_in "Tell us more about it", with: "It's rad."
+ check "Mark as finished"
+ click_button "Save"
+ end
+
+ expect(page).to have_css("img[src*='sunniness_not specified.png']")
+ expect(page).to have_css("img[alt='not specified']")
+ end
end
describe "Marking a planting as finished from the show page" do
- let(:path) { planting_path(planting) }
+ let(:path) { planting_path(planting) }
let(:link_text) { "Mark as finished" }
it_behaves_like "append date"
end
describe "Marking a planting as finished from the list page" do
- let(:path) { plantings_path }
+ let(:path) { plantings_path }
let(:link_text) { "Mark as finished" }
+
it_behaves_like "append date"
end
-
end
diff --git a/spec/features/posts/posting_a_post_spec.rb b/spec/features/posts/posting_a_post_spec.rb
new file mode 100644
index 000000000..ac31b6fec
--- /dev/null
+++ b/spec/features/posts/posting_a_post_spec.rb
@@ -0,0 +1,33 @@
+require 'rails_helper'
+
+feature 'Post a post' do
+ let(:member) { create :member }
+
+ background do
+ login_as member
+ visit new_post_path
+ end
+
+ scenario "creating a post" do
+ fill_in "post_subject", with: "Testing"
+ fill_in "post_body", with: "This is a sample test"
+ click_button "Post"
+ expect(page).to have_content "Post was successfully created"
+ expect(page).to have_content "Posted by"
+ end
+
+ context "editing a post" do
+ let(:existing_post) { create :post, author: member }
+
+ background do
+ visit edit_post_path(existing_post)
+ end
+
+ scenario "saving edit" do
+ fill_in "post_subject", with: "Testing Edit"
+ click_button "Post"
+ expect(page).to have_content "Post was successfully updated"
+ expect(page).to have_content "edited at"
+ end
+ end
+end
diff --git a/spec/features/rss/comments_spec.rb b/spec/features/rss/comments_spec.rb
index 3f7ce9dc8..f053a7e26 100644
--- a/spec/features/rss/comments_spec.rb
+++ b/spec/features/rss/comments_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require 'rails_helper'
feature 'Comments RSS feed' do
scenario 'The index feed exists' do
- visit comments_path(:format => 'rss')
+ visit comments_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
- visit comments_path(:format => 'rss')
+ visit comments_path(format: 'rss')
expect(page).to have_content "Recent comments on all posts (#{ENV['GROWSTUFF_SITE_NAME']})"
end
-end
\ No newline at end of file
+end
diff --git a/spec/features/rss/crops_spec.rb b/spec/features/rss/crops_spec.rb
index 971ec1b80..ef45af20b 100644
--- a/spec/features/rss/crops_spec.rb
+++ b/spec/features/rss/crops_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require 'rails_helper'
feature 'Crops RSS feed' do
scenario 'The index feed exists' do
- visit crops_path(:format => 'rss')
+ visit crops_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
- visit crops_path(:format => 'rss')
+ visit crops_path(format: 'rss')
expect(page).to have_content "Recently added crops (#{ENV['GROWSTUFF_SITE_NAME']})"
end
-end
\ No newline at end of file
+end
diff --git a/spec/features/rss/members_spec.rb b/spec/features/rss/members_spec.rb
index 69abb5a25..3849f9d80 100644
--- a/spec/features/rss/members_spec.rb
+++ b/spec/features/rss/members_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require 'rails_helper'
feature 'Members RSS feed' do
- let(:member) { FactoryGirl.create(:member) }
+ let(:member) { create :member }
scenario 'The show action exists' do
- visit member_path(member, :format => 'rss')
+ visit member_path(member, format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The show action title is what we expect' do
- visit member_path(member, :format => 'rss')
+ visit member_path(member, format: 'rss')
expect(page).to have_content "#{member.login_name}'s recent posts (#{ENV['GROWSTUFF_SITE_NAME']})"
end
-end
\ No newline at end of file
+end
diff --git a/spec/features/rss/plantings_spec.rb b/spec/features/rss/plantings_spec.rb
index 5a0e98371..effad2969 100644
--- a/spec/features/rss/plantings_spec.rb
+++ b/spec/features/rss/plantings_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require 'rails_helper'
feature 'Plantings RSS feed' do
scenario 'The index feed exists' do
- visit plantings_path(:format => 'rss')
+ visit plantings_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
- visit plantings_path(:format => 'rss')
+ visit plantings_path(format: 'rss')
expect(page).to have_content "Recent plantings from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
end
-end
\ No newline at end of file
+end
diff --git a/spec/features/rss/posts_spec.rb b/spec/features/rss/posts_spec.rb
index 899c1427b..2d900ebe4 100644
--- a/spec/features/rss/posts_spec.rb
+++ b/spec/features/rss/posts_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require 'rails_helper'
feature 'Posts RSS feed' do
scenario 'The index feed exists' do
- visit posts_path(:format => 'rss')
+ visit posts_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
- visit posts_path(:format => 'rss')
+ visit posts_path(format: 'rss')
expect(page).to have_content "Recent posts from #{ @author ? @author : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
end
-end
\ No newline at end of file
+end
diff --git a/spec/features/rss/seeds_spec.rb b/spec/features/rss/seeds_spec.rb
index e0d016939..7e5320655 100644
--- a/spec/features/rss/seeds_spec.rb
+++ b/spec/features/rss/seeds_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require 'rails_helper'
feature 'Seeds RSS feed' do
scenario 'The index feed exists' do
- visit seeds_path(:format => 'rss')
+ visit seeds_path(format: 'rss')
expect(page.status_code).to equal 200
end
scenario 'The index title is what we expect' do
- visit seeds_path(:format => 'rss')
+ visit seeds_path(format: 'rss')
expect(page).to have_content "Recent seeds from #{ @owner ? @owner : 'all members' } (#{ENV['GROWSTUFF_SITE_NAME']})"
end
-end
\ No newline at end of file
+end
diff --git a/spec/features/scientific_name_spec.rb b/spec/features/scientific_name_spec.rb
index c6cd60c6a..c5b621e10 100644
--- a/spec/features/scientific_name_spec.rb
+++ b/spec/features/scientific_name_spec.rb
@@ -1,7 +1,7 @@
require 'rails_helper'
-feature "Scientific names" do
- let!(:zea_mays) { FactoryGirl.create(:zea_mays) }
+feature "Scientific names", js: true do
+ let!(:zea_mays) { create :zea_mays }
let(:crop) { zea_mays.crop }
scenario "Display scientific names on crop page" do
@@ -17,10 +17,10 @@ feature "Scientific names" do
end
context "User is a crop wrangler" do
- let!(:crop_wranglers) { FactoryGirl.create_list(:crop_wrangling_member, 3) }
- let(:member){crop_wranglers.first}
+ let!(:crop_wranglers) { create_list :crop_wrangling_member, 3 }
+ let(:member) { crop_wranglers.first }
- before :each do
+ background do
login_as(member)
end
@@ -29,7 +29,7 @@ feature "Scientific names" do
expect(page.status_code).to equal 200
expect(page).to have_content "CROP WRANGLER"
expect(page).to have_content zea_mays.scientific_name
- expect(page).to have_link "Edit", :href => edit_scientific_name_path(zea_mays)
+ expect(page).to have_link "Edit", href: edit_scientific_name_path(zea_mays)
within('.scientific_names') { click_on "Edit" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -42,7 +42,7 @@ feature "Scientific names" do
scenario "Crop wranglers can delete scientific names" do
visit crop_path(zea_mays.crop)
expect(page).to have_link "Delete",
- href: scientific_name_path(zea_mays)
+ href: scientific_name_path(zea_mays)
within('.scientific_names') { click_on "Delete" }
expect(page.status_code).to equal 200
expect(page).to_not have_content zea_mays.scientific_name
@@ -52,7 +52,7 @@ feature "Scientific names" do
scenario "Crop wranglers can add scientific names" do
visit crop_path(crop)
expect(page).to have_link "Add",
- href: new_scientific_name_path(crop_id: crop.id)
+ href: new_scientific_name_path(crop_id: crop.id)
within('.scientific_names') { click_on "Add" }
expect(page.status_code).to equal 200
expect(page).to have_css "option[value='#{crop.id}'][selected=selected]"
@@ -67,9 +67,17 @@ feature "Scientific names" do
visit scientific_name_path(zea_mays)
expect(page.status_code).to equal 200
expect(page).to have_link zea_mays.crop.name,
- href: crop_path(zea_mays.crop)
+ href: crop_path(zea_mays.crop)
end
- end
+ context "When scientific name is pending" do
+ let(:pending_crop) { create :crop_request }
+ let(:pending_sci_name) { create :scientific_name, crop: pending_crop }
+ scenario "Displays crop pending message" do
+ visit scientific_name_path(pending_sci_name)
+ expect(page).to have_content "This crop is currently pending approval"
+ end
+ end
+ end
end
diff --git a/spec/features/seeds/adding_seeds_spec.rb b/spec/features/seeds/adding_seeds_spec.rb
index b14622d47..e52a96136 100644
--- a/spec/features/seeds/adding_seeds_spec.rb
+++ b/spec/features/seeds/adding_seeds_spec.rb
@@ -1,30 +1,48 @@
require 'rails_helper'
+require 'custom_matchers'
-feature "Seeds", :js => true do
- let(:member) { FactoryGirl.create(:member) }
- let!(:maize) { FactoryGirl.create(:maize) }
+feature "Seeds", :js do
+ let(:member) { create :member }
+ let!(:maize) { create :maize }
background do
- login_as(member)
+ login_as member
visit new_seed_path
- sync_elasticsearch([maize])
+ sync_elasticsearch [maize]
end
it_behaves_like "crop suggest", "seed", "crop"
- scenario "Adding a new seed", :js => true do
- fill_autocomplete "crop", :with => "mai"
+ it "has the required fields help text" do
+ expect(page).to have_content "* denotes a required field"
+ end
+
+ it "displays required and optional fields properly" do
+ expect(page).to have_selector ".form-group.required", text: "Crop:"
+ expect(page).to have_optional 'input#seed_quantity'
+ expect(page).to have_optional 'input#seed_plant_before'
+ expect(page).to have_optional 'input#seed_days_until_maturity_min'
+ expect(page).to have_optional 'input#seed_days_until_maturity_max'
+ expect(page).to have_selector '.form-group.required', text: 'Organic?'
+ expect(page).to have_selector '.form-group.required', text: 'GMO?'
+ expect(page).to have_selector '.form-group.required', text: 'Heirloom?'
+ expect(page).to have_optional 'textarea#seed_description'
+ expect(page).to have_selector '.form-group.required', text: 'Will trade:'
+ end
+
+ scenario "Adding a new seed", js: true do
+ fill_autocomplete "crop", with: "mai"
select_from_autocomplete "maize"
within "form#new_seed" do
- fill_in "Quantity:", :with => 42
- fill_in "Plant before:", :with => "2014-06-15"
- fill_in "Days until maturity:", :with => 999
- fill_in "to", :with => 1999
- select "certified organic", :from => "Organic?"
- select "non-certified GMO-free", :from => "GMO?"
- select "heirloom", :from => "Heirloom?"
- fill_in "Description", :with => "It's killer."
- select "internationally", :from => "Will trade:"
+ fill_in "Quantity:", with: 42
+ fill_in "Plant before:", with: "2014-06-15"
+ fill_in "Days until maturity:", with: 999
+ fill_in "to", with: 1999
+ select "certified organic", from: "Organic?"
+ select "non-certified GMO-free", from: "GMO?"
+ select "heirloom", from: "Heirloom?"
+ fill_in "Description", with: "It's killer."
+ select "internationally", from: "Will trade:"
click_button "Save"
end
@@ -48,5 +66,4 @@ feature "Seeds", :js => true do
expect(page).to have_content "Successfully added maize seed to your stash"
expect(page).to have_content "maize"
end
-
end
diff --git a/spec/features/seeds/misc_seeds_spec.rb b/spec/features/seeds/misc_seeds_spec.rb
index 1e434a754..1db053a80 100644
--- a/spec/features/seeds/misc_seeds_spec.rb
+++ b/spec/features/seeds/misc_seeds_spec.rb
@@ -1,74 +1,76 @@
require 'rails_helper'
-feature "seeds" do
+feature "seeds", js: true do
context "signed in user" do
- before(:each) do
- @crop = FactoryGirl.create(:crop)
- @member = FactoryGirl.create(:member)
- visit root_path
- click_link 'Sign in'
- fill_in 'Login', :with => @member.login_name
- fill_in 'Password', :with => @member.password
- click_button 'Sign in'
+ let(:member) { create :member }
+ let(:crop) { create :crop }
+
+ background do
+ login_as member
end
scenario "button on index to edit seed" do
- seed = FactoryGirl.create(:seed, :owner => @member)
+ seed = create :seed, owner: member
visit seeds_path
- click_link "Edit"
- current_path.should eq edit_seed_path(seed)
- page.should have_content 'Editing seeds'
+ click_link "edit_seed_glyphicon"
+ expect(current_path).to eq edit_seed_path(seed)
+ expect(page).to have_content 'Editing seeds'
end
scenario "button on front page to add seeds" do
visit root_path
click_link "Add seeds"
- current_path.should eq new_seed_path
- page.should have_content 'Add seeds'
+ expect(current_path).to eq new_seed_path
+ expect(page).to have_content 'Add seeds'
+ end
+
+ scenario "Clicking link to owner's profile" do
+ visit seeds_by_owner_path(member)
+ click_link "View #{member}'s profile >>"
+ expect(current_path).to eq member_path(member)
end
# actually adding seeds is in spec/features/seeds_new_spec.rb
scenario "edit seeds" do
- seed = FactoryGirl.create(:seed, :owner => @member)
+ seed = create :seed, owner: member
visit seed_path(seed)
click_link 'Edit'
- current_path.should eq edit_seed_path(seed)
- fill_in 'Quantity:', :with => seed.quantity * 2
+ expect(current_path).to eq edit_seed_path(seed)
+ fill_in 'Quantity:', with: seed.quantity * 2
click_button 'Save'
- current_path.should eq seed_path(seed)
+ expect(current_path).to eq seed_path(seed)
end
scenario "delete seeds" do
- seed = FactoryGirl.create(:seed, :owner => @member)
+ seed = create :seed, owner: member
visit seed_path(seed)
click_link 'Delete'
- current_path.should eq seeds_path
+ expect(current_path).to eq seeds_path
end
scenario "view seeds with max and min days until maturity" do
- seed = FactoryGirl.create(:seed, :days_until_maturity_min => 5, :days_until_maturity_max => 7)
+ seed = create :seed, days_until_maturity_min: 5, days_until_maturity_max: 7
visit seed_path(seed)
expect(page).to have_content "Days until maturity: 5–7"
end
scenario "view seeds with only max days until maturity" do
- seed = FactoryGirl.create(:seed, :days_until_maturity_max => 7)
+ seed = create :seed, days_until_maturity_max: 7
visit seed_path(seed)
expect(page).to have_content "Days until maturity: 7"
end
scenario "view seeds with only min days until maturity" do
- seed = FactoryGirl.create(:seed, :days_until_maturity_min => 5)
+ seed = create :seed, days_until_maturity_min: 5
visit seed_path(seed)
expect(page).to have_content "Days until maturity: 5"
end
scenario "view seeds with neither max nor min days until maturity" do
- seed = FactoryGirl.create(:seed)
+ seed = create :seed
visit seed_path(seed)
expect(page).to have_content "Days until maturity: unknown"
end
-
end
end
diff --git a/spec/features/shared_examples/append_date.rb b/spec/features/shared_examples/append_date.rb
index 089680ff9..310e39606 100644
--- a/spec/features/shared_examples/append_date.rb
+++ b/spec/features/shared_examples/append_date.rb
@@ -1,22 +1,21 @@
shared_examples "append date" do
+ let(:this_month) { Date.today.strftime("%B") }
+ let(:this_year) { Date.today.strftime("%Y") }
+
+ background { visit path }
scenario "Selecting a date with datepicker" do
- this_month = Date.today.strftime("%B")
- this_year = Date.today.strftime("%Y")
- visit path
click_link link_text
within "div.datepicker" do
expect(page).to have_content "#{this_month}"
- page.find(".datepicker-days td.day", text: "21").click
+ find(".datepicker-days td.day", text: "21").click
end
expect(page).to have_content "Finished: #{this_month} 21, #{this_year}"
end
scenario "Confirming without selecting date" do
- visit path
click_link link_text
click_link "Confirm without date"
expect(page).to have_content("Finished: Yes (no date specified) ")
end
-
end
\ No newline at end of file
diff --git a/spec/features/shared_examples/crop_suggest.rb b/spec/features/shared_examples/crop_suggest.rb
index 9856282ca..8f45c1e96 100644
--- a/spec/features/shared_examples/crop_suggest.rb
+++ b/spec/features/shared_examples/crop_suggest.rb
@@ -1,48 +1,52 @@
require 'rails_helper'
shared_examples "crop suggest" do |resource|
- let!(:pea) { FactoryGirl.create(:crop, :name => 'pea') }
- let!(:pear) { FactoryGirl.create(:pear) }
- let!(:tomato) { FactoryGirl.create(:tomato) }
- let!(:roma) { FactoryGirl.create(:roma) }
+ let!(:pea) { create :crop, name: 'pea' }
+ let!(:pear) { create :pear }
+ let!(:tomato) { create :tomato }
+ let!(:roma) { create :roma }
- background do
- sync_elasticsearch([pea, pear, maize, tomato])
- end
+ background { sync_elasticsearch [pea, pear, maize, tomato] }
- scenario "See text in crop auto suggest field" do
+ scenario "placeholder text in crop auto suggest field" do
expect(page).to have_selector("input[placeholder='e.g. lettuce']")
end
- scenario "Typing in the crop name displays suggestions" do
+ scenario "typing in the crop name displays suggestions" do
within "form#new_#{resource}" do
- fill_autocomplete "crop", :with => "pe"
+ fill_autocomplete "crop", with: "pe"
end
expect(page).to_not have_content("pear")
expect(page).to_not have_content("pea")
within "form#new_#{resource}" do
- fill_autocomplete "crop", :with => "pea"
+ fill_autocomplete "crop", with: "pea"
end
expect(page).to have_content("pear")
expect(page).to have_content("pea")
within "form#new_#{resource}" do
- fill_autocomplete "crop", :with => "pear"
+ fill_autocomplete "crop", with: "pear"
end
expect(page).to have_content("pear")
+ end
+
+ scenario "selecting crop from dropdown" do
+ within "form#new_#{resource}" do
+ fill_autocomplete "crop", with: "pear"
+ end
select_from_autocomplete("pear")
- expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", :visible => false)
+ expect(page).to have_selector("input##{resource}_crop_id[value='#{pear.id}']", visible: false)
end
scenario "Typing and pausing does not affect input" do
within "form#new_#{resource}" do
- fill_autocomplete "crop", :with => "pea"
+ fill_autocomplete "crop", with: "pea"
end
expect(page).to have_content("pear")
@@ -51,7 +55,7 @@ shared_examples "crop suggest" do |resource|
scenario "Searching for a crop casts a wide net on results" do
within "form#new_#{resource}" do
- fill_autocomplete "crop", :with => "tom"
+ fill_autocomplete "crop", with: "tom"
end
expect(page).to have_content("tomato")
@@ -60,11 +64,10 @@ shared_examples "crop suggest" do |resource|
scenario "Submitting a crop that doesn't exist in the database produces a meaningful error" do
within "form#new_#{resource}" do
- fill_autocomplete "crop", :with => "Ryan Gosling"
+ fill_autocomplete "crop", with: "Ryan Gosling"
click_button "Save"
end
expect(page).to have_content("Crop must be present and exist in our database")
end
-
-end
\ No newline at end of file
+end
diff --git a/spec/features/signin_spec.rb b/spec/features/signin_spec.rb
index dced5f2ac..c091e572c 100644
--- a/spec/features/signin_spec.rb
+++ b/spec/features/signin_spec.rb
@@ -1,9 +1,11 @@
require 'rails_helper'
-feature "signin" do
- let(:member){FactoryGirl.create(:member)}
- let(:recipient){FactoryGirl.create(:member)}
- let(:notification){FactoryGirl.create(:notification)}
+
+feature "signin", js: true do
+ let(:member) { create :member }
+ let(:recipient) { create :member }
+ let(:wrangler) { create :crop_wrangling_member }
+ let(:notification) { create :notification }
scenario "redirect to previous page after signin" do
visit crops_path # some random page
@@ -11,7 +13,7 @@ feature "signin" do
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
- current_path.should eq crops_path
+ expect(current_path).to eq crops_path
end
scenario "don't redirect to devise pages after signin" do
@@ -20,34 +22,43 @@ feature "signin" do
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
- current_path.should eq root_path
+ expect(current_path).to eq root_path
end
scenario "redirect to signin page for if not authenticated to view notification" do
visit notification_path(notification)
- current_path.should eq new_member_session_path
+ expect(current_path).to eq new_member_session_path
end
scenario "after signin, redirect to what you were trying to do" do
models = %w[plantings harvests posts photos gardens seeds]
models.each do |model|
visit "/#{model}/new"
- current_path.should eq new_member_session_path
+ expect(current_path).to eq new_member_session_path
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
- current_path.should eq "/#{model}/new"
+ expect(current_path).to eq "/#{model}/new"
click_link 'Sign out'
end
end
scenario "after signin, redirect to new notifications page" do
visit new_notification_path(recipient: recipient)
- current_path.should eq new_member_session_path
+ expect(current_path).to eq new_member_session_path
fill_in 'Login', with: member.login_name
fill_in 'Password', with: member.password
click_button 'Sign in'
- current_path.should eq new_notification_path
+ expect(current_path).to eq new_notification_path
end
+ scenario "after crop wrangler signs in and crops await wrangling, show alert" do
+ create :crop_request
+ visit crops_path # some random page
+ click_link 'Sign in'
+ fill_in 'Login', with: wrangler.login_name
+ fill_in 'Password', with: wrangler.password
+ click_button 'Sign in'
+ expect(page).to have_content("There are crops waiting to be wrangled.")
+ end
end
diff --git a/spec/features/signout_spec.rb b/spec/features/signout_spec.rb
new file mode 100644
index 000000000..2d5d1a230
--- /dev/null
+++ b/spec/features/signout_spec.rb
@@ -0,0 +1,30 @@
+require 'rails_helper'
+
+feature "signout" do
+ let(:member) { create :member }
+
+ scenario "redirect to previous page after signout" do
+ visit crops_path # some random page
+ click_link 'Sign in'
+ fill_in 'Login', with: member.login_name
+ fill_in 'Password', with: member.password
+ click_button 'Sign in'
+ click_link 'Sign out'
+ expect(current_path).to eq crops_path
+ end
+
+ scenario "after signout, redirect to signin page if page needs authentication" do
+ models = %w[plantings harvests posts photos gardens seeds]
+ models.each do |model|
+ visit "/#{model}/new"
+ expect(current_path).to eq new_member_session_path
+ fill_in 'Login', with: member.login_name
+ fill_in 'Password', with: member.password
+ click_button 'Sign in'
+ expect(current_path).to eq "/#{model}/new"
+ click_link 'Sign out'
+ expect(current_path).to eq new_member_session_path
+ end
+ end
+
+end
diff --git a/spec/features/signup_spec.rb b/spec/features/signup_spec.rb
index aa4c9d65f..f35ddd0c9 100644
--- a/spec/features/signup_spec.rb
+++ b/spec/features/signup_spec.rb
@@ -1,6 +1,6 @@
require 'rails_helper'
-feature "signup" do
+feature "signup", js: true do
scenario "sign up for new account from top menubar" do
visit crops_path # something other than front page, which has multiple signup links
@@ -11,7 +11,7 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
check 'member_tos_agreement'
click_button 'Sign up'
- current_path.should eq root_path
+ expect(current_path).to eq root_path
end
scenario "sign up for new account with existing username" do
@@ -23,8 +23,7 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
check 'member_tos_agreement'
click_button 'Sign up'
- page.has_content? 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
- current_path.should eq root_path
+ expect(current_path).to eq root_path
first('.signup a').click # click the 'Sign up' button in the middle of the page
fill_in 'Login name', with: 'person123'
fill_in 'Email', with: 'gardener@example.com'
@@ -32,7 +31,6 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
check 'member_tos_agreement'
click_button 'Sign up'
- page.has_content? 'Login name has already been taken'
end
scenario "sign up for new account without accepting TOS" do
@@ -44,8 +42,6 @@ feature "signup" do
fill_in 'Password confirmation', with: 'abc123'
# do not check 'member_tos_agreement'
click_button 'Sign up'
- page.has_content? 'Tos agreement must be accepted'
- current_path.should eq members_path
+ expect(current_path).to eq members_path
end
-
end
diff --git a/spec/features/unsubscribing_spec.rb b/spec/features/unsubscribing_spec.rb
new file mode 100644
index 000000000..e8242f542
--- /dev/null
+++ b/spec/features/unsubscribing_spec.rb
@@ -0,0 +1,59 @@
+require 'rails_helper'
+require 'capybara/email/rspec'
+
+feature "unsubscribe" do
+ let(:member) { create :member }
+ let(:notification) { create :notification }
+
+ background do
+ clear_emails
+ end
+
+ scenario "from planting reminder mailing list" do
+ # verifying the initial subscription status of the member
+ expect(member.send_planting_reminder).to eq(true)
+ expect(member.send_notification_email).to eq(true)
+
+ # generate planting reminder email
+ Notifier.planting_reminder(member).deliver
+ open_email(member.email)
+
+ # clicking 'Unsubscribe' link will unsubscribe the member
+ current_email.click_link 'Unsubscribe from planting reminders'
+ expect(page).to have_content "You have been unsubscribed from planting reminders"
+ updated_member = Member.find(member.id) # reload the member
+ expect(updated_member.send_planting_reminder).to eq(false)
+ expect(updated_member.send_notification_email).to eq(true)
+ end
+
+ scenario "from inbox notification mailing list" do
+ # verifying the initial subscription status of the member
+ expect(member.send_planting_reminder).to eq(true)
+ expect(member.send_notification_email).to eq(true)
+
+ # generate inbox notification email
+ notification.recipient = member
+ Notifier.notify(notification).deliver
+ open_email(member.email)
+
+ # clicking 'Unsubscribe' link will unsubscribe the member
+ current_email.click_link 'Unsubscribe from direct message notifications'
+ expect(page).to have_content "You have been unsubscribed from direct message notifications"
+ updated_member = Member.find(member.id) # reload the member
+ expect(updated_member.send_planting_reminder).to eq(true)
+ expect(updated_member.send_notification_email).to eq(false)
+ end
+
+ scenario "visit unsubscribe page with a non-encrypted parameter" do
+ # verifying the initial subscription status of the member
+ expect(member.send_planting_reminder).to eq(true)
+ expect(member.send_notification_email).to eq(true)
+
+ # visit /members/unsubscribe/somestring ie.parameter to the URL is a random string
+ visit unsubscribe_member_url("type=send_planting_reminder&member_id=#{member.id}")
+ expect(page).to have_content "We're sorry, there was an error"
+ updated_member = Member.find(member.id) # reload the member
+ expect(member.send_planting_reminder).to eq(true)
+ expect(member.send_notification_email).to eq(true)
+ end
+end
\ No newline at end of file
diff --git a/spec/helpers/application_helper.rb b/spec/helpers/application_helper.rb
deleted file mode 100644
index 9a39e59a7..000000000
--- a/spec/helpers/application_helper.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require 'rails_helper'
-
-describe ApplicationHelper do
- it "formats prices" do
- price_in_dollars(999).should eq '9.99'
- price_with_currency(999).should eq '9.99 AUD'
- end
-
- it "parses dates" do
- parse_date(nil).should eq nil
- parse_date('').should eq nil
- parse_date('2012-05-12').should eq Date.new(2012, 5, 12)
- parse_date('may 12th 2012').should eq Date.new(2012, 5, 12)
- end
-end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
new file mode 100644
index 000000000..057f68e58
--- /dev/null
+++ b/spec/helpers/application_helper_spec.rb
@@ -0,0 +1,46 @@
+require 'rails_helper'
+
+describe ApplicationHelper do
+ it "formats prices" do
+ price_in_dollars(999).should eq '9.99'
+ price_with_currency(999).should eq '9.99 %s' % Growstuff::Application.config.currency
+ end
+
+ it "parses dates" do
+ parse_date(nil).should eq nil
+ parse_date('').should eq nil
+ parse_date('2012-05-12').should eq Date.new(2012, 5, 12)
+ parse_date('may 12th 2012').should eq Date.new(2012, 5, 12)
+ end
+
+ it "shows required field marker help text with proper formatting" do
+ output = required_field_help_text
+ expect(output).to have_selector '.margin-bottom'
+ expect(output).to have_selector '.red', text: '*'
+ expect(output).to have_selector 'em', text: 'denotes a required field'
+ end
+
+ describe '#avatar_uri' do
+ context 'with a normal user' do
+ before :each do
+ @member = FactoryGirl.build(:member, email: 'example@example.com', preferred_avatar_uri: nil)
+ end
+ it 'should render a gravatar uri' do
+ expect(avatar_uri(@member)).to eq 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=150&default=identicon'
+ end
+
+ it 'should render a gravatar uri for a given size' do
+ expect(avatar_uri(@member, 456)).to eq 'http://www.gravatar.com/avatar/23463b99b62a72f26ed677cc556c44e8?size=456&default=identicon'
+ end
+ end
+
+ context 'with a user who specified a preferred avatar uri' do
+ before :each do
+ @member = FactoryGirl.build(:member, email: 'example@example.com', preferred_avatar_uri: 'http://media.catmoji.com/post/ujg/cat-in-hat.jpg')
+ end
+ it 'should render a the specified uri' do
+ expect(avatar_uri(@member)).to eq 'http://media.catmoji.com/post/ujg/cat-in-hat.jpg'
+ end
+ end
+ end
+end
diff --git a/spec/helpers/gardens_helper_spec.rb b/spec/helpers/gardens_helper_spec.rb
new file mode 100644
index 000000000..c561c32d1
--- /dev/null
+++ b/spec/helpers/gardens_helper_spec.rb
@@ -0,0 +1,110 @@
+require 'rails_helper'
+
+describe GardensHelper do
+ describe "garden description" do
+ it "is missing" do
+ garden = FactoryGirl.create(:garden,
+ description: nil
+ )
+ result = helper.display_garden_description(garden)
+ expect(result).to eq "no description provided."
+ end
+
+ it "is less than 130 characters long" do
+ garden = FactoryGirl.create(:garden,
+ description: 'a' * 20
+ )
+ result = helper.display_garden_description(garden)
+ expect(result).to eq 'a' * 20
+ end
+
+ it "is 130 characters long" do
+ garden = FactoryGirl.create(:garden,
+ description: 'a' * 130
+ )
+ result = helper.display_garden_description(garden)
+ link = link_to("Read more", garden_path(garden))
+ expect(result).to eq 'a' * 130
+ end
+
+ it "is more than 130 characters long" do
+ garden = FactoryGirl.create(:garden,
+ description: 'a' * 140
+ )
+ result = helper.display_garden_description(garden)
+ expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", garden_path(garden))
+ end
+ end
+
+ describe "garden plantings" do
+ it "is missing" do
+ garden = FactoryGirl.create(:garden)
+ plantings = nil
+ result = helper.display_garden_plantings(plantings)
+ expect(result).to eq "None"
+ end
+
+ it "has 1 planting" do
+ garden = FactoryGirl.create(:garden)
+ plantings = []
+ crop = FactoryGirl.create(:crop)
+ plantings << FactoryGirl.create(:planting, quantity: 10, crop: crop)
+ result = helper.display_garden_plantings(plantings)
+
+ output = "
"
+ expect(result).to eq output
+ end
+ end
+end
diff --git a/spec/helpers/harvests_helper_spec.rb b/spec/helpers/harvests_helper_spec.rb
index 7bc516162..c65d8b36e 100644
--- a/spec/helpers/harvests_helper_spec.rb
+++ b/spec/helpers/harvests_helper_spec.rb
@@ -5,8 +5,8 @@ describe HarvestsHelper do
it "blank" do
harvest = FactoryGirl.create(:harvest,
- :quantity => nil,
- :weight_quantity => nil
+ quantity: nil,
+ weight_quantity: nil
)
result = helper.display_quantity(harvest)
result.should eq 'not specified'
@@ -14,9 +14,9 @@ describe HarvestsHelper do
it '3 individual' do
harvest = FactoryGirl.create(:harvest,
- :quantity => 3,
- :unit => 'individual',
- :weight_quantity => nil
+ quantity: 3,
+ unit: 'individual',
+ weight_quantity: nil
)
result = helper.display_quantity(harvest)
result.should eq '3'
@@ -24,9 +24,9 @@ describe HarvestsHelper do
it '1 bunch' do
harvest = FactoryGirl.create(:harvest,
- :quantity => 1,
- :unit => 'bunch',
- :weight_quantity => nil
+ quantity: 1,
+ unit: 'bunch',
+ weight_quantity: nil
)
result = helper.display_quantity(harvest)
result.should eq '1 bunch'
@@ -34,9 +34,9 @@ describe HarvestsHelper do
it '3 bunches' do
harvest = FactoryGirl.create(:harvest,
- :quantity => 3,
- :unit => 'bunch',
- :weight_quantity => nil
+ quantity: 3,
+ unit: 'bunch',
+ weight_quantity: nil
)
result = helper.display_quantity(harvest)
result.should eq '3 bunches'
@@ -44,10 +44,10 @@ describe HarvestsHelper do
it '3 kg' do
harvest = FactoryGirl.create(:harvest,
- :quantity => nil,
- :unit => nil,
- :weight_quantity => 3,
- :weight_unit => 'kg'
+ quantity: nil,
+ unit: nil,
+ weight_quantity: 3,
+ weight_unit: 'kg'
)
result = helper.display_quantity(harvest)
result.should eq '3 kg'
@@ -55,10 +55,10 @@ describe HarvestsHelper do
it '3 individual weighing 3 kg' do
harvest = FactoryGirl.create(:harvest,
- :quantity => 3,
- :unit => 'individual',
- :weight_quantity => 3,
- :weight_unit => 'kg'
+ quantity: 3,
+ unit: 'individual',
+ weight_quantity: 3,
+ weight_unit: 'kg'
)
result = helper.display_quantity(harvest)
result.should eq '3, weighing 3 kg'
@@ -66,10 +66,10 @@ describe HarvestsHelper do
it '3 bunches weighing 3 kg' do
harvest = FactoryGirl.create(:harvest,
- :quantity => 3,
- :unit => 'bunch',
- :weight_quantity => 3,
- :weight_unit => 'kg'
+ quantity: 3,
+ unit: 'bunch',
+ weight_quantity: 3,
+ weight_unit: 'kg'
)
result = helper.display_quantity(harvest)
result.should eq '3 bunches, weighing 3 kg'
diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb
index 85f96d664..109bf0c87 100644
--- a/spec/helpers/notifications_helper_spec.rb
+++ b/spec/helpers/notifications_helper_spec.rb
@@ -3,29 +3,24 @@ require 'rails_helper'
describe NotificationsHelper do
describe "reply_link" do
- before(:each) do
- @member = FactoryGirl.create(:member)
- end
+ let(:member) { FactoryGirl.create(:member) }
it "replies to PMs with PMs" do
- notification = FactoryGirl.create(:notification, :recipient_id => @member.id, :post_id => nil)
+ notification = FactoryGirl.create(:notification, recipient_id: member.id, post_id: nil)
subject = "Re: " + notification.subject
link = helper.reply_link(notification)
link.should_not be_nil
- link.should eq new_notification_url(
- :recipient_id => notification.sender_id,
- :subject => subject
- )
+ link.should eq reply_notification_url(notification)
end
it "replies to post comments with post comments" do
- notification = FactoryGirl.create(:notification, :recipient_id => @member.id)
+ notification = FactoryGirl.create(:notification, recipient_id: member.id)
link = helper.reply_link(notification)
link.should_not be_nil
link.should eq new_comment_url(
- :post_id => notification.post.id
+ post_id: notification.post.id
)
end
diff --git a/spec/helpers/plantings_helper_spec.rb b/spec/helpers/plantings_helper_spec.rb
new file mode 100644
index 000000000..ae8c78c78
--- /dev/null
+++ b/spec/helpers/plantings_helper_spec.rb
@@ -0,0 +1,74 @@
+require 'rails_helper'
+
+describe PlantingsHelper do
+ describe "display_planting" do
+
+ let!(:member) { FactoryGirl.build(:member, login_name: 'crop_lady') }
+
+ it "does not have a quantity nor a planted from value provided" do
+ planting = FactoryGirl.build(:planting,
+ quantity: nil,
+ planted_from: '',
+ owner: member
+ )
+ result = helper.display_planting(planting)
+ expect(result).to eq "crop_lady."
+ end
+
+ it "does not have a quantity provided" do
+ planting = FactoryGirl.build(:planting,
+ quantity: nil,
+ planted_from: 'seed',
+ owner: member
+ )
+ result = helper.display_planting(planting)
+ expect(result).to eq "crop_lady planted seeds."
+ end
+
+ context "when quantity is greater than 1" do
+ it "does not have a planted from value provided" do
+ planting = FactoryGirl.build(:planting,
+ quantity: 10,
+ planted_from: '',
+ owner: member
+ )
+ result = helper.display_planting(planting)
+ expect(result).to eq "crop_lady planted 10 units."
+ end
+
+ it "does have a planted from value provided" do
+ planting = FactoryGirl.build(:planting,
+ quantity: 5,
+ planted_from: 'seed',
+ owner: member
+ )
+ result = helper.display_planting(planting)
+ expect(result).to eq "crop_lady planted 5 seeds."
+ end
+ end
+
+ context "when quantity is 1" do
+ it "does not have a planted from value provided" do
+ planting = FactoryGirl.build(:planting,
+ quantity: 1,
+ planted_from: '',
+ owner: member
+ )
+ result = helper.display_planting(planting)
+ expect(result).to eq "crop_lady planted 1 unit."
+ end
+
+ it "does have a planted from value provided" do
+ planting = FactoryGirl.build(:planting,
+ quantity: 1,
+ planted_from: 'seed',
+ owner: member
+ )
+ result = helper.display_planting(planting)
+ expect(result).to eq "crop_lady planted 1 seed."
+ end
+
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/spec/helpers/seeds_helper_spec.rb b/spec/helpers/seeds_helper_spec.rb
new file mode 100644
index 000000000..c86dc2637
--- /dev/null
+++ b/spec/helpers/seeds_helper_spec.rb
@@ -0,0 +1,38 @@
+require 'rails_helper'
+
+describe SeedsHelper do
+ describe "seed description" do
+ it "is missing" do
+ seed = FactoryGirl.create(:seed,
+ description: nil
+ )
+ result = helper.display_seed_description(seed)
+ expect(result).to eq "no description provided."
+ end
+
+ it "is less than 130 characters long" do
+ seed = FactoryGirl.create(:seed,
+ description: 'a' * 20
+ )
+ result = helper.display_seed_description(seed)
+ expect(result).to eq 'a' * 20
+ end
+
+ it "is 130 characters long" do
+ seed = FactoryGirl.create(:seed,
+ description: 'a' * 130
+ )
+ result = helper.display_seed_description(seed)
+ link = link_to("Read more", seed_path(seed))
+ expect(result).to eq 'a' * 130
+ end
+
+ it "is more than 130 characters long" do
+ seed = FactoryGirl.create(:seed,
+ description: 'a' * 140
+ )
+ result = helper.display_seed_description(seed)
+ expect(result).to eq 'a' * 126 + '...' + ' ' + link_to("Read more", seed_path(seed))
+ end
+ end
+end
diff --git a/spec/lib/haml/filters/growstuff_markdown_spec.rb b/spec/lib/haml/filters/growstuff_markdown_spec.rb
index 8abe8aee4..2aba8fb89 100644
--- a/spec/lib/haml/filters/growstuff_markdown_spec.rb
+++ b/spec/lib/haml/filters/growstuff_markdown_spec.rb
@@ -7,7 +7,7 @@ def input_link(name)
end
def output_link(crop, name=nil)
- url = Rails.application.routes.url_helpers.crop_url(crop, :host => Growstuff::Application.config.host)
+ url = Rails.application.routes.url_helpers.crop_url(crop, host: Growstuff::Application.config.host)
if name
return "#{name}"
else
@@ -15,6 +15,20 @@ def output_link(crop, name=nil)
end
end
+def input_member_link(name)
+ return "[#{name}](member)"
+end
+
+def output_member_link(member, name=nil)
+ url = Rails.application.routes.url_helpers.member_url(member, only_path: true)
+ if name
+ return "#{name}"
+ else
+ return "#{member.login_name}"
+ end
+end
+
+
describe 'Haml::Filters::Growstuff_Markdown' do
it 'is registered as the handler for :growstuff_markdown' do
Haml::Filters::defined['growstuff_markdown'].should ==
@@ -32,6 +46,12 @@ describe 'Haml::Filters::Growstuff_Markdown' do
rendered.should match /not a crop/
end
+ it "doesn't convert escaped crop links" do
+ @crop = FactoryGirl.create(:crop)
+ rendered = Haml::Filters::GrowstuffMarkdown.render( "\\" << input_link(@crop.name))
+ rendered.should match /\[#{@crop.name}\]\(crop\)/
+ end
+
it "handles multiple crop links" do
tomato = FactoryGirl.create(:tomato)
maize = FactoryGirl.create(:maize)
@@ -47,7 +67,7 @@ describe 'Haml::Filters::Growstuff_Markdown' do
end
it "finds crops case insensitively" do
- @crop = FactoryGirl.create(:crop, :name => 'tomato')
+ @crop = FactoryGirl.create(:crop, name: 'tomato')
rendered = Haml::Filters::GrowstuffMarkdown.render(input_link('ToMaTo'))
rendered.should match /#{output_link(@crop, 'ToMaTo')}/
end
@@ -60,4 +80,47 @@ describe 'Haml::Filters::Growstuff_Markdown' do
rendered.should match "test"
end
+ it 'converts quick member links' do
+ @member = FactoryGirl.create(:member)
+ rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link(@member.login_name))
+ rendered.should match /#{output_member_link(@member)}/
+ end
+
+ it "doesn't convert nonexistent members" do
+ rendered = Haml::Filters::GrowstuffMarkdown.render(input_member_link("not a member"))
+ rendered.should match /not a member/
+ end
+
+ it "doesn't convert escaped members" do
+ @member = FactoryGirl.create(:member)
+ rendered = Haml::Filters::GrowstuffMarkdown.render("\\" << input_member_link(@member.login_name))
+ rendered.should match /\[#{@member.login_name}\]\(member\)/
+ end
+
+
+ it 'converts @ member links' do
+ @member = FactoryGirl.create(:member)
+ rendered = Haml::Filters::GrowstuffMarkdown.render("Hey @#{@member.login_name}! What's up")
+ rendered.should match /#{output_member_link(@member, "@#{@member.login_name}")}/
+ end
+
+ it "doesn't convert invalid @ members" do
+ rendered = Haml::Filters::GrowstuffMarkdown.render("@not-a-member")
+ rendered.should match /@not-a-member/
+ end
+
+ it "doesn't convert nonexistent @ members" do
+ @member = FactoryGirl.create(:member)
+ @member_name = @member.login_name
+ @member.destroy
+ rendered = Haml::Filters::GrowstuffMarkdown.render("Hey @#{@member_name}")
+ rendered.should match /Hey @#{@member_name}/
+ end
+
+ it "doesn't convert escaped @ members" do
+ @member = FactoryGirl.create(:member)
+ rendered = Haml::Filters::GrowstuffMarkdown.render("Hey \\@#{@member.login_name}! What's up")
+ rendered.should match /Hey @#{@member.login_name}!/
+ end
+
end
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb
index 87d8a3b1d..f31f7f845 100644
--- a/spec/models/ability_spec.rb
+++ b/spec/models/ability_spec.rb
@@ -2,36 +2,36 @@ require 'rails_helper'
require 'cancan/matchers'
describe Ability do
- before(:each) do
- @member = FactoryGirl.create(:member)
- @ability = Ability.new(@member)
- end
+
+ let(:member) { FactoryGirl.create(:member) }
+ let(:ability) { Ability.new(member) }
context "notifications" do
+
it 'member can view their own notifications' do
- @notification = FactoryGirl.create(:notification, :recipient => @member)
- @ability.should be_able_to(:read, @notification)
+ notification = FactoryGirl.create(:notification, recipient: member)
+ ability.should be_able_to(:read, notification)
end
it "member can't view someone else's notifications" do
- @notification = FactoryGirl.create(:notification,
- :recipient => FactoryGirl.create(:member)
+ notification = FactoryGirl.create(:notification,
+ recipient: FactoryGirl.create(:member)
)
- @ability.should_not be_able_to(:read, @notification)
+ ability.should_not be_able_to(:read, notification)
end
it "member can't send messages to themself" do
- @ability.should_not be_able_to(:create,
+ ability.should_not be_able_to(:create,
FactoryGirl.create(:notification,
- :recipient => @member,
- :sender => @member
+ recipient: member,
+ sender: member
)
)
end
it "member can send messages to someone else" do
- @ability.should be_able_to(:create,
+ ability.should be_able_to(:create,
FactoryGirl.create(:notification,
- :recipient => FactoryGirl.create(:member),
- :sender => @member
+ recipient: FactoryGirl.create(:member),
+ sender: member
)
)
end
@@ -39,245 +39,240 @@ describe Ability do
context "crop wrangling" do
- before(:each) do
- @crop = FactoryGirl.create(:crop)
- end
+ let(:crop) { FactoryGirl.create(:crop) }
context "standard member" do
it "can't manage crops" do
- @ability.should_not be_able_to(:update, @crop)
- @ability.should_not be_able_to(:destroy, @crop)
+ ability.should_not be_able_to(:update, crop)
+ ability.should_not be_able_to(:destroy, crop)
end
it "can request crops" do
- @ability.should be_able_to(:create, Crop)
+ ability.should be_able_to(:create, Crop)
end
it "can read crops" do
- @ability.should be_able_to(:read, @crop)
+ ability.should be_able_to(:read, crop)
end
end
context "crop wrangler" do
+
+ let(:role) { FactoryGirl.create(:crop_wrangler) }
+
before(:each) do
- @role = FactoryGirl.create(:crop_wrangler)
- @member.roles << @role
- @cw_ability = Ability.new(@member)
+ member.roles << role
end
it "has crop_wrangler role" do
- @member.has_role?(:crop_wrangler).should be true
+ member.has_role?(:crop_wrangler).should be true
end
it "can create crops" do
- @cw_ability.should be_able_to(:create, Crop)
+ ability.should be_able_to(:create, Crop)
end
it "can update crops" do
- @cw_ability.should be_able_to(:update, @crop)
+ ability.should be_able_to(:update, crop)
end
it "can destroy crops" do
- @cw_ability.should be_able_to(:destroy, @crop)
+ ability.should be_able_to(:destroy, crop)
end
end
end
context "products" do
- before(:each) do
- @product = FactoryGirl.create(:product)
- end
+ let(:product) { FactoryGirl.create(:product) }
context "standard member" do
it "can't read or manage products" do
- @ability.should_not be_able_to(:read, @product)
- @ability.should_not be_able_to(:create, Product)
- @ability.should_not be_able_to(:update, @product)
- @ability.should_not be_able_to(:destroy, @product)
+ ability.should_not be_able_to(:read, product)
+ ability.should_not be_able_to(:create, Product)
+ ability.should_not be_able_to(:update, product)
+ ability.should_not be_able_to(:destroy, product)
end
end
context "admin" do
- before(:each) do
- @role = FactoryGirl.create(:admin)
- @member.roles << @role
- @admin_ability = Ability.new(@member)
+
+ let(:role) { FactoryGirl.create(:admin) }
+
+ before do
+ member.roles << role
end
it "has admin role" do
- @member.has_role?(:admin).should be true
+ member.has_role?(:admin).should be true
end
it "can read products" do
- @admin_ability.should be_able_to(:read, @product)
+ ability.should be_able_to(:read, product)
end
it "can create products" do
- @admin_ability.should be_able_to(:create, Product)
+ ability.should be_able_to(:create, Product)
end
it "can update products" do
- @admin_ability.should be_able_to(:update, @product)
+ ability.should be_able_to(:update, product)
end
it "can destroy products" do
- @admin_ability.should be_able_to(:destroy, @product)
+ ability.should be_able_to(:destroy, product)
end
end
end
context "orders" do
- before(:each) do
- @order = FactoryGirl.create(:order, :member => @member)
- @strangers_order = FactoryGirl.create(:order,
- :member => FactoryGirl.create(:member))
- @completed_order = FactoryGirl.create(:completed_order,
- :member => @member)
-
- @order_item = FactoryGirl.create(:order_item, :order => @order)
- @strangers_order_item = FactoryGirl.create(:order_item,
- :order => @strangers_order)
- @completed_order_item = FactoryGirl.create(:order_item,
- :order => @completed_order)
- end
+ let(:order) { FactoryGirl.create(:order, member: member) }
+ let(:strangers_order) { FactoryGirl.create(:order,
+ member: FactoryGirl.create(:member)) }
+ let(:completed_order) { FactoryGirl.create(:completed_order,
+ member: member) }
+ let(:order_item) { FactoryGirl.create(:order_item, order: order) }
+ let(:strangers_order_item) { FactoryGirl.create(:order_item,
+ order: strangers_order) }
+ let(:completed_order_item) { FactoryGirl.create(:order_item,
+ order: completed_order) }
context "standard member" do
it "can read their own orders" do
- @ability.should be_able_to(:read, @order)
- @ability.should be_able_to(:read, @completed_order)
+ ability.should be_able_to(:read, order)
+ ability.should be_able_to(:read, completed_order)
end
it "can't read other people's orders" do
- @ability.should_not be_able_to(:read, @strangers_order)
+ ability.should_not be_able_to(:read, strangers_order)
end
it "can create a new order" do
- @ability.should be_able_to(:create, Order)
+ ability.should be_able_to(:create, Order)
end
it "can complete their own current order" do
- @ability.should be_able_to(:complete, @order)
+ ability.should be_able_to(:complete, order)
end
it "can't complete someone else's order" do
- @ability.should_not be_able_to(:complete, @strangers_order)
+ ability.should_not be_able_to(:complete, strangers_order)
end
it "can't complete a completed order" do
- @ability.should_not be_able_to(:complete, @completed_order)
+ ability.should_not be_able_to(:complete, completed_order)
end
it "can delete a current order" do
- @ability.should be_able_to(:destroy, @order)
+ ability.should be_able_to(:destroy, order)
end
it "can't delete someone else's order" do
- @ability.should_not be_able_to(:destroy, @strangers_order)
+ ability.should_not be_able_to(:destroy, strangers_order)
end
it "can't delete a completed order" do
- @ability.should_not be_able_to(:destroy, @completed_order)
+ ability.should_not be_able_to(:destroy, completed_order)
end
it "can't read their own order items" do
- @ability.should_not be_able_to(:read, @order_item)
- @ability.should_not be_able_to(:read, @completed_order_item)
+ ability.should_not be_able_to(:read, order_item)
+ ability.should_not be_able_to(:read, completed_order_item)
end
it "can't read other people's order items" do
- @ability.should_not be_able_to(:read, @strangers_order_item)
+ ability.should_not be_able_to(:read, strangers_order_item)
end
it "can create a new order item" do
- @ability.should be_able_to(:create, OrderItem)
+ ability.should be_able_to(:create, OrderItem)
end
it "can't update their own order items" do
- @ability.should_not be_able_to(:update, @order_item)
+ ability.should_not be_able_to(:update, order_item)
end
it "can't update other people's order items" do
- @ability.should_not be_able_to(:update, @strangers_order_item)
+ ability.should_not be_able_to(:update, strangers_order_item)
end
it "can't updated items in completed orders" do
- @ability.should_not be_able_to(:update, @completed_order_item)
+ ability.should_not be_able_to(:update, completed_order_item)
end
it "can't delete their own order item" do
- @ability.should_not be_able_to(:destroy, @order_item)
+ ability.should_not be_able_to(:destroy, order_item)
end
it "can't delete someone else's order item" do
- @ability.should_not be_able_to(:destroy, @strangers_order_item)
+ ability.should_not be_able_to(:destroy, strangers_order_item)
end
it "can't delete items from completed orders" do
- @ability.should_not be_able_to(:destroy, @completed_order_item)
+ ability.should_not be_able_to(:destroy, completed_order_item)
end
end
context "admin" do
- before(:each) do
- @role = FactoryGirl.create(:admin)
- @member.roles << @role
- @admin_ability = Ability.new(@member)
+
+ let(:role) { FactoryGirl.create(:admin) }
+
+ before do
+ member.roles << role
end
it "has admin role" do
- @member.has_role?(:admin).should be true
+ member.has_role?(:admin).should be true
end
it "can read orders" do
- @admin_ability.should be_able_to(:read, @order)
+ ability.should be_able_to(:read, order)
end
it "cannot create orders" do
- @admin_ability.should_not be_able_to(:create, @order)
+ ability.should_not be_able_to(:create, order)
end
it "cannot complete orders" do
- @admin_ability.should_not be_able_to(:complete, @order)
+ ability.should_not be_able_to(:complete, order)
end
it "cannot delete orders" do
- @admin_ability.should_not be_able_to(:destroy, @order)
+ ability.should_not be_able_to(:destroy, order)
end
end
end
context 'account details' do
- before(:each) do
- @account = @member.account
- end
+
+ let(:account) { member.account }
context 'ordinary member' do
it "can't read account details" do
- @ability.should_not be_able_to(:read, @account)
+ ability.should_not be_able_to(:read, account)
end
it "can't manage account details" do
- @ability.should_not be_able_to(:create, Account)
- @ability.should_not be_able_to(:update, @account)
- @ability.should_not be_able_to(:destroy, @account)
+ ability.should_not be_able_to(:create, Account)
+ ability.should_not be_able_to(:update, account)
+ ability.should_not be_able_to(:destroy, account)
end
end
context 'admin' do
- before(:each) do
- @role = FactoryGirl.create(:admin)
- @member.roles << @role
- @admin_ability = Ability.new(@member)
+ let(:role) { FactoryGirl.create(:admin) }
+
+ before do
+ member.roles << role
end
it "can read account details" do
- @admin_ability.should be_able_to(:read, @account)
+ ability.should be_able_to(:read, account)
end
it "can manage account details" do
- @admin_ability.should be_able_to(:create, Account)
- @admin_ability.should be_able_to(:update, @account)
- @admin_ability.should be_able_to(:destroy, @account)
+ ability.should be_able_to(:create, Account)
+ ability.should be_able_to(:update, account)
+ ability.should be_able_to(:destroy, account)
end
end
@@ -285,44 +280,43 @@ describe Ability do
end
context 'plant parts' do
- before(:each) do
- @plant_part = FactoryGirl.create(:plant_part)
- end
+
+ let(:plant_part) { FactoryGirl.create(:plant_part) }
context 'ordinary member' do
it "can read plant parts" do
- @ability.should be_able_to(:read, @plant_part)
+ ability.should be_able_to(:read, plant_part)
end
it "can't manage plant parts" do
- @ability.should_not be_able_to(:create, PlantPart)
- @ability.should_not be_able_to(:update, @plant_part)
- @ability.should_not be_able_to(:destroy, @plant_part)
+ ability.should_not be_able_to(:create, PlantPart)
+ ability.should_not be_able_to(:update, plant_part)
+ ability.should_not be_able_to(:destroy, plant_part)
end
end
context 'admin' do
- before(:each) do
- @role = FactoryGirl.create(:admin)
- @member.roles << @role
- @admin_ability = Ability.new(@member)
+ let(:role) { FactoryGirl.create(:admin) }
+
+ before do
+ member.roles << role
end
it "can read plant_part details" do
- @admin_ability.should be_able_to(:read, @plant_part)
+ ability.should be_able_to(:read, plant_part)
end
it "can manage plant_part details" do
- @admin_ability.should be_able_to(:create, PlantPart)
- @admin_ability.should be_able_to(:update, @plant_part)
+ ability.should be_able_to(:create, PlantPart)
+ ability.should be_able_to(:update, plant_part)
end
it "can delete an unused plant part" do
- @admin_ability.should be_able_to(:destroy, @plant_part)
+ ability.should be_able_to(:destroy, plant_part)
end
it "can't delete a plant part that has harvests" do
- @harvest = FactoryGirl.create(:harvest, :plant_part => @plant_part)
- @admin_ability.should_not be_able_to(:destroy, @plant_part)
+ @harvest = FactoryGirl.create(:harvest, plant_part: plant_part)
+ ability.should_not be_able_to(:destroy, plant_part)
end
end
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index b1765ccc0..1274a825e 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -1,30 +1,29 @@
require 'rails_helper'
describe Account do
- before(:each) do
- @member = FactoryGirl.create(:member)
- end
+
+ let(:member) { FactoryGirl.create(:member) }
it "auto-creates an account detail record when a member is created" do
- @member.account.should be_an_instance_of Account
+ member.account.should be_an_instance_of Account
end
it "won't let you create two account details for the same member" do
- @details = Account.new(:member_id => @member.id)
+ @details = Account.new(member_id: member.id)
@details.should_not be_valid
end
it "formats the 'paid until' date nicely" do
- @member.account.account_type = FactoryGirl.create(:account_type)
- @member.account.paid_until_string.should eq nil
+ member.account.account_type = FactoryGirl.create(:account_type)
+ member.account.paid_until_string.should eq nil
- @member.account.account_type = FactoryGirl.create(:permanent_paid_account_type)
- @member.account.paid_until_string.should eq "forever"
+ member.account.account_type = FactoryGirl.create(:permanent_paid_account_type)
+ member.account.paid_until_string.should eq "forever"
- @member.account.account_type = FactoryGirl.create(:paid_account_type)
+ member.account.account_type = FactoryGirl.create(:paid_account_type)
@time = Time.zone.now
- @member.account.paid_until = @time
- @member.account.paid_until_string.should eq @time.to_s
+ member.account.paid_until = @time
+ member.account.paid_until_string.should eq @time.to_s
end
end
diff --git a/spec/models/alternate_name_spec.rb b/spec/models/alternate_name_spec.rb
index ecbdc10eb..5e12b02de 100644
--- a/spec/models/alternate_name_spec.rb
+++ b/spec/models/alternate_name_spec.rb
@@ -10,9 +10,9 @@ describe AlternateName do
it 'should be possible to add multiple alternate names to a crop' do
crop = an.crop
an2 = AlternateName.create(
- :name => "really alternative tomato",
- :crop_id => crop.id,
- :creator_id => an.creator.id
+ name: "really alternative tomato",
+ crop_id: crop.id,
+ creator_id: an.creator.id
)
crop.alternate_names << an2
expect(crop.alternate_names).to include an
diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb
index d54cd5606..f3c94860e 100644
--- a/spec/models/comment_spec.rb
+++ b/spec/models/comment_spec.rb
@@ -3,23 +3,21 @@ require 'rails_helper'
describe Comment do
context "basic" do
- before(:each) do
- @comment = FactoryGirl.create(:comment)
- end
+
+ let(:comment) { FactoryGirl.create(:comment) }
it "belongs to a post" do
- @comment.post.should be_an_instance_of Post
+ comment.post.should be_an_instance_of Post
end
it "belongs to an author" do
- @comment.author.should be_an_instance_of Member
+ comment.author.should be_an_instance_of Member
end
end
context "notifications" do
- before(:each) do
- @comment = FactoryGirl.create(:comment)
- end
+
+ let(:comment) { FactoryGirl.create(:comment) }
it "sends a notification when a comment is posted" do
expect {
@@ -39,9 +37,9 @@ describe Comment do
it "doesn't send notifications to yourself" do
@m = FactoryGirl.create(:member)
- @p = FactoryGirl.create(:post, :author => @m)
+ @p = FactoryGirl.create(:post, author: @m)
expect {
- FactoryGirl.create(:comment, :post => @p, :author => @m)
+ FactoryGirl.create(:comment, post: @p, author: @m)
}.to change(Notification, :count).by(0)
end
end
@@ -49,9 +47,9 @@ describe Comment do
context "ordering" do
before(:each) do
@m = FactoryGirl.create(:member)
- @p = FactoryGirl.create(:post, :author => @m)
- @c1 = FactoryGirl.create(:comment, :post => @p, :author => @m)
- @c2 = FactoryGirl.create(:comment, :post => @p, :author => @m)
+ @p = FactoryGirl.create(:post, author: @m)
+ @c1 = FactoryGirl.create(:comment, post: @p, author: @m)
+ @c2 = FactoryGirl.create(:comment, post: @p, author: @m)
end
it 'is in DESC order by default' do
diff --git a/spec/models/crop_spec.rb b/spec/models/crop_spec.rb
index 9cda818e8..047ca0c6a 100644
--- a/spec/models/crop_spec.rb
+++ b/spec/models/crop_spec.rb
@@ -3,44 +3,42 @@ require 'rails_helper'
describe Crop do
context 'all fields present' do
- before(:each) do
- @crop = FactoryGirl.create(:tomato)
- end
+ let(:crop) { FactoryGirl.create(:tomato) }
it 'should save a basic crop' do
- @crop.save.should be(true)
+ crop.save.should be(true)
end
it 'should be fetchable from the database' do
- @crop.save
+ crop.save
@crop2 = Crop.find_by_name('tomato')
@crop2.en_wikipedia_url.should == "http://en.wikipedia.org/wiki/Tomato"
@crop2.slug.should == "tomato"
end
it 'should stringify as the system name' do
- @crop.save
- @crop.to_s.should == 'tomato'
- "#{@crop}".should == 'tomato'
+ crop.save
+ crop.to_s.should == 'tomato'
+ "#{crop}".should == 'tomato'
end
it 'has a creator' do
- @crop.save
- @crop.creator.should be_an_instance_of Member
+ crop.save
+ crop.creator.should be_an_instance_of Member
end
end
context 'invalid data' do
it 'should not save a crop without a system name' do
- @crop = FactoryGirl.build(:crop, :name => nil)
- expect { @crop.save }.to raise_error ActiveRecord::StatementInvalid
+ crop = FactoryGirl.build(:crop, name: nil)
+ expect { crop.save }.to raise_error ActiveRecord::StatementInvalid
end
end
context 'ordering' do
- before(:each) do
- @uppercase = FactoryGirl.create(:uppercasecrop, :created_at => 1.minute.ago)
- @lowercase = FactoryGirl.create(:lowercasecrop, :created_at => 2.days.ago)
+ before do
+ @uppercase = FactoryGirl.create(:uppercasecrop, created_at: 1.minute.ago)
+ @lowercase = FactoryGirl.create(:lowercasecrop, created_at: 2.days.ago)
end
it "should be sorted case-insensitively" do
@@ -53,18 +51,20 @@ describe Crop do
end
context 'popularity' do
- before (:each) do
- @tomato = FactoryGirl.create(:tomato)
- @maize = FactoryGirl.create(:maize)
- @cucumber = FactoryGirl.create(:crop, :name => 'cucumber')
- FactoryGirl.create_list(:planting, 10, :crop => @maize)
- FactoryGirl.create_list(:planting, 3, :crop => @tomato)
+
+ let(:tomato) { FactoryGirl.create(:tomato) }
+ let(:maize) { FactoryGirl.create(:maize) }
+ let(:cucumber) { FactoryGirl.create(:crop, name: 'cucumber') }
+
+ before do
+ FactoryGirl.create_list(:planting, 10, crop: maize)
+ FactoryGirl.create_list(:planting, 3, crop: tomato)
end
it "sorts by most plantings" do
- Crop.popular.first.should eq @maize
- FactoryGirl.create_list(:planting, 10, :crop => @tomato)
- Crop.popular.first.should eq @tomato
+ Crop.popular.first.should eq maize
+ FactoryGirl.create_list(:planting, 10, crop: tomato)
+ Crop.popular.first.should eq tomato
end
end
@@ -72,36 +72,37 @@ describe Crop do
it 'finds a default scientific name' do
@crop = FactoryGirl.create(:tomato)
@crop.default_scientific_name.should eq nil
- @sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @crop)
+ @sn = FactoryGirl.create(:solanum_lycopersicum, crop: @crop)
+ @crop.reload
@crop.default_scientific_name.should eq @sn.scientific_name
end
it 'counts plantings' do
@crop = FactoryGirl.create(:tomato)
@crop.plantings.size.should eq 0
- @planting = FactoryGirl.create(:planting, :crop => @crop)
+ @planting = FactoryGirl.create(:planting, crop: @crop)
@crop.reload
@crop.plantings.size.should eq 1
end
it 'validates en_wikipedia_url' do
- @crop = FactoryGirl.build(:tomato, :en_wikipedia_url => 'this is not valid')
+ @crop = FactoryGirl.build(:tomato, en_wikipedia_url: 'this is not valid')
@crop.should_not be_valid
- @crop = FactoryGirl.build(:tomato, :en_wikipedia_url => 'http://en.wikipedia.org/wiki/SomePage')
+ @crop = FactoryGirl.build(:tomato, en_wikipedia_url: 'http://en.wikipedia.org/wiki/SomePage')
@crop.should be_valid
end
context 'varieties' do
it 'has a crop hierarchy' do
@tomato = FactoryGirl.create(:tomato)
- @roma = FactoryGirl.create(:roma, :parent_id => @tomato.id)
+ @roma = FactoryGirl.create(:roma, parent_id: @tomato.id)
@roma.parent.should eq @tomato
@tomato.varieties.should eq [@roma]
end
it 'toplevel scope works' do
@tomato = FactoryGirl.create(:tomato)
- @roma = FactoryGirl.create(:roma, :parent_id => @tomato.id)
+ @roma = FactoryGirl.create(:roma, parent_id: @tomato.id)
Crop.toplevel.should eq [ @tomato ]
end
end
@@ -109,7 +110,7 @@ describe Crop do
context 'photos' do
it 'has a default photo' do
@crop = FactoryGirl.create(:tomato)
- @planting = FactoryGirl.create(:planting, :crop => @crop)
+ @planting = FactoryGirl.create(:planting, crop: @crop)
@photo = FactoryGirl.create(:photo)
@planting.photos << @photo
@crop.default_photo.should be_an_instance_of Photo
@@ -117,70 +118,67 @@ describe Crop do
end
context 'sunniness' do
- before(:each) do
- @crop = FactoryGirl.create(:tomato)
- end
+
+ let(:crop) { FactoryGirl.create(:tomato) }
it 'returns a hash of sunniness values' do
- planting1 = FactoryGirl.create(:sunny_planting, :crop => @crop)
- planting2 = FactoryGirl.create(:sunny_planting, :crop => @crop)
- planting3 = FactoryGirl.create(:semi_shady_planting, :crop => @crop)
- planting4 = FactoryGirl.create(:shady_planting, :crop => @crop)
- @crop.sunniness.should be_an_instance_of Hash
+ planting1 = FactoryGirl.create(:sunny_planting, crop: crop)
+ planting2 = FactoryGirl.create(:sunny_planting, crop: crop)
+ planting3 = FactoryGirl.create(:semi_shady_planting, crop: crop)
+ planting4 = FactoryGirl.create(:shady_planting, crop: crop)
+ crop.sunniness.should be_an_instance_of Hash
end
it 'counts each sunniness value' do
- planting1 = FactoryGirl.create(:sunny_planting, :crop => @crop)
- planting2 = FactoryGirl.create(:sunny_planting, :crop => @crop)
- planting3 = FactoryGirl.create(:semi_shady_planting, :crop => @crop)
- planting4 = FactoryGirl.create(:shady_planting, :crop => @crop)
- @crop.sunniness.should == { 'sun' => 2, 'shade' => 1, 'semi-shade' => 1 }
+ planting1 = FactoryGirl.create(:sunny_planting, crop: crop)
+ planting2 = FactoryGirl.create(:sunny_planting, crop: crop)
+ planting3 = FactoryGirl.create(:semi_shady_planting, crop: crop)
+ planting4 = FactoryGirl.create(:shady_planting, crop: crop)
+ crop.sunniness.should == { 'sun' => 2, 'shade' => 1, 'semi-shade' => 1 }
end
it 'ignores unused sunniness values' do
- planting1 = FactoryGirl.create(:sunny_planting, :crop => @crop)
- planting2 = FactoryGirl.create(:sunny_planting, :crop => @crop)
- planting3 = FactoryGirl.create(:semi_shady_planting, :crop => @crop)
- @crop.sunniness.should == { 'sun' => 2, 'semi-shade' => 1 }
+ planting1 = FactoryGirl.create(:sunny_planting, crop: crop)
+ planting2 = FactoryGirl.create(:sunny_planting, crop: crop)
+ planting3 = FactoryGirl.create(:semi_shady_planting, crop: crop)
+ crop.sunniness.should == { 'sun' => 2, 'semi-shade' => 1 }
end
end
context 'planted_from' do
- before(:each) do
- @crop = FactoryGirl.create(:tomato)
- end
+
+ let(:crop) { FactoryGirl.create(:tomato) }
it 'returns a hash of sunniness values' do
- planting1 = FactoryGirl.create(:seed_planting, :crop => @crop)
- planting2 = FactoryGirl.create(:seed_planting, :crop => @crop)
- planting3 = FactoryGirl.create(:seedling_planting, :crop => @crop)
- planting4 = FactoryGirl.create(:cutting_planting, :crop => @crop)
- @crop.planted_from.should be_an_instance_of Hash
+ planting1 = FactoryGirl.create(:seed_planting, crop: crop)
+ planting2 = FactoryGirl.create(:seed_planting, crop: crop)
+ planting3 = FactoryGirl.create(:seedling_planting, crop: crop)
+ planting4 = FactoryGirl.create(:cutting_planting, crop: crop)
+ crop.planted_from.should be_an_instance_of Hash
end
it 'counts each planted_from value' do
- planting1 = FactoryGirl.create(:seed_planting, :crop => @crop)
- planting2 = FactoryGirl.create(:seed_planting, :crop => @crop)
- planting3 = FactoryGirl.create(:seedling_planting, :crop => @crop)
- planting4 = FactoryGirl.create(:cutting_planting, :crop => @crop)
- @crop.planted_from.should == { 'seed' => 2, 'seedling' => 1, 'cutting' => 1 }
+ planting1 = FactoryGirl.create(:seed_planting, crop: crop)
+ planting2 = FactoryGirl.create(:seed_planting, crop: crop)
+ planting3 = FactoryGirl.create(:seedling_planting, crop: crop)
+ planting4 = FactoryGirl.create(:cutting_planting, crop: crop)
+ crop.planted_from.should == { 'seed' => 2, 'seedling' => 1, 'cutting' => 1 }
end
it 'ignores unused planted_from values' do
- planting1 = FactoryGirl.create(:seed_planting, :crop => @crop)
- planting2 = FactoryGirl.create(:seed_planting, :crop => @crop)
- planting3 = FactoryGirl.create(:seedling_planting, :crop => @crop)
- @crop.planted_from.should == { 'seed' => 2, 'seedling' => 1 }
+ planting1 = FactoryGirl.create(:seed_planting, crop: crop)
+ planting2 = FactoryGirl.create(:seed_planting, crop: crop)
+ planting3 = FactoryGirl.create(:seedling_planting, crop: crop)
+ crop.planted_from.should == { 'seed' => 2, 'seedling' => 1 }
end
end
context 'popular plant parts' do
- before(:each) do
- @crop = FactoryGirl.create(:tomato)
- end
+
+ let(:crop) { FactoryGirl.create(:tomato) }
it 'returns a hash of plant_part values' do
- @crop.popular_plant_parts.should be_an_instance_of Hash
+ crop.popular_plant_parts.should be_an_instance_of Hash
end
it 'counts each plant_part value' do
@@ -189,22 +187,22 @@ describe Crop do
@root = FactoryGirl.create(:plant_part)
@bulb = FactoryGirl.create(:plant_part)
@harvest1 = FactoryGirl.create(:harvest,
- :crop => @crop,
- :plant_part => @fruit
+ crop: crop,
+ plant_part: @fruit
)
@harvest2 = FactoryGirl.create(:harvest,
- :crop => @crop,
- :plant_part => @fruit
+ crop: crop,
+ plant_part: @fruit
)
@harvest3 = FactoryGirl.create(:harvest,
- :crop => @crop,
- :plant_part => @seed
+ crop: crop,
+ plant_part: @seed
)
@harvest4 = FactoryGirl.create(:harvest,
- :crop => @crop,
- :plant_part => @root
+ crop: crop,
+ plant_part: @root
)
- @crop.popular_plant_parts.should == { @fruit => 2, @seed => 1, @root => 1 }
+ crop.popular_plant_parts.should == { @fruit => 2, @seed => 1, @root => 1 }
end
end
@@ -217,10 +215,10 @@ describe Crop do
# they need 3+ plantings each to be interesting
(1..3).each do
- FactoryGirl.create(:planting, :crop => @crop1)
+ FactoryGirl.create(:planting, crop: @crop1)
end
(1..3).each do
- FactoryGirl.create(:planting, :crop => @crop2)
+ FactoryGirl.create(:planting, crop: @crop2)
end
# crops need 3+ photos to be interesting
@@ -234,7 +232,7 @@ describe Crop do
Crop.interesting.should include @crop1
Crop.interesting.should include @crop2
- Crop.interesting.length.should == 2
+ Crop.interesting.size.should == 2
end
it 'ignores crops without plantings' do
@@ -244,7 +242,7 @@ describe Crop do
# only crop1 has plantings
(1..3).each do
- FactoryGirl.create(:planting, :crop => @crop1)
+ FactoryGirl.create(:planting, crop: @crop1)
end
# ... and photos
@@ -256,7 +254,7 @@ describe Crop do
Crop.interesting.should include @crop1
Crop.interesting.should_not include @crop2
- Crop.interesting.length.should == 1
+ Crop.interesting.size.should == 1
end
@@ -267,10 +265,10 @@ describe Crop do
# both crops have plantings
(1..3).each do
- FactoryGirl.create(:planting, :crop => @crop1)
+ FactoryGirl.create(:planting, crop: @crop1)
end
(1..3).each do
- FactoryGirl.create(:planting, :crop => @crop2)
+ FactoryGirl.create(:planting, crop: @crop2)
end
# but only crop1 has photos
@@ -282,7 +280,7 @@ describe Crop do
Crop.interesting.should include @crop1
Crop.interesting.should_not include @crop2
- Crop.interesting.length.should == 1
+ Crop.interesting.size.should == 1
end
end
@@ -290,7 +288,7 @@ describe Crop do
context "harvests" do
it "has harvests" do
crop = FactoryGirl.create(:crop)
- harvest = FactoryGirl.create(:harvest, :crop => crop)
+ harvest = FactoryGirl.create(:harvest, crop: crop)
crop.harvests.should eq [harvest]
end
end
@@ -300,47 +298,60 @@ describe Crop do
@pp1 = FactoryGirl.create(:plant_part)
@pp2 = FactoryGirl.create(:plant_part)
@h1 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp1
+ crop: @maize,
+ plant_part: @pp1
)
@h2 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp2
+ crop: @maize,
+ plant_part: @pp2
)
@maize.plant_parts.should include @pp1
@maize.plant_parts.should include @pp2
end
- it "doesn't dupliate plant_parts" do
+ it "doesn't duplicate plant_parts" do
@maize = FactoryGirl.create(:maize)
@pp1 = FactoryGirl.create(:plant_part)
@h1 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp1
+ crop: @maize,
+ plant_part: @pp1
)
@h2 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp1
+ crop: @maize,
+ plant_part: @pp1
)
@maize.plant_parts.should eq [@pp1]
end
context "search" do
- before :each do
- @mushroom = FactoryGirl.create(:crop, :name => 'mushroom')
- sync_elasticsearch([@mushroom])
+
+ let(:mushroom) { FactoryGirl.create(:crop, name: 'mushroom') }
+
+ before do
+ sync_elasticsearch([mushroom])
end
+
it "finds exact matches" do
- Crop.search('mushroom').should eq [@mushroom]
+ Crop.search('mushroom').should eq [mushroom]
end
it "finds approximate matches" do
- Crop.search('mush').should eq [@mushroom]
+ Crop.search('mush').should eq [mushroom]
end
it "doesn't find non-matches" do
Crop.search('mush').should_not include @crop
end
it "searches case insensitively" do
- Crop.search('mUsH').should include @mushroom
+ Crop.search('mUsH').should include mushroom
+ end
+ it "doesn't find 'rejected' crop" do
+ @rejected_crop = FactoryGirl.create(:rejected_crop, name: 'tomato')
+ sync_elasticsearch([@rejected_crop])
+ Crop.search('tomato').should_not include @rejected_crop
+ end
+ it "doesn't find 'pending' crop" do
+ @crop_request = FactoryGirl.create(:crop_request, name: 'tomato')
+ sync_elasticsearch([@crop_request])
+ Crop.search('tomato').should_not include @crop_request
end
end
@@ -363,12 +374,12 @@ describe Crop do
end
it "picks up scientific name from parent crop if available" do
- parent = FactoryGirl.create(:crop, :name => 'parent crop')
+ parent = FactoryGirl.create(:crop, name: 'parent crop')
parent.add_scientific_names_from_csv("Parentis cropis")
parent.save
parent.reload
- tomato = FactoryGirl.create(:tomato, :parent => parent)
+ tomato = FactoryGirl.create(:tomato, parent: parent)
expect(tomato.parent).to eq parent
expect(tomato.parent.default_scientific_name).to eq "Parentis cropis"
@@ -388,12 +399,12 @@ describe Crop do
end
it "doesn't add a duplicate scientific name from parent" do
- parent = FactoryGirl.create(:crop, :name => 'parent')
+ parent = FactoryGirl.create(:crop, name: 'parent')
parent.add_scientific_names_from_csv("Parentis cropis")
parent.save
parent.reload
- tomato = FactoryGirl.create(:tomato, :parent => parent)
+ tomato = FactoryGirl.create(:tomato, parent: parent)
expect(tomato.scientific_names.size).to eq 0
tomato.add_scientific_names_from_csv('')
expect(tomato.scientific_names.size).to eq 1 # picks up parent SN
@@ -498,7 +509,7 @@ describe Crop do
end
it "loads a crop with a parent" do
- parent = FactoryGirl.create(:crop, :name => 'parent')
+ parent = FactoryGirl.create(:crop, name: 'parent')
tomato_row = "tomato,http://en.wikipedia.org/wiki/Tomato,parent"
CSV.parse(tomato_row) do |row|
@@ -528,7 +539,7 @@ describe Crop do
context "crop-post association" do
let!(:tomato) { FactoryGirl.create(:tomato) }
let!(:maize) { FactoryGirl.create(:maize) }
- let!(:post) { FactoryGirl.create(:post, :body => "[maize](crop)[tomato](crop)[tomato](crop)") }
+ let!(:post) { FactoryGirl.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") }
describe "destroying a crop" do
before do
@@ -544,4 +555,19 @@ describe Crop do
end
end
end
+
+ context "crop rejections" do
+ let!(:rejected_reason) { FactoryGirl.create(:crop, name: 'tomato', approval_status: 'rejected', reason_for_rejection: 'not edible') }
+ let!(:rejected_other) { FactoryGirl.create(:crop, name: 'tomato', approval_status: 'rejected', reason_for_rejection: 'other', rejection_notes: 'blah blah blah') }
+
+ describe "rejecting a crop" do
+ it "should give reason if a default option" do
+ expect(rejected_reason.rejection_explanation).to eq "not edible"
+ end
+
+ it "should show rejection notes if reason was other" do
+ expect(rejected_other.rejection_explanation).to eq "blah blah blah"
+ end
+ end
+ end
end
diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb
index 27b42de15..7bebbc7f3 100644
--- a/spec/models/follow_spec.rb
+++ b/spec/models/follow_spec.rb
@@ -9,13 +9,13 @@ describe Follow do
it "sends a notification when a follow is created" do
expect {
- Follow.create(:follower_id => @member1.id, :followed_id => @member2.id)
+ Follow.create(follower_id: @member1.id, followed_id: @member2.id)
}.to change(Notification, :count).by(1)
end
it "does not delete any members when follow is deleted" do
expect {
- follow = Follow.create(:follower_id => @member1.id, :followed_id => @member2.id)
+ follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id)
follow.destroy
}.not_to change(Member, :count)
end
@@ -23,11 +23,11 @@ describe Follow do
context "when follow is created" do
before (:each) do
- @follow = Follow.create(:follower_id => @member1.id, :followed_id => @member2.id)
+ @follow = Follow.create(follower_id: @member1.id, followed_id: @member2.id)
end
it "should not duplicate follows" do
- expect(Follow.create(:follower_id => @member1.id, :followed_id => @member2.id)).not_to be_valid
+ expect(Follow.create(follower_id: @member1.id, followed_id: @member2.id)).not_to be_valid
end
it "should list users in following/follower collections when follow is created" do
diff --git a/spec/models/forum_spec.rb b/spec/models/forum_spec.rb
index 9769882c6..72fafd31c 100644
--- a/spec/models/forum_spec.rb
+++ b/spec/models/forum_spec.rb
@@ -1,32 +1,31 @@
require 'rails_helper'
describe Forum do
- before(:each) do
- @forum = FactoryGirl.create(:forum)
- end
+
+ let(:forum) { FactoryGirl.create(:forum) }
it "belongs to an owner" do
- @forum.owner.should be_an_instance_of Member
+ forum.owner.should be_an_instance_of Member
end
it "stringifies nicely" do
- "#{@forum}".should eq @forum.name
+ "#{forum}".should eq forum.name
end
it 'has a slug' do
- @forum.slug.should eq 'permaculture'
+ forum.slug.should eq 'permaculture'
end
it "has many posts" do
- @post1 = FactoryGirl.create(:forum_post, :forum => @forum)
- @post2 = FactoryGirl.create(:forum_post, :forum => @forum)
- @forum.posts.length.should == 2
+ @post1 = FactoryGirl.create(:forum_post, forum: forum)
+ @post2 = FactoryGirl.create(:forum_post, forum: forum)
+ forum.posts.size.should == 2
end
it "orders posts in reverse chron order" do
- @post1 = FactoryGirl.create(:forum_post, :forum => @forum, :created_at => 2.days.ago)
- @post2 = FactoryGirl.create(:forum_post, :forum => @forum, :created_at => 1.day.ago)
- @forum.posts.first.should eq @post2
+ @post1 = FactoryGirl.create(:forum_post, forum: forum, created_at: 2.days.ago)
+ @post2 = FactoryGirl.create(:forum_post, forum: forum, created_at: 1.day.ago)
+ forum.posts.first.should eq @post2
end
end
diff --git a/spec/models/garden_spec.rb b/spec/models/garden_spec.rb
index 7a6590596..1332e7287 100644
--- a/spec/models/garden_spec.rb
+++ b/spec/models/garden_spec.rb
@@ -1,80 +1,78 @@
require 'rails_helper'
describe Garden do
- before :each do
- @owner = FactoryGirl.create(:member)
- @garden = FactoryGirl.create(:garden, :owner => @owner)
- end
+
+ let(:owner) { FactoryGirl.create(:member) }
+ let(:garden) { FactoryGirl.create(:garden, owner: owner) }
it "should have a slug" do
- @garden.slug.should match(/member\d+-springfield-community-garden/)
+ garden.slug.should match(/member\d+-springfield-community-garden/)
end
it "should have a description" do
- @garden.description.should == "This is a **totally** cool garden"
+ garden.description.should == "This is a **totally** cool garden"
end
it "doesn't allow a nil name" do
- @garden = FactoryGirl.build(:garden, :name => nil)
- @garden.should_not be_valid
+ garden = FactoryGirl.build(:garden, name: nil)
+ garden.should_not be_valid
end
it "doesn't allow a blank name" do
- @garden = FactoryGirl.build(:garden, :name => "")
- @garden.should_not be_valid
+ garden = FactoryGirl.build(:garden, name: "")
+ garden.should_not be_valid
end
it "doesn't allow a name with only spaces" do
- @garden = FactoryGirl.build(:garden, :name => " ")
- @garden.should_not be_valid
+ garden = FactoryGirl.build(:garden, name: " ")
+ garden.should_not be_valid
end
it "should have an owner" do
- @garden.owner.should be_an_instance_of Member
+ garden.owner.should be_an_instance_of Member
end
it "should stringify as its name" do
- @garden.to_s.should == @garden.name
+ garden.to_s.should == garden.name
end
context "featured plantings" do
- before :each do
- @tomato = FactoryGirl.create(:tomato)
- @maize = FactoryGirl.create(:maize)
- @chard = FactoryGirl.create(:chard)
- @apple = FactoryGirl.create(:apple)
- @pear = FactoryGirl.create(:pear)
- @walnut = FactoryGirl.create(:walnut)
- end
+
+ let(:tomato) { FactoryGirl.create(:tomato) }
+ let(:maize) { FactoryGirl.create(:maize) }
+ let(:chard) { FactoryGirl.create(:chard) }
+ let(:apple) { FactoryGirl.create(:apple) }
+ let(:pear) { FactoryGirl.create(:pear) }
+ let(:walnut) { FactoryGirl.create(:walnut) }
it "should fetch < 4 featured plantings if insufficient exist" do
- @p1 = FactoryGirl.create(:planting, :crop => @tomato, :garden => @garden)
- @p2 = FactoryGirl.create(:planting, :crop => @maize, :garden => @garden)
+ @p1 = FactoryGirl.create(:planting, crop: tomato, garden: garden)
+ @p2 = FactoryGirl.create(:planting, crop: maize, garden: garden)
- @garden.featured_plantings.should eq [@p2, @p1]
+ garden.featured_plantings.should eq [@p2, @p1]
end
it "should fetch most recent 4 featured plantings" do
- @p1 = FactoryGirl.create(:planting, :crop => @tomato, :garden => @garden)
- @p2 = FactoryGirl.create(:planting, :crop => @maize, :garden => @garden)
- @p3 = FactoryGirl.create(:planting, :crop => @chard, :garden => @garden)
- @p4 = FactoryGirl.create(:planting, :crop => @apple, :garden => @garden)
- @p5 = FactoryGirl.create(:planting, :crop => @walnut, :garden => @garden)
+ @p1 = FactoryGirl.create(:planting, crop: tomato, garden: garden)
+ @p2 = FactoryGirl.create(:planting, crop: maize, garden: garden)
+ @p3 = FactoryGirl.create(:planting, crop: chard, garden: garden)
+ @p4 = FactoryGirl.create(:planting, crop: apple, garden: garden)
+ @p5 = FactoryGirl.create(:planting, crop: walnut, garden: garden)
- @garden.featured_plantings.should eq [@p5, @p4, @p3, @p2]
+ garden.featured_plantings.should eq [@p5, @p4, @p3, @p2]
end
it "should skip repeated plantings" do
- @p1 = FactoryGirl.create(:planting, :crop => @tomato, :garden => @garden)
- @p2 = FactoryGirl.create(:planting, :crop => @maize, :garden => @garden)
- @p3 = FactoryGirl.create(:planting, :crop => @chard, :garden => @garden)
- @p4 = FactoryGirl.create(:planting, :crop => @apple, :garden => @garden)
- @p5 = FactoryGirl.create(:planting, :crop => @walnut, :garden => @garden)
- @p6 = FactoryGirl.create(:planting, :crop => @apple, :garden => @garden)
- @p7 = FactoryGirl.create(:planting, :crop => @pear, :garden => @garden)
+ @p1 = FactoryGirl.create(:planting, crop: tomato, garden: garden)
+ @p2 = FactoryGirl.create(:planting, crop: maize, garden: garden)
+ @p3 = FactoryGirl.create(:planting, crop: chard, garden: garden)
+ @p4 = FactoryGirl.create(:planting, crop: apple, garden: garden)
+ @p5 = FactoryGirl.create(:planting, crop: walnut, garden: garden)
+ @p6 = FactoryGirl.create(:planting, crop: apple, garden: garden)
+ @p7 = FactoryGirl.create(:planting, crop: pear, garden: garden)
- @garden.featured_plantings.should eq [@p7, @p6, @p5, @p3]
+ garden.featured_plantings.should eq [@p7, @p6, @p5, @p3]
end
end
@@ -87,93 +85,92 @@ describe Garden do
end
it "destroys plantings when deleted" do
- @garden = FactoryGirl.create(:garden, :owner => @owner)
- @planting1 = FactoryGirl.create(:planting, :garden => @garden)
- @planting2 = FactoryGirl.create(:planting, :garden => @garden)
- @garden.plantings.length.should == 2
+ garden = FactoryGirl.create(:garden, owner: owner)
+ @planting1 = FactoryGirl.create(:planting, garden: garden)
+ @planting2 = FactoryGirl.create(:planting, garden: garden)
+ garden.plantings.size.should == 2
all = Planting.count
- @garden.destroy
+ garden.destroy
Planting.count.should == all - 2
end
context 'area' do
it 'allows numeric area' do
- @garden = FactoryGirl.build(:garden, :area => 33)
- @garden.should be_valid
+ garden = FactoryGirl.build(:garden, area: 33)
+ garden.should be_valid
end
it "doesn't allow negative area" do
- @garden = FactoryGirl.build(:garden, :area => -5)
- @garden.should_not be_valid
+ garden = FactoryGirl.build(:garden, area: -5)
+ garden.should_not be_valid
end
it 'allows decimal quantities' do
- @garden = FactoryGirl.build(:garden, :area => 3.3)
- @garden.should be_valid
+ garden = FactoryGirl.build(:garden, area: 3.3)
+ garden.should be_valid
end
it 'allows blank quantities' do
- @garden = FactoryGirl.build(:garden, :area => '')
- @garden.should be_valid
+ garden = FactoryGirl.build(:garden, area: '')
+ garden.should be_valid
end
it 'allows nil quantities' do
- @garden = FactoryGirl.build(:garden, :area => nil)
- @garden.should be_valid
+ garden = FactoryGirl.build(:garden, area: nil)
+ garden.should be_valid
end
it 'cleans up zero quantities' do
- @garden = FactoryGirl.build(:garden, :area => 0)
- @garden.area.should == 0
+ garden = FactoryGirl.build(:garden, area: 0)
+ garden.area.should == 0
end
it "doesn't allow non-numeric quantities" do
- @garden = FactoryGirl.build(:garden, :area => "99a")
- @garden.should_not be_valid
+ garden = FactoryGirl.build(:garden, area: "99a")
+ garden.should_not be_valid
end
end
context 'units' do
Garden::AREA_UNITS_VALUES.values.push(nil, '').each do |s|
it "#{s} should be a valid unit" do
- @garden = FactoryGirl.build(:garden, :area_unit => s)
- @garden.should be_valid
+ garden = FactoryGirl.build(:garden, area_unit: s)
+ garden.should be_valid
end
end
it 'should refuse invalid unit values' do
- @garden = FactoryGirl.build(:garden, :area_unit => 'not valid')
- @garden.should_not be_valid
- @garden.errors[:area_unit].should include("not valid is not a valid area unit")
+ garden = FactoryGirl.build(:garden, area_unit: 'not valid')
+ garden.should_not be_valid
+ garden.errors[:area_unit].should include("not valid is not a valid area unit")
end
it 'sets area unit to blank if area is blank' do
- @garden = FactoryGirl.build(:garden, :area => '', :area_unit => 'acre')
- @garden.should be_valid
- @garden.area_unit.should eq nil
+ garden = FactoryGirl.build(:garden, area: '', area_unit: 'acre')
+ garden.should be_valid
+ garden.area_unit.should eq nil
end
end
context 'active scopes' do
- before(:each) do
- @active = FactoryGirl.create(:garden)
- @inactive = FactoryGirl.create(:inactive_garden)
- end
+
+ let(:active) { FactoryGirl.create(:garden) }
+ let(:inactive) { FactoryGirl.create(:inactive_garden) }
it 'includes active garden in active scope' do
- Garden.active.should include @active
- Garden.active.should_not include @inactive
+ Garden.active.should include active
+ Garden.active.should_not include inactive
end
it 'includes inactive garden in inactive scope' do
- Garden.inactive.should include @inactive
- Garden.inactive.should_not include @active
+ Garden.inactive.should include inactive
+ Garden.inactive.should_not include active
end
end
it "marks plantings as finished when garden is inactive" do
garden = FactoryGirl.create(:garden)
- p1 = FactoryGirl.create(:planting, :garden => garden)
- p2 = FactoryGirl.create(:planting, :garden => garden)
+ p1 = FactoryGirl.create(:planting, garden: garden)
+ p2 = FactoryGirl.create(:planting, garden: garden)
p1.finished.should eq false
p2.finished.should eq false
@@ -190,8 +187,8 @@ describe Garden do
it "doesn't mark the wrong plantings as finished" do
g1 = FactoryGirl.create(:garden)
g2 = FactoryGirl.create(:garden)
- p1 = FactoryGirl.create(:planting, :garden => g1)
- p2 = FactoryGirl.create(:planting, :garden => g2)
+ p1 = FactoryGirl.create(:planting, garden: g1)
+ p2 = FactoryGirl.create(:planting, garden: g2)
# mark the garden as inactive
g1.active = false
@@ -207,30 +204,32 @@ describe Garden do
end
context 'photos' do
- before(:each) do
- @garden = FactoryGirl.create(:garden)
- @photo = FactoryGirl.create(:photo)
- @garden.photos << @photo
+
+ let(:garden) { FactoryGirl.create(:garden) }
+ let(:photo) { FactoryGirl.create(:photo) }
+
+ before do
+ garden.photos << photo
end
it 'has a photo' do
- @garden.photos.first.should eq @photo
+ garden.photos.first.should eq photo
end
it 'deletes association with photos when photo is deleted' do
- @photo.destroy
- @garden.reload
- @garden.photos.should be_empty
+ photo.destroy
+ garden.reload
+ garden.photos.should be_empty
end
it 'has a default photo' do
- @garden.default_photo.should eq @photo
+ garden.default_photo.should eq photo
end
it 'chooses the most recent photo' do
@photo2 = FactoryGirl.create(:photo)
- @garden.photos << @photo2
- @garden.default_photo.should eq @photo2
+ garden.photos << @photo2
+ garden.default_photo.should eq @photo2
end
end
diff --git a/spec/models/harvest_spec.rb b/spec/models/harvest_spec.rb
index cd6d5f1ef..583363aa2 100644
--- a/spec/models/harvest_spec.rb
+++ b/spec/models/harvest_spec.rb
@@ -14,32 +14,32 @@ describe Harvest do
context 'quantity' do
it 'allows numeric quantities' do
- @harvest = FactoryGirl.build(:harvest, :quantity => 33)
+ @harvest = FactoryGirl.build(:harvest, quantity: 33)
@harvest.should be_valid
end
it 'allows decimal quantities' do
- @harvest = FactoryGirl.build(:harvest, :quantity => 3.3)
+ @harvest = FactoryGirl.build(:harvest, quantity: 3.3)
@harvest.should be_valid
end
it 'allows blank quantities' do
- @harvest = FactoryGirl.build(:harvest, :quantity => '')
+ @harvest = FactoryGirl.build(:harvest, quantity: '')
@harvest.should be_valid
end
it 'allows nil quantities' do
- @harvest = FactoryGirl.build(:harvest, :quantity => nil)
+ @harvest = FactoryGirl.build(:harvest, quantity: nil)
@harvest.should be_valid
end
it 'cleans up zero quantities' do
- @harvest = FactoryGirl.build(:harvest, :quantity => 0)
+ @harvest = FactoryGirl.build(:harvest, quantity: 0)
@harvest.quantity.should == 0
end
it "doesn't allow non-numeric quantities" do
- @harvest = FactoryGirl.build(:harvest, :quantity => "99a")
+ @harvest = FactoryGirl.build(:harvest, quantity: "99a")
@harvest.should_not be_valid
end
end
@@ -47,19 +47,19 @@ describe Harvest do
context 'units' do
it 'all valid units should work' do
['individual','bunch','sprig','handful','litre','pint','quart','bucket','basket','bushel', nil, ''].each do |s|
- @harvest = FactoryGirl.build(:harvest, :unit => s)
+ @harvest = FactoryGirl.build(:harvest, unit: s)
@harvest.should be_valid
end
end
it 'should refuse invalid unit values' do
- @harvest = FactoryGirl.build(:harvest, :unit => 'not valid')
+ @harvest = FactoryGirl.build(:harvest, unit: 'not valid')
@harvest.should_not be_valid
@harvest.errors[:unit].should include("not valid is not a valid unit")
end
it 'sets unit to blank if quantity is blank' do
- @harvest = FactoryGirl.build(:harvest, :quantity => '', :unit => 'individual')
+ @harvest = FactoryGirl.build(:harvest, quantity: '', unit: 'individual')
@harvest.should be_valid
@harvest.unit.should eq nil
end
@@ -67,32 +67,32 @@ describe Harvest do
context 'weight quantity' do
it 'allows numeric weight quantities' do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => 33)
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: 33)
@harvest.should be_valid
end
it 'allows decimal weight quantities' do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => 3.3)
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: 3.3)
@harvest.should be_valid
end
it 'allows blank weight quantities' do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => '')
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: '')
@harvest.should be_valid
end
it 'allows nil weight quantities' do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => nil)
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: nil)
@harvest.should be_valid
end
it 'cleans up zero quantities' do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => 0)
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: 0)
@harvest.weight_quantity.should == 0
end
it "doesn't allow non-numeric weight quantities" do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => "99a")
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: "99a")
@harvest.should_not be_valid
end
end
@@ -100,19 +100,19 @@ describe Harvest do
context 'weight units' do
it 'all valid units should work' do
['kg', 'lb', 'oz', nil, ''].each do |s|
- @harvest = FactoryGirl.build(:harvest, :weight_unit => s)
+ @harvest = FactoryGirl.build(:harvest, weight_unit: s)
@harvest.should be_valid
end
end
it 'should refuse invalid weight unit values' do
- @harvest = FactoryGirl.build(:harvest, :weight_unit => 'not valid')
+ @harvest = FactoryGirl.build(:harvest, weight_unit: 'not valid')
@harvest.should_not be_valid
@harvest.errors[:weight_unit].should include("not valid is not a valid unit")
end
it 'sets weight_unit to blank if quantity is blank' do
- @harvest = FactoryGirl.build(:harvest, :weight_quantity => '', :weight_unit => 'kg')
+ @harvest = FactoryGirl.build(:harvest, weight_quantity: '', weight_unit: 'kg')
@harvest.should be_valid
@harvest.weight_unit.should eq nil
end
@@ -120,19 +120,19 @@ describe Harvest do
context "standardized weights" do
it 'converts from pounds' do
- @harvest = FactoryGirl.create(:harvest, :weight_quantity => 2, :weight_unit => "lb")
+ @harvest = FactoryGirl.create(:harvest, weight_quantity: 2, weight_unit: "lb")
@harvest.should be_valid
@harvest.reload.si_weight.should eq 0.907
end
it 'converts from ounces' do
- @harvest = FactoryGirl.create(:harvest, :weight_quantity => 16, :weight_unit => "oz")
+ @harvest = FactoryGirl.create(:harvest, weight_quantity: 16, weight_unit: "oz")
@harvest.should be_valid
@harvest.reload.si_weight.should eq 0.454
end
it 'leaves kg alone' do
- @harvest = FactoryGirl.create(:harvest, :weight_quantity => 2, :weight_unit => "kg")
+ @harvest = FactoryGirl.create(:harvest, weight_quantity: 2, weight_unit: "kg")
@harvest.should be_valid
@harvest.reload.si_weight.should eq 2.0
end
@@ -140,123 +140,124 @@ describe Harvest do
context 'ordering' do
it 'lists most recent harvests first' do
- @h1 = FactoryGirl.create(:harvest, :created_at => 1.day.ago)
- @h2 = FactoryGirl.create(:harvest, :created_at => 1.hour.ago)
+ @h1 = FactoryGirl.create(:harvest, created_at: 1.day.ago)
+ @h2 = FactoryGirl.create(:harvest, created_at: 1.hour.ago)
Harvest.all.should eq [@h2, @h1]
end
end
context "stringification" do
- before :each do
- @crop = FactoryGirl.create(:crop, :name => "apricot")
- end
+
+ let(:crop) { FactoryGirl.create(:crop, name: "apricot") }
it "apricots" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => nil,
- :unit => nil,
- :weight_quantity => nil,
- :weight_unit => nil
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: nil,
+ unit: nil,
+ weight_quantity: nil,
+ weight_unit: nil
)
@h.to_s.should eq "apricots"
end
it "1 individual apricot" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => 1,
- :unit => 'individual',
- :weight_quantity => nil,
- :weight_unit => nil
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: 1,
+ unit: 'individual',
+ weight_quantity: nil,
+ weight_unit: nil
)
@h.to_s.should eq "1 individual apricot"
end
it "10 individual apricots" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => 10,
- :unit => 'individual',
- :weight_quantity => nil,
- :weight_unit => nil
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: 10,
+ unit: 'individual',
+ weight_quantity: nil,
+ weight_unit: nil
)
@h.to_s.should eq "10 individual apricots"
end
it "1 bushel of apricots" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => 1,
- :unit => 'bushel',
- :weight_quantity => nil,
- :weight_unit => nil
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: 1,
+ unit: 'bushel',
+ weight_quantity: nil,
+ weight_unit: nil
)
@h.to_s.should eq "1 bushel of apricots"
end
it "1.5 bushels of apricots" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => 1.5,
- :unit => 'bushel',
- :weight_quantity => nil,
- :weight_unit => nil
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: 1.5,
+ unit: 'bushel',
+ weight_quantity: nil,
+ weight_unit: nil
)
@h.to_s.should eq "1.5 bushels of apricots"
end
it "10 bushels of apricots" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => 10,
- :unit => 'bushel',
- :weight_quantity => nil,
- :weight_unit => nil
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: 10,
+ unit: 'bushel',
+ weight_quantity: nil,
+ weight_unit: nil
)
@h.to_s.should eq "10 bushels of apricots"
end
it "apricots weighing 1.2 kg" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => nil,
- :unit => nil,
- :weight_quantity => 1.2,
- :weight_unit => 'kg'
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: nil,
+ unit: nil,
+ weight_quantity: 1.2,
+ weight_unit: 'kg'
)
@h.to_s.should eq "apricots weighing 1.2 kg"
end
it "10 bushels of apricots weighing 100 kg" do
- @h = FactoryGirl.create(:harvest, :crop => @crop,
- :quantity => 10,
- :unit => 'bushel',
- :weight_quantity => 100,
- :weight_unit => 'kg')
+ @h = FactoryGirl.create(:harvest, crop: crop,
+ quantity: 10,
+ unit: 'bushel',
+ weight_quantity: 100,
+ weight_unit: 'kg')
@h.to_s.should eq "10 bushels of apricots weighing 100 kg"
end
end
context 'photos' do
- before(:each) do
- @harvest = FactoryGirl.create(:harvest)
- @photo = FactoryGirl.create(:photo)
- @harvest.photos << @photo
+
+ let(:harvest) { FactoryGirl.create(:harvest) }
+ let(:photo) { FactoryGirl.create(:photo) }
+
+ before do
+ harvest.photos << photo
end
it 'has a photo' do
- @harvest.photos.first.should eq @photo
+ harvest.photos.first.should eq photo
end
it 'deletes association with photos when photo is deleted' do
- @photo.destroy
- @harvest.reload
- @harvest.photos.should be_empty
+ photo.destroy
+ harvest.reload
+ harvest.photos.should be_empty
end
it 'has a default photo' do
- @harvest.default_photo.should eq @photo
+ harvest.default_photo.should eq photo
end
it 'chooses the most recent photo' do
@photo2 = FactoryGirl.create(:photo)
- @harvest.photos << @photo2
- @harvest.default_photo.should eq @photo2
+ harvest.photos << @photo2
+ harvest.default_photo.should eq @photo2
end
end
end
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 01e5ae4f8..409860463 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -3,72 +3,71 @@ require 'rails_helper'
describe 'member' do
context 'valid member' do
- before(:each) do
- @member = FactoryGirl.create(:member)
- end
+
+ let(:member) { FactoryGirl.create(:member) }
it 'should be fetchable from the database' do
- @member2 = Member.find(@member.id)
+ @member2 = Member.find(member.id)
@member2.should be_an_instance_of Member
@member2.login_name.should match(/member\d+/)
@member2.encrypted_password.should_not be_nil
end
it 'should have a friendly slug' do
- @member.slug.should match(/member\d+/)
+ member.slug.should match(/member\d+/)
end
it 'has a bio' do
- @member.bio = 'I love seeds'
- @member.bio.should eq 'I love seeds'
+ member.bio = 'I love seeds'
+ member.bio.should eq 'I love seeds'
end
it 'should have a default garden' do
- @member.gardens.count.should == 1
+ member.gardens.size.should == 1
end
it 'should have a accounts entry' do
- @member.account.should be_an_instance_of Account
+ member.account.should be_an_instance_of Account
end
it "should have a default-type account by default" do
- @member.account.account_type.name.should eq Growstuff::Application.config.default_account_type
- @member.is_paid?.should be(false)
+ member.account.account_type.name.should eq Growstuff::Application.config.default_account_type
+ member.is_paid?.should be(false)
end
it "doesn't show email by default" do
- @member.show_email.should be(false)
+ member.show_email.should be(false)
end
it 'should stringify as the login_name' do
- @member.to_s.should match(/member\d+/)
- "#{@member}".should match(/member\d+/)
+ member.to_s.should match(/member\d+/)
+ "#{member}".should match(/member\d+/)
end
it 'should be able to fetch posts' do
- @post = FactoryGirl.create(:post, :author => @member)
- @member.posts.should eq [@post]
+ @post = FactoryGirl.create(:post, author: member)
+ member.posts.should eq [@post]
end
it 'should be able to fetch gardens' do
- @member.gardens.first.name.should eq "Garden"
+ member.gardens.first.name.should eq "Garden"
end
it 'has many plantings' do
- @planting = FactoryGirl.create(:planting, :owner => @member)
- @member.plantings.size.should eq 1
+ @planting = FactoryGirl.create(:planting, owner: member)
+ member.plantings.size.should eq 1
end
it "has many comments" do
- @comment1 = FactoryGirl.create(:comment, :author => @member)
- @comment2 = FactoryGirl.create(:comment, :author => @member)
- @member.comments.length.should == 2
+ @comment1 = FactoryGirl.create(:comment, author: member)
+ @comment2 = FactoryGirl.create(:comment, author: member)
+ member.comments.size.should == 2
end
it "has many forums" do
- @forum1 = FactoryGirl.create(:forum, :owner => @member)
- @forum2 = FactoryGirl.create(:forum, :owner => @member)
- @member.forums.length.should == 2
+ @forum1 = FactoryGirl.create(:forum, owner: member)
+ @forum2 = FactoryGirl.create(:forum, owner: member)
+ member.forums.size.should == 2
end
it "has many likes" do
@@ -80,36 +79,35 @@ describe 'member' do
end
it 'has location and lat/long fields' do
- @member.update_attributes(:location => 'Greenwich, UK')
- @member.location.should eq 'Greenwich, UK'
- @member.latitude.round(2).should eq 51.48
- @member.longitude.round(2).should eq 0.00
+ member.update_attributes(location: 'Greenwich, UK')
+ member.location.should eq 'Greenwich, UK'
+ member.latitude.round(2).should eq 51.48
+ member.longitude.round(2).should eq 0.00
end
it 'empties the lat/long if location removed' do
- @member.update_attributes(:location => 'Greenwich, UK')
- @member.update_attributes(:location => '')
- @member.location.should eq ''
- @member.latitude.should be_nil
- @member.longitude.should be_nil
+ member.update_attributes(location: 'Greenwich, UK')
+ member.update_attributes(location: '')
+ member.location.should eq ''
+ member.latitude.should be_nil
+ member.longitude.should be_nil
end
it 'fails gracefully for unfound locations' do
- @member.update_attributes(:location => 'Tatooine')
- @member.location.should eq 'Tatooine'
- @member.latitude.should be_nil
- @member.longitude.should be_nil
+ member.update_attributes(location: 'Tatooine')
+ member.location.should eq 'Tatooine'
+ member.latitude.should be_nil
+ member.longitude.should be_nil
end
end
context 'no TOS agreement' do
- before(:each) do
- @member = FactoryGirl.build(:no_tos_member)
- end
+
+ let(:member) { FactoryGirl.build(:no_tos_member) }
it "should refuse to save a member who hasn't agreed to the TOS" do
- @member.save.should_not be(true)
+ member.save.should_not be(true)
end
end
@@ -124,15 +122,15 @@ describe 'member' do
context 'same :login_name' do
it "should not allow two members with the same login_name" do
- FactoryGirl.create(:member, :login_name => "bob")
- member = FactoryGirl.build(:member, :login_name => "bob")
+ FactoryGirl.create(:member, login_name: "bob")
+ member = FactoryGirl.build(:member, login_name: "bob")
member.should_not be_valid
member.errors[:login_name].should include("has already been taken")
end
it "tests uniqueness case-insensitively" do
- FactoryGirl.create(:member, :login_name => "bob")
- member = FactoryGirl.build(:member, :login_name => "BoB")
+ FactoryGirl.create(:member, login_name: "bob")
+ member = FactoryGirl.build(:member, login_name: "BoB")
member.should_not be_valid
member.errors[:login_name].should include("has already been taken")
end
@@ -140,7 +138,7 @@ describe 'member' do
context 'case sensitivity' do
it 'preserves case of login name' do
- member = FactoryGirl.create(:member, :login_name => "BOB")
+ member = FactoryGirl.create(:member, login_name: "BOB")
check = Member.find('bob')
check.login_name.should eq 'BOB'
end
@@ -148,8 +146,8 @@ describe 'member' do
context 'ordering' do
it "should be sorted by name" do
- z = FactoryGirl.create(:member, :login_name => "Zoe")
- a = FactoryGirl.create(:member, :login_name => "Anna")
+ z = FactoryGirl.create(:member, login_name: "Zoe")
+ a = FactoryGirl.create(:member, login_name: "Anna")
Member.first.should == a
end
end
@@ -198,15 +196,17 @@ describe 'member' do
end
context 'roles' do
- before(:each) do
- @member = FactoryGirl.create(:member)
- @role = FactoryGirl.create(:role)
- @member.roles << @role
+
+ let(:member) { FactoryGirl.create(:member) }
+ let(:role) { FactoryGirl.create(:role) }
+
+ before do
+ member.roles << role
end
it 'has a role' do
- @member.roles.first.should eq @role
- @member.has_role?(:moderator).should eq true
+ member.roles.first.should eq role
+ member.has_role?(:moderator).should eq true
end
it 'sets up roles in factories' do
@@ -216,9 +216,9 @@ describe 'member' do
it 'converts role names properly' do
# need to make sure spaces get turned to underscores
- @role = FactoryGirl.create(:role, :name => "a b c")
- @member.roles << @role
- @member.has_role?(:a_b_c).should eq true
+ @role = FactoryGirl.create(:role, name: "a b c")
+ member.roles << @role
+ member.has_role?(:a_b_c).should eq true
end
end
@@ -229,12 +229,12 @@ describe 'member' do
end
it 'sees confirmed members' do
- Member.confirmed.count.should == 2
+ Member.confirmed.size.should == 2
end
it 'ignores unconfirmed members' do
@member3 = FactoryGirl.create(:unconfirmed_member)
- Member.confirmed.count.should == 2
+ Member.confirmed.size.should == 2
end
end
@@ -254,7 +254,7 @@ describe 'member' do
@london_member = FactoryGirl.create(:london_member)
@london_member.latitude = nil
@london_member.longitude = nil
- @london_member.save(:validate => false)
+ @london_member.save(validate: false)
Member.located.should_not include @london_member
end
end
@@ -281,7 +281,7 @@ describe 'member' do
@member4 = FactoryGirl.create(:unconfirmed_member)
[@member1, @member2, @member3, @member4].each do |m|
- FactoryGirl.create(:planting, :owner => m)
+ FactoryGirl.create(:planting, owner: m)
end
@member1.updated_at = 3.days.ago
@@ -297,123 +297,124 @@ describe 'member' do
context 'orders' do
it 'finds the current order' do
@member = FactoryGirl.create(:member)
- @order1 = FactoryGirl.create(:completed_order, :member => @member)
- @order2 = FactoryGirl.create(:order, :member => @member)
+ @order1 = FactoryGirl.create(:completed_order, member: @member)
+ @order2 = FactoryGirl.create(:order, member: @member)
@member.current_order.should eq @order2
end
it "copes if there's no current order" do
@member = FactoryGirl.create(:member)
- @order1 = FactoryGirl.create(:completed_order, :member => @member)
- @order2 = FactoryGirl.create(:completed_order, :member => @member)
+ @order1 = FactoryGirl.create(:completed_order, member: @member)
+ @order2 = FactoryGirl.create(:completed_order, member: @member)
@member.current_order.should be_nil
end
end
context "paid accounts" do
- before(:each) do
- @member = FactoryGirl.create(:member)
- end
+
+ let(:member) { FactoryGirl.create(:member) }
it "recognises a permanent paid account" do
@account_type = FactoryGirl.create(:account_type,
- :is_paid => true, :is_permanent_paid => true)
- @member.account.account_type = @account_type
- @member.is_paid?.should be(true)
+ is_paid: true, is_permanent_paid: true)
+ member.account.account_type = @account_type
+ member.is_paid?.should be(true)
end
it "recognises a current paid account" do
@account_type = FactoryGirl.create(:account_type,
- :is_paid => true, :is_permanent_paid => false)
- @member.account.account_type = @account_type
- @member.account.paid_until = Time.zone.now + 1.month
- @member.is_paid?.should be(true)
+ is_paid: true, is_permanent_paid: false)
+ member.account.account_type = @account_type
+ member.account.paid_until = Time.zone.now + 1.month
+ member.is_paid?.should be(true)
end
it "recognises an expired paid account" do
@account_type = FactoryGirl.create(:account_type,
- :is_paid => true, :is_permanent_paid => false)
- @member.account.account_type = @account_type
- @member.account.paid_until = Time.zone.now - 1.minute
- @member.is_paid?.should be(false)
+ is_paid: true, is_permanent_paid: false)
+ member.account.account_type = @account_type
+ member.account.paid_until = Time.zone.now - 1.minute
+ member.is_paid?.should be(false)
end
it "recognises a free account" do
@account_type = FactoryGirl.create(:account_type,
- :is_paid => false, :is_permanent_paid => false)
- @member.account.account_type = @account_type
- @member.is_paid?.should be(false)
+ is_paid: false, is_permanent_paid: false)
+ member.account.account_type = @account_type
+ member.is_paid?.should be(false)
end
it "recognises a free account even with paid_until set" do
@account_type = FactoryGirl.create(:account_type,
- :is_paid => false, :is_permanent_paid => false)
- @member.account.account_type = @account_type
- @member.account.paid_until = Time.zone.now + 1.month
- @member.is_paid?.should be(false)
+ is_paid: false, is_permanent_paid: false)
+ member.account.account_type = @account_type
+ member.account.paid_until = Time.zone.now + 1.month
+ member.is_paid?.should be(false)
end
end
context "update account" do
- before(:each) do
- @product = FactoryGirl.create(:product,
- :paid_months => 3
- )
- @member = FactoryGirl.create(:member)
- end
+
+ let(:product) { FactoryGirl.create(:product,
+ paid_months: 3
+ )}
+ let(:member) { FactoryGirl.create(:member) }
it "sets account_type" do
- @member.update_account_after_purchase(@product)
- @member.account.account_type.should eq @product.account_type
+ member.update_account_after_purchase(product)
+ member.account.account_type.should eq product.account_type
end
it "sets paid_until" do
- @member.account.paid_until = nil # blank for now, as if never paid before
- @member.update_account_after_purchase(@product)
+ member.account.paid_until = nil # blank for now, as if never paid before
+ member.update_account_after_purchase(product)
# stringify to avoid millisecond problems...
- @member.account.paid_until.to_s.should eq (Time.zone.now + 3.months).to_s
+ member.account.paid_until.to_s.should eq (Time.zone.now + 3.months).to_s
# and again to make sure it works for currently paid accounts
- @member.update_account_after_purchase(@product)
- @member.account.paid_until.to_s.should eq (Time.zone.now + 3.months + 3.months).to_s
+ member.update_account_after_purchase(product)
+ member.account.paid_until.to_s.should eq (Time.zone.now + 3.months + 3.months).to_s
end
end
context 'harvests' do
it 'has harvests' do
member = FactoryGirl.create(:member)
- harvest = FactoryGirl.create(:harvest, :owner => member)
+ harvest = FactoryGirl.create(:harvest, owner: member)
member.harvests.should eq [harvest]
end
end
context 'member who followed another member' do
- before(:each) do
- @member1 = FactoryGirl.create(:member)
- @member2 = FactoryGirl.create(:member)
- @member3 = FactoryGirl.create(:member)
- @follow = @member1.follows.create(:follower_id => @member1.id, :followed_id => @member2.id)
+
+
+ let(:member1) { FactoryGirl.create(:member) }
+ let(:member2) { FactoryGirl.create(:member) }
+ let(:member3) { FactoryGirl.create(:member) }
+
+ before do
+ @follow = member1.follows.create(follower_id: member1.id, followed_id: member2.id)
end
context 'already_following' do
it 'detects that member is already following a member' do
- expect(@member1.already_following?(@member2)).to eq true
+ expect(member1.already_following?(member2)).to eq true
end
it 'detects that member is not already following a member' do
- expect(@member1.already_following?(@member3)).to eq false
+ expect(member1.already_following?(member3)).to eq false
end
end
context 'get_follow' do
it 'gets the correct follow for a followed member' do
- expect(@member1.get_follow(@member2).id).to eq @follow.id
+ expect(member1.get_follow(member2).id).to eq @follow.id
end
it 'returns nil for a member that is not followed' do
- expect(@member1.get_follow(@member3)).to be_nil
+ expect(member1.get_follow(member3)).to be_nil
end
end
diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb
index 27924ebed..e38444d5d 100644
--- a/spec/models/notification_spec.rb
+++ b/spec/models/notification_spec.rb
@@ -1,33 +1,32 @@
require 'rails_helper'
describe Notification do
- before(:each) do
- @notification = FactoryGirl.create(:notification)
- end
+
+ let(:notification) { FactoryGirl.create(:notification) }
it "belongs to a post" do
- @notification.post.should be_an_instance_of Post
+ notification.post.should be_an_instance_of Post
end
it "belongs to a recipient" do
- @notification.recipient.should be_an_instance_of Member
+ notification.recipient.should be_an_instance_of Member
end
it "belongs to a sender" do
- @notification.sender.should be_an_instance_of Member
+ notification.sender.should be_an_instance_of Member
end
it "has a scope for unread" do
- Notification.unread.should eq [@notification]
- @n2 = FactoryGirl.create(:notification, :read => true)
- Notification.unread.should eq [@notification]
- @n3 = FactoryGirl.create(:notification, :read => false)
- Notification.unread.should eq [@n3, @notification]
+ Notification.unread.should eq [notification]
+ @n2 = FactoryGirl.create(:notification, read: true)
+ Notification.unread.should eq [notification]
+ @n3 = FactoryGirl.create(:notification, read: false)
+ Notification.unread.should eq [@n3, notification]
end
it "counts unread" do
- @who = @notification.recipient
- @n2 = FactoryGirl.create(:notification, :recipient => @who, :read => false)
+ @who = notification.recipient
+ @n2 = FactoryGirl.create(:notification, recipient: @who, read: false)
@who.notifications.unread_count.should eq 2
end
@@ -38,9 +37,9 @@ describe Notification do
end
it "doesn't send email to people who don't want it" do
- @notification = FactoryGirl.create(:no_email_notification)
- @notification.send_email
- ActionMailer::Base.deliveries.last.to.should_not == [@notification.recipient.email]
+ notification = FactoryGirl.create(:no_email_notification)
+ notification.send_email
+ ActionMailer::Base.deliveries.last.to.should_not == [notification.recipient.email]
end
it "sends email on creation" do
@@ -49,13 +48,13 @@ describe Notification do
end
it "replaces missing subjects with (no subject)" do
- @notification = FactoryGirl.create(:notification, :subject => nil)
- @notification.subject.should == "(no subject)"
+ notification = FactoryGirl.create(:notification, subject: nil)
+ notification.subject.should == "(no subject)"
end
it "replaces whitespace-only subjects with (no subject)" do
- @notification = FactoryGirl.create(:notification, :subject => " ")
- @notification.subject.should == "(no subject)"
+ notification = FactoryGirl.create(:notification, subject: " ")
+ notification.subject.should == "(no subject)"
end
end
diff --git a/spec/models/order_item_spec.rb b/spec/models/order_item_spec.rb
index 20c0be94f..67f86415c 100644
--- a/spec/models/order_item_spec.rb
+++ b/spec/models/order_item_spec.rb
@@ -1,28 +1,27 @@
require 'rails_helper'
describe OrderItem do
- before(:each) do
- @order_item = FactoryGirl.create(:order_item)
- end
+
+ let(:order_item) { FactoryGirl.create(:order_item) }
it "has an order and a product" do
- @order_item.order.should be_an_instance_of Order
- @order_item.product.should be_an_instance_of Product
+ order_item.order.should be_an_instance_of Order
+ order_item.product.should be_an_instance_of Product
end
it "validates price > product.min_price" do
@product = FactoryGirl.create(:product)
- @order_item = FactoryGirl.build(:order_item, :price => @product.min_price - 1)
- @order_item.should_not be_valid
+ order_item = FactoryGirl.build(:order_item, price: @product.min_price - 1)
+ order_item.should_not be_valid
end
it "doesn't let you add two items to an order" do
@product = FactoryGirl.create(:product)
@order = FactoryGirl.create(:order)
- @order_item = FactoryGirl.build(:order_item, :order => @order)
- @order_item.should be_valid
- @order_item.save
- @order_item2 = FactoryGirl.build(:order_item, :order => @order)
+ order_item = FactoryGirl.build(:order_item, order: @order)
+ order_item.should be_valid
+ order_item.save
+ @order_item2 = FactoryGirl.build(:order_item, order: @order)
@order_item2.should_not be_valid
end
diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb
index 50fb6f949..9291e1a3f 100644
--- a/spec/models/order_spec.rb
+++ b/spec/models/order_spec.rb
@@ -5,7 +5,7 @@ describe Order do
@order = FactoryGirl.create(:order)
@product = FactoryGirl.create(:product)
@order_item = FactoryGirl.create(:order_item,
- :order_id => @order.id, :product_id => @product.id)
+ order_id: @order.id, product_id: @product.id)
end
it 'has order_items' do
@@ -19,14 +19,14 @@ describe Order do
it 'updates the account details' do
@member = FactoryGirl.create(:member)
- @order = FactoryGirl.create(:order, :member => @member)
- @account_type = FactoryGirl.create(:account_type, :name => 'paid')
+ @order = FactoryGirl.create(:order, member: @member)
+ @account_type = FactoryGirl.create(:account_type, name: 'paid')
@product = FactoryGirl.create(:product,
- :account_type => @account_type,
- :paid_months => 3
+ account_type: @account_type,
+ paid_months: 3
)
@order_item = FactoryGirl.create(:order_item,
- :order_id => @order.id, :product_id => @product.id)
+ order_id: @order.id, product_id: @product.id)
@member.account.paid_until.should be_nil
@@ -38,48 +38,48 @@ describe Order do
it "totals the amount due" do
@member = FactoryGirl.create(:member)
- @order = FactoryGirl.create(:order, :member => @member)
+ @order = FactoryGirl.create(:order, member: @member)
@product = FactoryGirl.create(:product,
- :min_price => 1000
+ min_price: 1000
)
# we force an order to only have one item at present. Add more if wanted
# later.
@order_item1 = FactoryGirl.create(:order_item,
- :order_id => @order.id, :product_id => @product.id, :price => 1111, :quantity => 1)
+ order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1)
@order.total.should eq 1111
end
it "gives the correct total for quantities more than 1" do
@member = FactoryGirl.create(:member)
- @order = FactoryGirl.create(:order, :member => @member)
+ @order = FactoryGirl.create(:order, member: @member)
@product = FactoryGirl.create(:product,
- :min_price => 1000
+ min_price: 1000
)
# we force an order to only have one item at present. Add more if wanted
# later.
@order_item1 = FactoryGirl.create(:order_item,
- :order_id => @order.id, :product_id => @product.id, :price => 1111, :quantity => 2)
+ order_id: @order.id, product_id: @product.id, price: 1111, quantity: 2)
@order.total.should eq 2222
end
it "formats order items for activemerchant" do
@member = FactoryGirl.create(:member)
- @order = FactoryGirl.create(:order, :member => @member)
+ @order = FactoryGirl.create(:order, member: @member)
@product = FactoryGirl.create(:product,
- :name => 'foo',
- :min_price => 1000
+ name: 'foo',
+ min_price: 1000
)
# we force an order to only have one item at present. Add more if wanted
# later.
@order_item1 = FactoryGirl.create(:order_item,
- :order_id => @order.id, :product_id => @product.id, :price => 1111, :quantity => 1)
+ order_id: @order.id, product_id: @product.id, price: 1111, quantity: 1)
@order.activemerchant_items.should eq [{
- :name => 'foo',
- :quantity => 1,
- :amount => 1111
+ name: 'foo',
+ quantity: 1,
+ amount: 1111
}]
end
@@ -91,12 +91,12 @@ describe Order do
end
it "validates referral codes" do
- referred_order = FactoryGirl.build(:order, :referral_code => 'CAMP_AIGN1?')
+ referred_order = FactoryGirl.build(:order, referral_code: 'CAMP_AIGN1?')
referred_order.should_not be_valid
end
it "cleans up messy referral codes" do
- referred_order = FactoryGirl.create(:order, :referral_code => 'CaMpAiGn 1 ')
+ referred_order = FactoryGirl.create(:order, referral_code: 'CaMpAiGn 1 ')
referred_order.referral_code.should eq 'CAMPAIGN1'
end
end
@@ -104,27 +104,27 @@ describe Order do
context 'search' do
it 'finds orders by member' do
order = FactoryGirl.create(:order)
- Order.search(:by => 'member', :for => order.member.login_name).should eq [order]
+ Order.search(by: 'member', for: order.member.login_name).should eq [order]
end
it 'finds orders by order_id' do
order = FactoryGirl.create(:order)
- Order.search(:by => 'order_id', :for => order.id).should eq [order]
+ Order.search(by: 'order_id', for: order.id).should eq [order]
end
it 'finds orders by paypal_token' do
- order = FactoryGirl.create(:order, :paypal_express_token => 'foo')
- Order.search(:by => 'paypal_token', :for => 'foo').should eq [order]
+ order = FactoryGirl.create(:order, paypal_express_token: 'foo')
+ Order.search(by: 'paypal_token', for: 'foo').should eq [order]
end
it 'finds orders by paypal_payer_id' do
- order = FactoryGirl.create(:order, :paypal_express_payer_id => 'bar')
- Order.search(:by => 'paypal_payer_id', :for => 'bar').should eq [order]
+ order = FactoryGirl.create(:order, paypal_express_payer_id: 'bar')
+ Order.search(by: 'paypal_payer_id', for: 'bar').should eq [order]
end
it 'finds orders by referral_code' do
- order = FactoryGirl.create(:order, :referral_code => 'baz')
- Order.search(:by => 'referral_code', :for => 'baz').should eq [order]
+ order = FactoryGirl.create(:order, referral_code: 'baz')
+ Order.search(by: 'referral_code', for: 'baz').should eq [order]
end
end
diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb
index 650f0f57c..bd6335be2 100644
--- a/spec/models/photo_spec.rb
+++ b/spec/models/photo_spec.rb
@@ -11,19 +11,19 @@ describe Photo do
context "adds photos" do
it 'to a planting' do
planting.photos << photo
- expect(planting.photos.count).to eq 1
+ expect(planting.photos.size).to eq 1
expect(planting.photos.first).to eq photo
end
it 'to a harvest' do
harvest.photos << photo
- expect(harvest.photos.count).to eq 1
+ expect(harvest.photos.size).to eq 1
expect(harvest.photos.first).to eq photo
end
it 'to a garden' do
garden.photos << photo
- expect(garden.photos.count).to eq 1
+ expect(garden.photos.size).to eq 1
expect(garden.photos.first).to eq photo
end
end
@@ -32,19 +32,19 @@ describe Photo do
it 'from a planting' do
planting.photos << photo
photo.destroy
- expect(planting.photos.count).to eq 0
+ expect(planting.photos.size).to eq 0
end
it 'from a harvest' do
harvest.photos << photo
photo.destroy
- expect(harvest.photos.count).to eq 0
+ expect(harvest.photos.size).to eq 0
end
it 'from a garden' do
garden.photos << photo
photo.destroy
- expect(garden.photos.count).to eq 0
+ expect(garden.photos.size).to eq 0
end
it "automatically if unused" do
@@ -115,7 +115,7 @@ describe Photo do
# which was epistemologically unsatisfactory.
# So we're just going to test that the method exists.
it 'exists' do
- photo = Photo.new(:owner_id => 1)
+ photo = Photo.new(owner_id: 1)
photo.should.respond_to? :flickr_metadata
end
end
diff --git a/spec/models/plant_part_spec.rb b/spec/models/plant_part_spec.rb
index f8dc1f290..ef3705ef2 100644
--- a/spec/models/plant_part_spec.rb
+++ b/spec/models/plant_part_spec.rb
@@ -11,27 +11,27 @@ describe PlantPart do
@tomato = FactoryGirl.create(:tomato)
@pp1 = FactoryGirl.create(:plant_part)
@h1 = FactoryGirl.create(:harvest,
- :crop => @tomato,
- :plant_part => @pp1
+ crop: @tomato,
+ plant_part: @pp1
)
@h2 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp1
+ crop: @maize,
+ plant_part: @pp1
)
@pp1.crops.should include @tomato
@pp1.crops.should include @maize
end
- it "doesn't dupliate crops" do
+ it "doesn't duplicate crops" do
@maize = FactoryGirl.create(:maize)
@pp1 = FactoryGirl.create(:plant_part)
@h1 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp1
+ crop: @maize,
+ plant_part: @pp1
)
@h2 = FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp1
+ crop: @maize,
+ plant_part: @pp1
)
@pp1.crops.should eq [@maize]
end
diff --git a/spec/models/planting_spec.rb b/spec/models/planting_spec.rb
index fba4fabe1..3663f8c29 100644
--- a/spec/models/planting_spec.rb
+++ b/spec/models/planting_spec.rb
@@ -2,26 +2,24 @@ require 'rails_helper'
describe Planting do
- before(:each) do
- @crop = FactoryGirl.create(:tomato)
- @garden_owner = FactoryGirl.create(:member)
- @garden = FactoryGirl.create(:garden, :owner => @garden_owner)
- @planting = FactoryGirl.create(:planting,
- :crop => @crop, :garden => @garden)
- end
+ let(:crop) { FactoryGirl.create(:tomato) }
+ let(:garden_owner) { FactoryGirl.create(:member) }
+ let(:garden) { FactoryGirl.create(:garden, owner: garden_owner) }
+ let(:planting) { FactoryGirl.create(:planting,
+ crop: crop, garden: garden)}
it 'has an owner' do
- @planting.owner.should be_an_instance_of Member
+ planting.owner.should be_an_instance_of Member
end
it "owner isn't necessarily the garden owner" do
# a new owner should be created automatically by FactoryGirl
# note that formerly, the planting belonged to an owner through the garden
- @planting.owner.should_not eq @garden_owner
+ planting.owner.should_not eq garden_owner
end
it "generates a location" do
- @planting.location.should eq "#{@garden_owner.login_name}'s #{@garden.name}"
+ planting.location.should eq "#{garden_owner.login_name}'s #{garden.name}"
end
it "sorts plantings in descending order of creation" do
@@ -31,7 +29,7 @@ describe Planting do
end
it "should have a slug" do
- @planting.slug.should match /^member\d+-springfield-community-garden-tomato$/
+ planting.slug.should match /^member\d+-springfield-community-garden-tomato$/
end
it 'should sort in reverse creation order' do
@@ -39,63 +37,108 @@ describe Planting do
Planting.first.should eq @planting2
end
+ describe '#planted?' do
+ it "should be false for future plantings"
+ it "should be false for never planted"
+ it "should be false for future plantings"
+ end
+
+ describe '#percentage_grown' do
+ it 'should not be more than 100%' do
+ @planting = FactoryGirl.build(:planting, days_before_maturity: 1, planted_at: 1.day.ago)
+
+ now_later_than_planting = 2.days.from_now
+
+ @planting.percentage_grown(now_later_than_planting).should be 100
+ end
+
+ it 'should not be less than 0%' do
+ @planting = FactoryGirl.build(:planting, days_before_maturity: 1, planted_at: 1.day.ago)
+
+ now_earlier_than_planting = 2.days.ago
+
+ @planting.percentage_grown(now_earlier_than_planting).should be nil
+ end
+
+ it 'should reflect the current growth' do
+ @planting = FactoryGirl.build(:planting, days_before_maturity: 10, planted_at: 4.days.ago)
+
+ expect(@planting.percentage_grown(Date.current)).to eq 40
+ end
+
+ it 'should not be calculated for unplanted plantings' do
+ @planting = FactoryGirl.build(:planting, planted_at: nil)
+
+ @planting.planted?.should be false
+ @planting.percentage_grown.should be nil
+ end
+
+ it 'should not be calculated for plantings with an unknown days before maturity' do
+ @planting = FactoryGirl.build(:planting, days_before_maturity: nil)
+
+ @planting.percentage_grown.should be nil
+ end
+ end
+
context 'delegation' do
it 'system name' do
- @planting.crop_name.should eq @planting.crop.name
+ planting.crop_name.should eq planting.crop.name
end
+
it 'wikipedia url' do
- @planting.crop_en_wikipedia_url.should eq @planting.crop.en_wikipedia_url
+ planting.crop_en_wikipedia_url.should eq planting.crop.en_wikipedia_url
end
+
it 'default scientific name' do
- @planting.crop_default_scientific_name.should eq @planting.crop.default_scientific_name
+ planting.crop_default_scientific_name.should eq planting.crop.default_scientific_name
end
+
it 'plantings count' do
- @planting.crop_plantings_count.should eq @planting.crop.plantings_count
+ planting.crop_plantings_count.should eq planting.crop.plantings_count
end
end
context 'quantity' do
it 'allows integer quantities' do
- @planting = FactoryGirl.build(:planting, :quantity => 99)
+ @planting = FactoryGirl.build(:planting, quantity: 99)
@planting.should be_valid
end
it "doesn't allow decimal quantities" do
- @planting = FactoryGirl.build(:planting, :quantity => 99.9)
+ @planting = FactoryGirl.build(:planting, quantity: 99.9)
@planting.should_not be_valid
end
it "doesn't allow non-numeric quantities" do
- @planting = FactoryGirl.build(:planting, :quantity => 'foo')
+ @planting = FactoryGirl.build(:planting, quantity: 'foo')
@planting.should_not be_valid
end
it "allows blank quantities" do
- @planting = FactoryGirl.build(:planting, :quantity => nil)
+ @planting = FactoryGirl.build(:planting, quantity: nil)
@planting.should be_valid
- @planting = FactoryGirl.build(:planting, :quantity => '')
+ @planting = FactoryGirl.build(:planting, quantity: '')
@planting.should be_valid
end
end
context 'sunniness' do
- before(:each) do
- @planting = FactoryGirl.create(:sunny_planting)
- end
+
+ let(:planting) { FactoryGirl.create(:sunny_planting) }
it 'should have a sunniness value' do
- @planting.sunniness.should eq 'sun'
+ planting.sunniness.should eq 'sun'
end
it 'all three valid sunniness values should work' do
['sun', 'shade', 'semi-shade', nil, ''].each do |s|
- @planting = FactoryGirl.build(:planting, :sunniness => s)
+ @planting = FactoryGirl.build(:planting, sunniness: s)
@planting.should be_valid
end
end
it 'should refuse invalid sunniness values' do
- @planting = FactoryGirl.build(:planting, :sunniness => 'not valid')
+ @planting = FactoryGirl.build(:planting, sunniness: 'not valid')
@planting.should_not be_valid
@planting.errors[:sunniness].should include("not valid is not a valid sunniness value")
end
@@ -111,13 +154,13 @@ describe Planting do
['seed', 'seedling', 'cutting', 'root division',
'runner', 'bare root plant', 'advanced plant',
'graft', 'layering', 'bulb', 'root/tuber', nil, ''].each do |p|
- @planting = FactoryGirl.build(:planting, :planted_from => p)
+ @planting = FactoryGirl.build(:planting, planted_from: p)
@planting.should be_valid
end
end
it 'should refuse invalid planted_from values' do
- @planting = FactoryGirl.build(:planting, :planted_from => 'not valid')
+ @planting = FactoryGirl.build(:planting, planted_from: 'not valid')
@planting.should_not be_valid
@planting.errors[:planted_from].should include("not valid is not a valid planting method")
end
@@ -126,30 +169,32 @@ describe Planting do
# we decided that all the tests for the planting/photo association would
# be done on this side, not on the photos side
context 'photos' do
- before(:each) do
- @planting = FactoryGirl.create(:planting)
- @photo = FactoryGirl.create(:photo)
- @planting.photos << @photo
+
+ let(:planting) { FactoryGirl.create(:planting) }
+ let(:photo) { FactoryGirl.create(:photo) }
+
+ before do
+ planting.photos << photo
end
it 'has a photo' do
- @planting.photos.first.should eq @photo
+ planting.photos.first.should eq photo
end
it 'deletes association with photos when photo is deleted' do
- @photo.destroy
- @planting.reload
- @planting.photos.should be_empty
+ photo.destroy
+ planting.reload
+ planting.photos.should be_empty
end
it 'has a default photo' do
- @planting.default_photo.should eq @photo
+ planting.default_photo.should eq photo
end
it 'chooses the most recent photo' do
@photo2 = FactoryGirl.create(:photo)
- @planting.photos << @photo2
- @planting.default_photo.should eq @photo2
+ planting.photos << @photo2
+ planting.default_photo.should eq @photo2
end
end
@@ -157,10 +202,10 @@ describe Planting do
it 'picks up interesting plantings' do
# plantings have members created implicitly for them
# each member is different, hence these are all interesting
- @planting1 = FactoryGirl.create(:planting, :created_at => 5.days.ago)
- @planting2 = FactoryGirl.create(:planting, :created_at => 4.days.ago)
- @planting3 = FactoryGirl.create(:planting, :created_at => 3.days.ago)
- @planting4 = FactoryGirl.create(:planting, :created_at => 2.days.ago)
+ @planting1 = FactoryGirl.create(:planting, created_at: 5.days.ago)
+ @planting2 = FactoryGirl.create(:planting, created_at: 4.days.ago)
+ @planting3 = FactoryGirl.create(:planting, created_at: 3.days.ago)
+ @planting4 = FactoryGirl.create(:planting, created_at: 2.days.ago)
# plantings need photos to be interesting
@photo = FactoryGirl.create(:photo)
@@ -193,14 +238,14 @@ describe Planting do
it 'ignores plantings with the same owner' do
# this planting is older
- @planting1 = FactoryGirl.create(:planting, :created_at => 1.day.ago)
+ @planting1 = FactoryGirl.create(:planting, created_at: 1.day.ago)
@planting1.photos << FactoryGirl.create(:photo)
@planting1.save
# this one is newer, and has the same owner, through the garden
@planting2 = FactoryGirl.create(:planting,
- :created_at => 1.minute.ago,
- :owner_id => @planting1.owner.id
+ created_at: 1.minute.ago,
+ owner_id: @planting1.owner.id
)
@planting2.photos << FactoryGirl.create(:photo)
@planting2.save
@@ -230,7 +275,7 @@ describe Planting do
context "with howmany argument" do
it "only returns the number asked for" do
@plantings = FactoryGirl.create_list(:planting, 10)
- Planting.interesting(3, false).length.should eq 3
+ Planting.interesting(3, false).size.should eq 3
end
end
@@ -259,22 +304,19 @@ describe Planting do
context "finished date validation" do
it 'requires finished date after planting date' do
- @f = FactoryGirl.build(:finished_planting, :planted_at =>
- '2014-01-01', :finished_at => '2013-01-01')
+ @f = FactoryGirl.build(:finished_planting, planted_at: '2014-01-01', finished_at: '2013-01-01')
@f.should_not be_valid
end
it 'allows just the planted date' do
- @f = FactoryGirl.build(:planting, :planted_at => '2013-01-01', :finished_at => nil)
+ @f = FactoryGirl.build(:planting, planted_at: '2013-01-01', finished_at: nil)
@f.should be_valid
end
+
it 'allows just the finished date' do
- @f = FactoryGirl.build(:planting, :finished_at => '2013-01-01', :planted_at => nil)
+ @f = FactoryGirl.build(:planting, finished_at: '2013-01-01', planted_at: nil)
@f.should be_valid
end
-
end
-
end
-
end
diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb
index 41afb09a0..57e803bf1 100644
--- a/spec/models/post_spec.rb
+++ b/spec/models/post_spec.rb
@@ -1,48 +1,47 @@
require 'rails_helper'
describe Post do
- before(:each) do
- @member = FactoryGirl.create(:member)
- end
+
+ let(:member) { FactoryGirl.create(:member) }
it_behaves_like "it is likeable"
it "should be sorted in reverse order" do
FactoryGirl.create(:post,
- :subject => 'first entry',
- :author => @member,
- :created_at => 2.days.ago
+ subject: 'first entry',
+ author: member,
+ created_at: 2.days.ago
)
FactoryGirl.create(:post,
- :subject => 'second entry',
- :author => @member,
- :created_at => 1.day.ago
+ subject: 'second entry',
+ author: member,
+ created_at: 1.day.ago
)
Post.first.subject.should == "second entry"
end
it "should have a slug" do
- @post = FactoryGirl.create(:post, :author => @member)
+ @post = FactoryGirl.create(:post, author: member)
@time = @post.created_at
@datestr = @time.strftime("%Y%m%d")
# 2 digit day and month, full-length years
# Counting digits using Math.log is not precise enough!
- @datestr.length.should == 4 + @time.year.to_s.size
- @post.slug.should == "#{@member.login_name}-#{@datestr}-a-post"
+ @datestr.size.should == 4 + @time.year.to_s.size
+ @post.slug.should == "#{member.login_name}-#{@datestr}-a-post"
end
it "has many comments" do
- @post = FactoryGirl.create(:post, :author => @member)
- @comment1 = FactoryGirl.create(:comment, :post => @post)
- @comment2 = FactoryGirl.create(:comment, :post => @post)
- @post.comments.length.should == 2
+ @post = FactoryGirl.create(:post, author: member)
+ @comment1 = FactoryGirl.create(:comment, post: @post)
+ @comment2 = FactoryGirl.create(:comment, post: @post)
+ @post.comments.size.should == 2
end
it "destroys comments when deleted" do
- @post = FactoryGirl.create(:post, :author => @member)
- @comment1 = FactoryGirl.create(:comment, :post => @post)
- @comment2 = FactoryGirl.create(:comment, :post => @post)
- @post.comments.length.should == 2
+ @post = FactoryGirl.create(:post, author: member)
+ @comment1 = FactoryGirl.create(:comment, post: @post)
+ @comment2 = FactoryGirl.create(:comment, post: @post)
+ @post.comments.size.should == 2
all = Comment.count
@post.destroy
Comment.count.should == all - 2
@@ -54,46 +53,80 @@ describe Post do
end
it "doesn't allow a nil subject" do
- @post = FactoryGirl.build(:post, :subject => nil)
+ @post = FactoryGirl.build(:post, subject: nil)
@post.should_not be_valid
end
it "doesn't allow a blank subject" do
- @post = FactoryGirl.build(:post, :subject => "")
+ @post = FactoryGirl.build(:post, subject: "")
@post.should_not be_valid
end
it "doesn't allow a subject with only spaces" do
- @post = FactoryGirl.build(:post, :subject => " ")
+ @post = FactoryGirl.build(:post, subject: " ")
@post.should_not be_valid
end
context "recent activity" do
- before(:each) do
- Time.stub(:now => Time.now)
- @post = FactoryGirl.create(:post, :created_at => 1.day.ago)
+
+ before do
+ Time.stub(now: Time.now)
end
+
+ let(:post) { FactoryGirl.create(:post, created_at: 1.day.ago) }
it "sets recent activity to post time" do
- @post.recent_activity.to_i.should eq @post.created_at.to_i
+ post.recent_activity.to_i.should eq post.created_at.to_i
end
it "sets recent activity to comment time" do
- @comment = FactoryGirl.create(:comment, :post => @post,
- :created_at => 1.hour.ago)
- @post.recent_activity.to_i.should eq @comment.created_at.to_i
+ @comment = FactoryGirl.create(:comment, post: post,
+ created_at: 1.hour.ago)
+ post.recent_activity.to_i.should eq @comment.created_at.to_i
end
it "shiny new post is recently active" do
# create a shiny new post
- @post2 = FactoryGirl.create(:post, :created_at => 1.minute.ago)
+ @post2 = FactoryGirl.create(:post, created_at: 1.minute.ago)
Post.recently_active.first.should eq @post2
end
it "new comment on old post is recently active" do
# now comment on an older post
- @comment2 = FactoryGirl.create(:comment, :post => @post, :created_at => 1.second.ago)
- Post.recently_active.first.should eq @post
+ @comment2 = FactoryGirl.create(:comment, post: post, created_at: 1.second.ago)
+ Post.recently_active.first.should eq post
+ end
+ end
+
+ context "notifications" do
+ let(:member2) { FactoryGirl.create(:member) }
+
+ it "sends a notification when a member is mentioned" do
+ expect {
+ FactoryGirl.create(:post, author: member, body: "Hey @" << member2.login_name)
+ }.to change(Notification, :count).by(1)
+ end
+
+ it "sets the notification field" do
+ @p = FactoryGirl.create(:post, author: member, body: "Hey @" << member2.login_name)
+ @n = Notification.first
+ @n.sender.should eq member
+ @n.recipient.should eq member2
+ @n.subject.should match /mentioned you in their post/
+ @n.body.should eq @p.body
+ end
+
+ it "sends notifications to all members mentioned" do
+ @member3 = FactoryGirl.create(:member)
+ expect {
+ FactoryGirl.create(:post, author: member, body: "Hey @" << member2.login_name << " & @" << @member3.login_name)
+ }.to change(Notification, :count).by(2)
+ end
+
+ it "doesn't send notifications if you mention yourself" do
+ expect {
+ FactoryGirl.create(:post, author: member, body: "@" << member.login_name)
+ }.to change(Notification, :count).by(0)
end
end
@@ -101,7 +134,7 @@ describe Post do
let!(:tomato) { FactoryGirl.create(:tomato) }
let!(:maize) { FactoryGirl.create(:maize) }
let!(:chard) { FactoryGirl.create(:chard) }
- let!(:post) { FactoryGirl.create(:post, :body => "[maize](crop)[tomato](crop)[tomato](crop)") }
+ let!(:post) { FactoryGirl.create(:post, body: "[maize](crop)[tomato](crop)[tomato](crop)") }
it "should be generated" do
expect(tomato.posts).to eq [post]
@@ -113,7 +146,7 @@ describe Post do
end
it "should be updated when post was modified" do
- post.update_attributes(:body => "[chard](crop)")
+ post.update_attributes(body: "[chard](crop)")
expect(post.crops).to eq [chard]
expect(chard.posts).to eq [post]
diff --git a/spec/models/scientific_name_spec.rb b/spec/models/scientific_name_spec.rb
index 020f1cc0d..e506acccf 100644
--- a/spec/models/scientific_name_spec.rb
+++ b/spec/models/scientific_name_spec.rb
@@ -3,30 +3,28 @@ require 'rails_helper'
describe ScientificName do
context 'all fields present' do
- before(:each) do
- @sn = FactoryGirl.create(:zea_mays)
- end
+ let(:sn) { FactoryGirl.create(:zea_mays) }
it 'should save a basic scientific name' do
- @sn.save.should be(true)
+ sn.save.should be(true)
end
it 'should be fetchable from the database' do
- @sn.save
+ sn.save
@sn2 = ScientificName.find_by_scientific_name('Zea mays')
@sn2.crop.name.should == 'maize'
end
it 'has a creator' do
- @sn.save
- @sn.creator.should be_an_instance_of Member
+ sn.save
+ sn.creator.should be_an_instance_of Member
end
end
context 'invalid data' do
it 'should not save a scientific name without a name' do
- @sn = ScientificName.new
- expect { @sn.save }.to raise_error ActiveRecord::StatementInvalid
+ sn = ScientificName.new
+ expect { sn.save }.to raise_error ActiveRecord::StatementInvalid
end
end
end
diff --git a/spec/models/seed_spec.rb b/spec/models/seed_spec.rb
index 747dbee71..58ae5f906 100644
--- a/spec/models/seed_spec.rb
+++ b/spec/models/seed_spec.rb
@@ -2,39 +2,37 @@ require 'rails_helper'
describe Seed do
- before(:each) do
- @seed = FactoryGirl.build(:seed)
- end
+ let(:seed) { FactoryGirl.build(:seed) }
it 'should save a basic seed' do
- @seed.save.should be(true)
+ seed.save.should be(true)
end
it "should have a slug" do
- @seed.save
- @seed.slug.should match(/member\d+-magic-bean/)
+ seed.save
+ seed.slug.should match(/member\d+-magic-bean/)
end
context 'quantity' do
it 'allows integer quantities' do
- @seed = FactoryGirl.build(:seed, :quantity => 99)
+ @seed = FactoryGirl.build(:seed, quantity: 99)
@seed.should be_valid
end
it "doesn't allow decimal quantities" do
- @seed = FactoryGirl.build(:seed, :quantity => 99.9)
+ @seed = FactoryGirl.build(:seed, quantity: 99.9)
@seed.should_not be_valid
end
it "doesn't allow non-numeric quantities" do
- @seed = FactoryGirl.build(:seed, :quantity => 'foo')
+ @seed = FactoryGirl.build(:seed, quantity: 'foo')
@seed.should_not be_valid
end
it "allows blank quantities" do
- @seed = FactoryGirl.build(:seed, :quantity => nil)
+ @seed = FactoryGirl.build(:seed, quantity: nil)
@seed.should be_valid
- @seed = FactoryGirl.build(:seed, :quantity => '')
+ @seed = FactoryGirl.build(:seed, quantity: '')
@seed.should be_valid
end
end
@@ -42,32 +40,32 @@ describe Seed do
context 'tradable' do
it 'all valid tradable_to values should work' do
['nowhere', 'locally', 'nationally', 'internationally'].each do |t|
- @seed = FactoryGirl.build(:seed, :tradable_to => t)
+ @seed = FactoryGirl.build(:seed, tradable_to: t)
@seed.should be_valid
end
end
it 'should refuse invalid tradable_to values' do
- @seed = FactoryGirl.build(:seed, :tradable_to => 'not valid')
+ @seed = FactoryGirl.build(:seed, tradable_to: 'not valid')
@seed.should_not be_valid
@seed.errors[:tradable_to].should include("You may only trade seed nowhere, locally, nationally, or internationally")
end
it 'should not allow nil or blank values' do
- @seed = FactoryGirl.build(:seed, :tradable_to => nil)
+ @seed = FactoryGirl.build(:seed, tradable_to: nil)
@seed.should_not be_valid
- @seed = FactoryGirl.build(:seed, :tradable_to => '')
+ @seed = FactoryGirl.build(:seed, tradable_to: '')
@seed.should_not be_valid
end
it 'tradable? gives the right answers' do
- @seed = FactoryGirl.create(:seed, :tradable_to => 'nowhere')
+ @seed = FactoryGirl.create(:seed, tradable_to: 'nowhere')
@seed.tradable?.should eq false
- @seed = FactoryGirl.create(:seed, :tradable_to => 'locally')
+ @seed = FactoryGirl.create(:seed, tradable_to: 'locally')
@seed.tradable?.should eq true
- @seed = FactoryGirl.create(:seed, :tradable_to => 'nationally')
+ @seed = FactoryGirl.create(:seed, tradable_to: 'nationally')
@seed.tradable?.should eq true
- @seed = FactoryGirl.create(:seed, :tradable_to => 'internationally')
+ @seed = FactoryGirl.create(:seed, tradable_to: 'internationally')
@seed.tradable?.should eq true
end
@@ -92,7 +90,7 @@ describe Seed do
it 'all valid organic values should work' do
['certified organic', 'non-certified organic',
'conventional/non-organic', 'unknown'].each do |t|
- @seed = FactoryGirl.build(:seed, :organic => t)
+ @seed = FactoryGirl.build(:seed, organic: t)
@seed.should be_valid
end
end
@@ -100,14 +98,14 @@ describe Seed do
it 'all valid GMO values should work' do
['certified GMO-free', 'non-certified GMO-free',
'GMO', 'unknown'].each do |t|
- @seed = FactoryGirl.build(:seed, :gmo => t)
+ @seed = FactoryGirl.build(:seed, gmo: t)
@seed.should be_valid
end
end
it 'all valid heirloom values should work' do
%w(heirloom hybrid unknown).each do |t|
- @seed = FactoryGirl.build(:seed, :heirloom => t)
+ @seed = FactoryGirl.build(:seed, heirloom: t)
@seed.should be_valid
end
end
@@ -139,8 +137,8 @@ describe Seed do
# 2) the owner must have a location set
@located_member = FactoryGirl.create(:london_member)
- @seed1 = FactoryGirl.create(:tradable_seed, :owner => @located_member)
- @seed2 = FactoryGirl.create(:seed, :owner => @located_member)
+ @seed1 = FactoryGirl.create(:tradable_seed, owner: @located_member)
+ @seed2 = FactoryGirl.create(:seed, owner: @located_member)
@seed3 = FactoryGirl.create(:tradable_seed)
@seed4 = FactoryGirl.create(:seed)
@@ -148,7 +146,7 @@ describe Seed do
Seed.interesting.should_not include @seed2
Seed.interesting.should_not include @seed3
Seed.interesting.should_not include @seed4
- Seed.interesting.length.should == 1
+ Seed.interesting.size.should == 1
end
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 784cfba6f..aa8d32946 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -1,9 +1,5 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
-require 'spec_helper'
-require File.expand_path("../../config/environment", __FILE__)
-require 'rspec/rails'
-# Add additional requires below this line. Rails is not loaded until this point!
require 'simplecov'
require 'coveralls'
@@ -21,9 +17,30 @@ SimpleCov.start :rails do
add_filter 'vendor/'
end
+require 'spec_helper'
+require File.expand_path("../../config/environment", __FILE__)
+require 'rspec/rails'
+# Add additional requires below this line. Rails is not loaded until this point!
+Rails.application.eager_load!
+
require 'capybara'
require 'capybara/poltergeist'
+require 'capybara/rspec'
+require 'capybara-screenshot/rspec'
+
Capybara.javascript_driver = :poltergeist
+if ENV['GROWSTUFF_CAPYBARA_DRIVER'].present?
+ case ENV['GROWSTUFF_CAPYBARA_DRIVER']
+ when 'selenium'
+ require 'selenium-webdriver'
+ end
+ Capybara.javascript_driver = ENV['GROWSTUFF_CAPYBARA_DRIVER'].to_sym
+end
+
+Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
+ "screenshot_#{example.description.gsub(' ', '-').gsub(/^.*\/spec\//,'')}"
+end
+
Capybara.app_host = 'http://localhost'
Capybara.server_port = 8081
@@ -80,6 +97,9 @@ RSpec.configure do |config|
# controller specs require this to work with Devise
# see https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29
- config.include Devise::TestHelpers, :type => :controller
- config.extend ControllerMacros, :type => :controller
+ config.include Devise::TestHelpers, type: :controller
+ config.extend ControllerMacros, type: :controller
+
+ # Allow just create(:factory) instead of needing to specify FactoryGirl.create(:factory)
+ config.include FactoryGirl::Syntax::Methods
end
diff --git a/spec/routing/account_types_routing_spec.rb b/spec/routing/account_types_routing_spec.rb
index 440c16956..83dba34a5 100644
--- a/spec/routing/account_types_routing_spec.rb
+++ b/spec/routing/account_types_routing_spec.rb
@@ -12,11 +12,11 @@ describe AccountTypesController do
end
it "routes to #show" do
- get("/account_types/1").should route_to("account_types#show", :id => "1")
+ get("/account_types/1").should route_to("account_types#show", id: "1")
end
it "routes to #edit" do
- get("/account_types/1/edit").should route_to("account_types#edit", :id => "1")
+ get("/account_types/1/edit").should route_to("account_types#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe AccountTypesController do
end
it "routes to #update" do
- put("/account_types/1").should route_to("account_types#update", :id => "1")
+ put("/account_types/1").should route_to("account_types#update", id: "1")
end
it "routes to #destroy" do
- delete("/account_types/1").should route_to("account_types#destroy", :id => "1")
+ delete("/account_types/1").should route_to("account_types#destroy", id: "1")
end
end
diff --git a/spec/routing/authentications_routing_spec.rb b/spec/routing/authentications_routing_spec.rb
index 5d907428f..75f86fd49 100644
--- a/spec/routing/authentications_routing_spec.rb
+++ b/spec/routing/authentications_routing_spec.rb
@@ -7,7 +7,7 @@ describe AuthenticationsController do
end
it "routes to #destroy" do
- delete("/authentications/1").should route_to("authentications#destroy", :id => "1")
+ delete("/authentications/1").should route_to("authentications#destroy", id: "1")
end
end
diff --git a/spec/routing/comments_routing_spec.rb b/spec/routing/comments_routing_spec.rb
index 4a0fe8026..b5466af43 100644
--- a/spec/routing/comments_routing_spec.rb
+++ b/spec/routing/comments_routing_spec.rb
@@ -12,11 +12,11 @@ describe CommentsController do
end
it "routes to #show" do
- get("/comments/1").should route_to("comments#show", :id => "1")
+ get("/comments/1").should route_to("comments#show", id: "1")
end
it "routes to #edit" do
- get("/comments/1/edit").should route_to("comments#edit", :id => "1")
+ get("/comments/1/edit").should route_to("comments#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe CommentsController do
end
it "routes to #update" do
- put("/comments/1").should route_to("comments#update", :id => "1")
+ put("/comments/1").should route_to("comments#update", id: "1")
end
it "routes to #destroy" do
- delete("/comments/1").should route_to("comments#destroy", :id => "1")
+ delete("/comments/1").should route_to("comments#destroy", id: "1")
end
end
diff --git a/spec/routing/crops_routing_spec.rb b/spec/routing/crops_routing_spec.rb
index 1e1fe4aac..95985917f 100644
--- a/spec/routing/crops_routing_spec.rb
+++ b/spec/routing/crops_routing_spec.rb
@@ -12,11 +12,11 @@ describe CropsController do
end
it "routes to #show" do
- get("/crops/1").should route_to("crops#show", :id => "1")
+ get("/crops/1").should route_to("crops#show", id: "1")
end
it "routes to #edit" do
- get("/crops/1/edit").should route_to("crops#edit", :id => "1")
+ get("/crops/1/edit").should route_to("crops#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe CropsController do
end
it "routes to #update" do
- put("/crops/1").should route_to("crops#update", :id => "1")
+ put("/crops/1").should route_to("crops#update", id: "1")
end
it "routes to #destroy" do
- delete("/crops/1").should route_to("crops#destroy", :id => "1")
+ delete("/crops/1").should route_to("crops#destroy", id: "1")
end
end
diff --git a/spec/routing/follows_routing_spec.rb b/spec/routing/follows_routing_spec.rb
index d4259e024..4158502c7 100644
--- a/spec/routing/follows_routing_spec.rb
+++ b/spec/routing/follows_routing_spec.rb
@@ -8,7 +8,7 @@ describe FollowsController do
end
it "routes to #destroy" do
- delete("/follows/1").should route_to("follows#destroy", :id => "1")
+ delete("/follows/1").should route_to("follows#destroy", id: "1")
end
end
diff --git a/spec/routing/forums_routing_spec.rb b/spec/routing/forums_routing_spec.rb
index 4bd7d6097..12730c556 100644
--- a/spec/routing/forums_routing_spec.rb
+++ b/spec/routing/forums_routing_spec.rb
@@ -12,11 +12,11 @@ describe ForumsController do
end
it "routes to #show" do
- get("/forums/1").should route_to("forums#show", :id => "1")
+ get("/forums/1").should route_to("forums#show", id: "1")
end
it "routes to #edit" do
- get("/forums/1/edit").should route_to("forums#edit", :id => "1")
+ get("/forums/1/edit").should route_to("forums#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe ForumsController do
end
it "routes to #update" do
- put("/forums/1").should route_to("forums#update", :id => "1")
+ put("/forums/1").should route_to("forums#update", id: "1")
end
it "routes to #destroy" do
- delete("/forums/1").should route_to("forums#destroy", :id => "1")
+ delete("/forums/1").should route_to("forums#destroy", id: "1")
end
end
diff --git a/spec/routing/gardens_routing_spec.rb b/spec/routing/gardens_routing_spec.rb
index 1c627e091..5270195ec 100644
--- a/spec/routing/gardens_routing_spec.rb
+++ b/spec/routing/gardens_routing_spec.rb
@@ -12,11 +12,11 @@ describe GardensController do
end
it "routes to #show" do
- get("/gardens/1").should route_to("gardens#show", :id => "1")
+ get("/gardens/1").should route_to("gardens#show", id: "1")
end
it "routes to #edit" do
- get("/gardens/1/edit").should route_to("gardens#edit", :id => "1")
+ get("/gardens/1/edit").should route_to("gardens#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe GardensController do
end
it "routes to #update" do
- put("/gardens/1").should route_to("gardens#update", :id => "1")
+ put("/gardens/1").should route_to("gardens#update", id: "1")
end
it "routes to #destroy" do
- delete("/gardens/1").should route_to("gardens#destroy", :id => "1")
+ delete("/gardens/1").should route_to("gardens#destroy", id: "1")
end
end
diff --git a/spec/routing/harvests_routing_spec.rb b/spec/routing/harvests_routing_spec.rb
index 8b34d920a..4d532bcfc 100644
--- a/spec/routing/harvests_routing_spec.rb
+++ b/spec/routing/harvests_routing_spec.rb
@@ -12,11 +12,11 @@ describe HarvestsController do
end
it "routes to #show" do
- get("/harvests/1").should route_to("harvests#show", :id => "1")
+ get("/harvests/1").should route_to("harvests#show", id: "1")
end
it "routes to #edit" do
- get("/harvests/1/edit").should route_to("harvests#edit", :id => "1")
+ get("/harvests/1/edit").should route_to("harvests#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe HarvestsController do
end
it "routes to #update" do
- put("/harvests/1").should route_to("harvests#update", :id => "1")
+ put("/harvests/1").should route_to("harvests#update", id: "1")
end
it "routes to #destroy" do
- delete("/harvests/1").should route_to("harvests#destroy", :id => "1")
+ delete("/harvests/1").should route_to("harvests#destroy", id: "1")
end
end
diff --git a/spec/routing/notifications_routing_spec.rb b/spec/routing/notifications_routing_spec.rb
index 35f54689f..d3c2b9f61 100644
--- a/spec/routing/notifications_routing_spec.rb
+++ b/spec/routing/notifications_routing_spec.rb
@@ -12,11 +12,11 @@ describe NotificationsController do
end
it "routes to #show" do
- get("/notifications/1").should route_to("notifications#show", :id => "1")
+ get("/notifications/1").should route_to("notifications#show", id: "1")
end
it "routes to #edit" do
- get("/notifications/1/edit").should route_to("notifications#edit", :id => "1")
+ get("/notifications/1/edit").should route_to("notifications#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe NotificationsController do
end
it "routes to #update" do
- put("/notifications/1").should route_to("notifications#update", :id => "1")
+ put("/notifications/1").should route_to("notifications#update", id: "1")
end
it "routes to #destroy" do
- delete("/notifications/1").should route_to("notifications#destroy", :id => "1")
+ delete("/notifications/1").should route_to("notifications#destroy", id: "1")
end
end
diff --git a/spec/routing/order_items_routing_spec.rb b/spec/routing/order_items_routing_spec.rb
index 858a873ad..6562e3a17 100644
--- a/spec/routing/order_items_routing_spec.rb
+++ b/spec/routing/order_items_routing_spec.rb
@@ -12,11 +12,11 @@ describe OrderItemsController do
end
it "routes to #show" do
- get("/order_items/1").should route_to("order_items#show", :id => "1")
+ get("/order_items/1").should route_to("order_items#show", id: "1")
end
it "routes to #edit" do
- get("/order_items/1/edit").should route_to("order_items#edit", :id => "1")
+ get("/order_items/1/edit").should route_to("order_items#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe OrderItemsController do
end
it "routes to #update" do
- put("/order_items/1").should route_to("order_items#update", :id => "1")
+ put("/order_items/1").should route_to("order_items#update", id: "1")
end
it "routes to #destroy" do
- delete("/order_items/1").should route_to("order_items#destroy", :id => "1")
+ delete("/order_items/1").should route_to("order_items#destroy", id: "1")
end
end
diff --git a/spec/routing/orders_routing_spec.rb b/spec/routing/orders_routing_spec.rb
index 7fc9735ee..61410745e 100644
--- a/spec/routing/orders_routing_spec.rb
+++ b/spec/routing/orders_routing_spec.rb
@@ -12,11 +12,11 @@ describe OrdersController do
end
it "routes to #show" do
- get("/orders/1").should route_to("orders#show", :id => "1")
+ get("/orders/1").should route_to("orders#show", id: "1")
end
it "routes to #edit" do
- get("/orders/1/edit").should route_to("orders#edit", :id => "1")
+ get("/orders/1/edit").should route_to("orders#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe OrdersController do
end
it "routes to #update" do
- put("/orders/1").should route_to("orders#update", :id => "1")
+ put("/orders/1").should route_to("orders#update", id: "1")
end
it "routes to #destroy" do
- delete("/orders/1").should route_to("orders#destroy", :id => "1")
+ delete("/orders/1").should route_to("orders#destroy", id: "1")
end
end
diff --git a/spec/routing/photos_routing_spec.rb b/spec/routing/photos_routing_spec.rb
index 5bdfeca07..fb96758c2 100644
--- a/spec/routing/photos_routing_spec.rb
+++ b/spec/routing/photos_routing_spec.rb
@@ -12,11 +12,11 @@ describe PhotosController do
end
it "routes to #show" do
- get("/photos/1").should route_to("photos#show", :id => "1")
+ get("/photos/1").should route_to("photos#show", id: "1")
end
it "routes to #edit" do
- get("/photos/1/edit").should route_to("photos#edit", :id => "1")
+ get("/photos/1/edit").should route_to("photos#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe PhotosController do
end
it "routes to #update" do
- put("/photos/1").should route_to("photos#update", :id => "1")
+ put("/photos/1").should route_to("photos#update", id: "1")
end
it "routes to #destroy" do
- delete("/photos/1").should route_to("photos#destroy", :id => "1")
+ delete("/photos/1").should route_to("photos#destroy", id: "1")
end
end
diff --git a/spec/routing/plant_parts_routing_spec.rb b/spec/routing/plant_parts_routing_spec.rb
index 54d02caa1..4a4137cd6 100644
--- a/spec/routing/plant_parts_routing_spec.rb
+++ b/spec/routing/plant_parts_routing_spec.rb
@@ -12,11 +12,11 @@ describe PlantPartsController do
end
it "routes to #show" do
- get("/plant_parts/1").should route_to("plant_parts#show", :id => "1")
+ get("/plant_parts/1").should route_to("plant_parts#show", id: "1")
end
it "routes to #edit" do
- get("/plant_parts/1/edit").should route_to("plant_parts#edit", :id => "1")
+ get("/plant_parts/1/edit").should route_to("plant_parts#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe PlantPartsController do
end
it "routes to #update" do
- put("/plant_parts/1").should route_to("plant_parts#update", :id => "1")
+ put("/plant_parts/1").should route_to("plant_parts#update", id: "1")
end
it "routes to #destroy" do
- delete("/plant_parts/1").should route_to("plant_parts#destroy", :id => "1")
+ delete("/plant_parts/1").should route_to("plant_parts#destroy", id: "1")
end
end
diff --git a/spec/routing/plantings_routing_spec.rb b/spec/routing/plantings_routing_spec.rb
index bf3e1e8b8..1be8416d4 100644
--- a/spec/routing/plantings_routing_spec.rb
+++ b/spec/routing/plantings_routing_spec.rb
@@ -12,11 +12,11 @@ describe PlantingsController do
end
it "routes to #show" do
- get("/plantings/1").should route_to("plantings#show", :id => "1")
+ get("/plantings/1").should route_to("plantings#show", id: "1")
end
it "routes to #edit" do
- get("/plantings/1/edit").should route_to("plantings#edit", :id => "1")
+ get("/plantings/1/edit").should route_to("plantings#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe PlantingsController do
end
it "routes to #update" do
- put("/plantings/1").should route_to("plantings#update", :id => "1")
+ put("/plantings/1").should route_to("plantings#update", id: "1")
end
it "routes to #destroy" do
- delete("/plantings/1").should route_to("plantings#destroy", :id => "1")
+ delete("/plantings/1").should route_to("plantings#destroy", id: "1")
end
end
diff --git a/spec/routing/products_routing_spec.rb b/spec/routing/products_routing_spec.rb
index a9c2fa004..189bbe59a 100644
--- a/spec/routing/products_routing_spec.rb
+++ b/spec/routing/products_routing_spec.rb
@@ -12,11 +12,11 @@ describe ProductsController do
end
it "routes to #show" do
- get("/products/1").should route_to("products#show", :id => "1")
+ get("/products/1").should route_to("products#show", id: "1")
end
it "routes to #edit" do
- get("/products/1/edit").should route_to("products#edit", :id => "1")
+ get("/products/1/edit").should route_to("products#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe ProductsController do
end
it "routes to #update" do
- put("/products/1").should route_to("products#update", :id => "1")
+ put("/products/1").should route_to("products#update", id: "1")
end
it "routes to #destroy" do
- delete("/products/1").should route_to("products#destroy", :id => "1")
+ delete("/products/1").should route_to("products#destroy", id: "1")
end
end
diff --git a/spec/routing/roles_routing_spec.rb b/spec/routing/roles_routing_spec.rb
index 0a7900f9d..752bd7c49 100644
--- a/spec/routing/roles_routing_spec.rb
+++ b/spec/routing/roles_routing_spec.rb
@@ -12,11 +12,11 @@ describe RolesController do
end
it "routes to #show" do
- get("/roles/1").should route_to("roles#show", :id => "1")
+ get("/roles/1").should route_to("roles#show", id: "1")
end
it "routes to #edit" do
- get("/roles/1/edit").should route_to("roles#edit", :id => "1")
+ get("/roles/1/edit").should route_to("roles#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe RolesController do
end
it "routes to #update" do
- put("/roles/1").should route_to("roles#update", :id => "1")
+ put("/roles/1").should route_to("roles#update", id: "1")
end
it "routes to #destroy" do
- delete("/roles/1").should route_to("roles#destroy", :id => "1")
+ delete("/roles/1").should route_to("roles#destroy", id: "1")
end
end
diff --git a/spec/routing/scientific_names_routing_spec.rb b/spec/routing/scientific_names_routing_spec.rb
index 00c049289..f5bfa780e 100644
--- a/spec/routing/scientific_names_routing_spec.rb
+++ b/spec/routing/scientific_names_routing_spec.rb
@@ -12,11 +12,11 @@ describe ScientificNamesController do
end
it "routes to #show" do
- get("/scientific_names/1").should route_to("scientific_names#show", :id => "1")
+ get("/scientific_names/1").should route_to("scientific_names#show", id: "1")
end
it "routes to #edit" do
- get("/scientific_names/1/edit").should route_to("scientific_names#edit", :id => "1")
+ get("/scientific_names/1/edit").should route_to("scientific_names#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe ScientificNamesController do
end
it "routes to #update" do
- put("/scientific_names/1").should route_to("scientific_names#update", :id => "1")
+ put("/scientific_names/1").should route_to("scientific_names#update", id: "1")
end
it "routes to #destroy" do
- delete("/scientific_names/1").should route_to("scientific_names#destroy", :id => "1")
+ delete("/scientific_names/1").should route_to("scientific_names#destroy", id: "1")
end
end
diff --git a/spec/routing/seeds_routing_spec.rb b/spec/routing/seeds_routing_spec.rb
index 4fe46774a..5ac7ae02c 100644
--- a/spec/routing/seeds_routing_spec.rb
+++ b/spec/routing/seeds_routing_spec.rb
@@ -12,11 +12,11 @@ describe SeedsController do
end
it "routes to #show" do
- get("/seeds/1").should route_to("seeds#show", :id => "1")
+ get("/seeds/1").should route_to("seeds#show", id: "1")
end
it "routes to #edit" do
- get("/seeds/1/edit").should route_to("seeds#edit", :id => "1")
+ get("/seeds/1/edit").should route_to("seeds#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe SeedsController do
end
it "routes to #update" do
- put("/seeds/1").should route_to("seeds#update", :id => "1")
+ put("/seeds/1").should route_to("seeds#update", id: "1")
end
it "routes to #destroy" do
- delete("/seeds/1").should route_to("seeds#destroy", :id => "1")
+ delete("/seeds/1").should route_to("seeds#destroy", id: "1")
end
end
diff --git a/spec/routing/updates_routing_spec.rb b/spec/routing/updates_routing_spec.rb
index 9ff2b5ccd..32be13b86 100644
--- a/spec/routing/updates_routing_spec.rb
+++ b/spec/routing/updates_routing_spec.rb
@@ -12,11 +12,11 @@ describe PostsController do
end
it "routes to #show" do
- get("/posts/1").should route_to("posts#show", :id => "1")
+ get("/posts/1").should route_to("posts#show", id: "1")
end
it "routes to #edit" do
- get("/posts/1/edit").should route_to("posts#edit", :id => "1")
+ get("/posts/1/edit").should route_to("posts#edit", id: "1")
end
it "routes to #create" do
@@ -24,11 +24,11 @@ describe PostsController do
end
it "routes to #update" do
- put("/posts/1").should route_to("posts#update", :id => "1")
+ put("/posts/1").should route_to("posts#update", id: "1")
end
it "routes to #destroy" do
- delete("/posts/1").should route_to("posts#destroy", :id => "1")
+ delete("/posts/1").should route_to("posts#destroy", id: "1")
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 191e049ee..8c7b0b9fe 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -14,6 +14,8 @@
# users commonly want.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
+require "codeclimate-test-reporter"
+CodeClimate::TestReporter.start
RSpec.configure do |config|
# rspec-expectations config goes here. You can use an alternate
# assertion/expectation library such as wrong or the stdlib/minitest
diff --git a/spec/support/controller_macros.rb b/spec/support/controller_macros.rb
index eb5be2dd4..2e8162705 100644
--- a/spec/support/controller_macros.rb
+++ b/spec/support/controller_macros.rb
@@ -1,9 +1,11 @@
# Taken unashamedly from https://github.com/plataformatec/devise/wiki/How-To%3a-Controllers-and-Views-tests-with-Rails-3-%28and-rspec%29
module ControllerMacros
def login_member(member_factory=:member)
+
+ let(:member) { member = FactoryGirl.create(member_factory || :member) }
+
before(:each) do
@request.env["devise.mapping"] = Devise.mappings[:member]
- member = FactoryGirl.create(member_factory || :member)
sign_in member
end
end
diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb
index b3e908378..051579ea7 100644
--- a/spec/support/database_cleaner.rb
+++ b/spec/support/database_cleaner.rb
@@ -8,7 +8,7 @@ RSpec.configure do |config|
DatabaseCleaner.strategy = :transaction
end
- config.before(:each, :js => true) do
+ config.before(:each, js: true) do
DatabaseCleaner.strategy = :truncation
end
diff --git a/spec/support/devise.rb b/spec/support/devise.rb
index 5d898b4d3..5fffd6c3f 100644
--- a/spec/support/devise.rb
+++ b/spec/support/devise.rb
@@ -1,4 +1,4 @@
RSpec.configure do |config|
- config.include Devise::TestHelpers, :type => :controller
- config.include Devise::TestHelpers, :type => :view
+ config.include Devise::TestHelpers, type: :controller
+ config.include Devise::TestHelpers, type: :view
end
diff --git a/spec/support/elasticsearch_helpers.rb b/spec/support/elasticsearch_helpers.rb
index 0d89eb33b..94cf447ff 100644
--- a/spec/support/elasticsearch_helpers.rb
+++ b/spec/support/elasticsearch_helpers.rb
@@ -10,7 +10,7 @@ end
RSpec.configure do |config|
config.include ElasticsearchHelpers
- config.before(:each) do
+ config.before(:all) do
if ENV['GROWSTUFF_ELASTICSEARCH'] == "true"
Crop.__elasticsearch__.create_index! force: true
end
diff --git a/spec/support/feature_helpers.rb b/spec/support/feature_helpers.rb
index 81b781d18..b4da3b755 100644
--- a/spec/support/feature_helpers.rb
+++ b/spec/support/feature_helpers.rb
@@ -1,7 +1,7 @@
module FeatureHelpers
def fill_autocomplete(field, options={})
- fill_in field, :with => options[:with]
+ fill_in field, with: options[:with]
page.execute_script %Q{ $('##{field}').trigger('focus'); }
page.execute_script %Q{ $('##{field}').trigger('keydown'); }
@@ -16,5 +16,5 @@ module FeatureHelpers
end
RSpec.configure do |config|
- config.include FeatureHelpers, :type => :feature
+ config.include FeatureHelpers, type: :feature
end
\ No newline at end of file
diff --git a/spec/views/about/contact_spec.rb b/spec/views/about/contact_spec.rb
deleted file mode 100644
index f655a1394..000000000
--- a/spec/views/about/contact_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'rails_helper'
-
-describe 'about/contact.html.haml', :type => "view" do
- before(:each) do
- render
- end
-
- it 'should show support faq' do
- render
- rendered.should have_content 'General contact email'
- end
-end
diff --git a/spec/views/account_types/edit.html.haml_spec.rb b/spec/views/account_types/edit.html.haml_spec.rb
index cf77a0402..f8fa80cc3 100644
--- a/spec/views/account_types/edit.html.haml_spec.rb
+++ b/spec/views/account_types/edit.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "account_types/edit" do
before(:each) do
@account_type = assign(:account_type, stub_model(AccountType,
- :name => "MyString",
- :is_paid => false,
- :is_permanent_paid => false
+ name: "MyString",
+ is_paid: false,
+ is_permanent_paid: false
))
end
@@ -13,10 +29,10 @@ describe "account_types/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => account_types_path(@account_type), :method => "post" do
- assert_select "input#account_type_name", :name => "account_type[name]"
- assert_select "input#account_type_is_paid", :name => "account_type[is_paid]"
- assert_select "input#account_type_is_permanent_paid", :name => "account_type[is_permanent_paid]"
+ assert_select "form", action: account_types_path(@account_type), method: "post" do
+ assert_select "input#account_type_name", name: "account_type[name]"
+ assert_select "input#account_type_is_paid", name: "account_type[is_paid]"
+ assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]"
end
end
end
diff --git a/spec/views/account_types/index.html.haml_spec.rb b/spec/views/account_types/index.html.haml_spec.rb
index 1bbd0dc72..76a83d269 100644
--- a/spec/views/account_types/index.html.haml_spec.rb
+++ b/spec/views/account_types/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "account_types/index" do
@@ -9,6 +25,6 @@ describe "account_types/index" do
it "renders a list of account_types" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => @type.name.to_s, :count => 2
+ assert_select "tr>td", text: @type.name.to_s, count: 2
end
end
diff --git a/spec/views/account_types/new.html.haml_spec.rb b/spec/views/account_types/new.html.haml_spec.rb
index a9e97ee54..8ec9fc1ff 100644
--- a/spec/views/account_types/new.html.haml_spec.rb
+++ b/spec/views/account_types/new.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "account_types/new" do
before(:each) do
assign(:account_type, stub_model(AccountType,
- :name => "MyString",
- :is_paid => false,
- :is_permanent_paid => false
+ name: "MyString",
+ is_paid: false,
+ is_permanent_paid: false
).as_new_record)
end
@@ -13,10 +29,10 @@ describe "account_types/new" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => account_types_path, :method => "post" do
- assert_select "input#account_type_name", :name => "account_type[name]"
- assert_select "input#account_type_is_paid", :name => "account_type[is_paid]"
- assert_select "input#account_type_is_permanent_paid", :name => "account_type[is_permanent_paid]"
+ assert_select "form", action: account_types_path, method: "post" do
+ assert_select "input#account_type_name", name: "account_type[name]"
+ assert_select "input#account_type_is_paid", name: "account_type[is_paid]"
+ assert_select "input#account_type_is_permanent_paid", name: "account_type[is_permanent_paid]"
end
end
end
diff --git a/spec/views/account_types/show.html.haml_spec.rb b/spec/views/account_types/show.html.haml_spec.rb
index bee9cebd5..bfbd50243 100644
--- a/spec/views/account_types/show.html.haml_spec.rb
+++ b/spec/views/account_types/show.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "account_types/show" do
before(:each) do
@account_type = assign(:account_type, stub_model(AccountType,
- :name => "Name",
- :is_paid => false,
- :is_permanent_paid => false
+ name: "Name",
+ is_paid: false,
+ is_permanent_paid: false
))
end
diff --git a/spec/views/accounts/edit.html.haml_spec.rb b/spec/views/accounts/edit.html.haml_spec.rb
index 124ec1d12..2f265658f 100644
--- a/spec/views/accounts/edit.html.haml_spec.rb
+++ b/spec/views/accounts/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "accounts/edit" do
@@ -10,9 +26,9 @@ describe "accounts/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => accounts_path(@account), :method => "post" do
- assert_select "input#account_member_id", :name => "account[member_id]"
- assert_select "input#account_account_type", :name => "account[account_type]"
+ assert_select "form", action: accounts_path(@account), method: "post" do
+ assert_select "input#account_member_id", name: "account[member_id]"
+ assert_select "input#account_account_type", name: "account[account_type]"
end
end
end
diff --git a/spec/views/accounts/index.html.haml_spec.rb b/spec/views/accounts/index.html.haml_spec.rb
index e8c0f1a79..60b2cf6f6 100644
--- a/spec/views/accounts/index.html.haml_spec.rb
+++ b/spec/views/accounts/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "accounts/index" do
@@ -10,6 +26,6 @@ describe "accounts/index" do
it "renders a list of accounts" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => @account.member_id.to_s, :count => 2
+ assert_select "tr>td", text: @account.member_id.to_s, count: 2
end
end
diff --git a/spec/views/accounts/new.html.haml_spec.rb b/spec/views/accounts/new.html.haml_spec.rb
index 3a2b7cdbc..f51649226 100644
--- a/spec/views/accounts/new.html.haml_spec.rb
+++ b/spec/views/accounts/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "accounts/new" do
@@ -10,9 +26,9 @@ describe "accounts/new" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => accounts_path, :method => "post" do
- assert_select "input#account_member_id", :name => "account[member_id]"
- assert_select "input#account_account_type", :name => "account[account_type]"
+ assert_select "form", action: accounts_path, method: "post" do
+ assert_select "input#account_member_id", name: "account[member_id]"
+ assert_select "input#account_account_type", name: "account[account_type]"
end
end
end
diff --git a/spec/views/accounts/show.html.haml_spec.rb b/spec/views/accounts/show.html.haml_spec.rb
index 13dfc3589..7b4e273d1 100644
--- a/spec/views/accounts/show.html.haml_spec.rb
+++ b/spec/views/accounts/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "accounts/show" do
diff --git a/spec/views/admin/index_spec.rb b/spec/views/admin/index_spec.rb
index eb9dd9d01..79ac5d965 100644
--- a/spec/views/admin/index_spec.rb
+++ b/spec/views/admin/index_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'admin/index.html.haml', :type => "view" do
+describe 'admin/index.html.haml', type: "view" do
before(:each) do
@member = FactoryGirl.create(:admin_member)
sign_in @member
@@ -9,10 +25,10 @@ describe 'admin/index.html.haml', :type => "view" do
end
it "includes links to manage various things" do
- assert_select "a", :href => account_types_path
- assert_select "a", :href => products_path
- assert_select "a", :href => roles_path
- assert_select "a", :href => forums_path
+ assert_select "a", href: account_types_path
+ assert_select "a", href: products_path
+ assert_select "a", href: roles_path
+ assert_select "a", href: forums_path
end
it "has a link to newsletter subscribers" do
diff --git a/spec/views/admin/newsletter_spec.rb b/spec/views/admin/newsletter_spec.rb
index d072aee2e..55f02d0fa 100644
--- a/spec/views/admin/newsletter_spec.rb
+++ b/spec/views/admin/newsletter_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'admin/newsletter.html.haml', :type => "view" do
+describe 'admin/newsletter.html.haml', type: "view" do
before(:each) do
@member = FactoryGirl.create(:admin_member)
sign_in @member
diff --git a/spec/views/admin/orders/index_spec.rb b/spec/views/admin/orders/index_spec.rb
index e4279fdd0..55d55773d 100644
--- a/spec/views/admin/orders/index_spec.rb
+++ b/spec/views/admin/orders/index_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'admin/orders/index.html.haml', :type => "view" do
+describe 'admin/orders/index.html.haml', type: "view" do
before(:each) do
@member = FactoryGirl.create(:admin_member)
sign_in @member
@@ -15,6 +31,6 @@ describe 'admin/orders/index.html.haml', :type => "view" do
end
it "lets you search by referral code" do
- assert_select "option[value=referral_code]", :text => "Referral code"
+ assert_select "option[value=referral_code]", text: "Referral code"
end
end
diff --git a/spec/views/comments/edit.html.haml_spec.rb b/spec/views/comments/edit.html.haml_spec.rb
index 87ba9c549..d6e7ccb2a 100644
--- a/spec/views/comments/edit.html.haml_spec.rb
+++ b/spec/views/comments/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "comments/edit" do
@@ -10,8 +26,8 @@ describe "comments/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => comments_path(@comment), :method => "post" do
- assert_select "textarea#comment_body", :name => "comment[body]"
+ assert_select "form", action: comments_path(@comment), method: "post" do
+ assert_select "textarea#comment_body", name: "comment[body]"
end
end
end
diff --git a/spec/views/comments/index.html.haml_spec.rb b/spec/views/comments/index.html.haml_spec.rb
index 7161978ab..4b8cbf72f 100644
--- a/spec/views/comments/index.html.haml_spec.rb
+++ b/spec/views/comments/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "comments/index" do
@@ -9,7 +25,7 @@ describe "comments/index" do
comments = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
FactoryGirl.create(:comment),
- FactoryGirl.create(:comment, :body => 'ROFL')
+ FactoryGirl.create(:comment, body: 'ROFL')
])
end
assign(:comments, comments)
@@ -23,6 +39,6 @@ describe "comments/index" do
end
it "contains an RSS feed link" do
- assert_select "a", :href => comments_path(:format => 'rss')
+ assert_select "a", href: comments_path(format: 'rss')
end
end
diff --git a/spec/views/comments/index.rss.haml_spec.rb b/spec/views/comments/index.rss.haml_spec.rb
index 5278a8b56..9c61e9f2d 100644
--- a/spec/views/comments/index.rss.haml_spec.rb
+++ b/spec/views/comments/index.rss.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe 'comments/index.rss.haml' do
@@ -6,8 +22,8 @@ describe 'comments/index.rss.haml' do
@author = FactoryGirl.create(:member)
@post = FactoryGirl.create(:post)
assign(:comments, [
- FactoryGirl.create(:comment, :author => @author, :post => @post),
- FactoryGirl.create(:comment, :author => @author, :post => @post)
+ FactoryGirl.create(:comment, author: @author, post: @post),
+ FactoryGirl.create(:comment, author: @author, post: @post)
])
render
end
diff --git a/spec/views/comments/new.html.haml_spec.rb b/spec/views/comments/new.html.haml_spec.rb
index 4df929a54..d86d304cf 100644
--- a/spec/views/comments/new.html.haml_spec.rb
+++ b/spec/views/comments/new.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "comments/new" do
before(:each) do
controller.stub(:current_user) { nil }
@post = FactoryGirl.create(:post)
- @comment = FactoryGirl.create(:comment, :post => @post)
+ @comment = FactoryGirl.create(:comment, post: @post)
assign(:comment, @comment)
assign(:comments, [@comment])
render
@@ -23,8 +39,8 @@ describe "comments/new" do
end
it "renders new comment form" do
- assert_select "form", :action => comments_path, :method => "post" do
- assert_select "textarea#comment_body", :name => "comment[body]"
+ assert_select "form", action: comments_path, method: "post" do
+ assert_select "textarea#comment_body", name: "comment[body]"
end
end
diff --git a/spec/views/comments/show.html.haml_spec.rb b/spec/views/comments/show.html.haml_spec.rb
index 7152a2715..80b59d33d 100644
--- a/spec/views/comments/show.html.haml_spec.rb
+++ b/spec/views/comments/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "comments/show" do
diff --git a/spec/views/crops/_grown_for.html.haml_spec.rb b/spec/views/crops/_grown_for.html.haml_spec.rb
index 88cf618e5..10a36aff9 100644
--- a/spec/views/crops/_grown_for.html.haml_spec.rb
+++ b/spec/views/crops/_grown_for.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/_grown_for" do
@@ -5,14 +21,14 @@ describe "crops/_grown_for" do
@crop = FactoryGirl.create(:crop)
@pp = FactoryGirl.create(:plant_part)
@harvest = FactoryGirl.create(:harvest,
- :crop => @crop,
- :plant_part => @pp
+ crop: @crop,
+ plant_part: @pp
)
end
it 'shows plant parts' do
- render :partial => 'crops/grown_for', :locals => { :crop => @crop }
+ render partial: 'crops/grown_for', locals: { crop: @crop }
rendered.should have_content @pp.name
- assert_select "a", :href => plant_part_path(@pp)
+ assert_select "a", href: plant_part_path(@pp)
end
end
diff --git a/spec/views/crops/_planting_advice.html.haml_spec.rb b/spec/views/crops/_planting_advice.html.haml_spec.rb
index 6c2a35481..77e7e1b38 100644
--- a/spec/views/crops/_planting_advice.html.haml_spec.rb
+++ b/spec/views/crops/_planting_advice.html.haml_spec.rb
@@ -1,34 +1,50 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/_planting_advice" do
before(:each) do
@owner = FactoryGirl.create(:member)
@crop = FactoryGirl.create(:crop)
- @garden = FactoryGirl.create(:garden, :owner => @owner)
+ @garden = FactoryGirl.create(:garden, owner: @owner)
@planting = FactoryGirl.create(:planting,
- :garden => @garden,
- :crop => @crop
+ garden: @garden,
+ crop: @crop
)
end
context "sunniness" do
it "doesn't show sunniness if none are set" do
- render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
+ render partial: 'crops/planting_advice', locals: { crop: @crop }
rendered.should have_content "Plant in: not known."
end
it "shows sunniness frequencies" do
- FactoryGirl.create(:sunny_planting, :crop => @crop)
- render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
+ FactoryGirl.create(:sunny_planting, crop: @crop)
+ render partial: 'crops/planting_advice', locals: { crop: @crop }
rendered.should have_content "Plant in:"
rendered.should have_content "sun (1)"
end
it "shows multiple sunniness frequencies" do
- FactoryGirl.create(:sunny_planting, :crop => @crop)
- FactoryGirl.create(:sunny_planting, :crop => @crop)
- FactoryGirl.create(:shady_planting, :crop => @crop)
- render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
+ FactoryGirl.create(:sunny_planting, crop: @crop)
+ FactoryGirl.create(:sunny_planting, crop: @crop)
+ FactoryGirl.create(:shady_planting, crop: @crop)
+ render partial: 'crops/planting_advice', locals: { crop: @crop }
rendered.should have_content "Plant in:"
rendered.should have_content "sun (2), shade (1)"
end
@@ -38,22 +54,22 @@ describe "crops/_planting_advice" do
context "planted from" do
it "doesn't show planted_from if none are set" do
- render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
+ render partial: 'crops/planting_advice', locals: { crop: @crop }
rendered.should have_content "Plant from: not known."
end
it "shows planted_from frequencies" do
- FactoryGirl.create(:seed_planting, :crop => @crop)
- render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
+ FactoryGirl.create(:seed_planting, crop: @crop)
+ render partial: 'crops/planting_advice', locals: { crop: @crop }
rendered.should have_content "Plant from:"
rendered.should have_content "seed (1)"
end
it "shows multiple planted_from frequencies" do
- FactoryGirl.create(:seed_planting, :crop => @crop)
- FactoryGirl.create(:seed_planting, :crop => @crop)
- FactoryGirl.create(:cutting_planting, :crop => @crop)
- render :partial => 'crops/planting_advice', :locals => { :crop => @crop }
+ FactoryGirl.create(:seed_planting, crop: @crop)
+ FactoryGirl.create(:seed_planting, crop: @crop)
+ FactoryGirl.create(:cutting_planting, crop: @crop)
+ render partial: 'crops/planting_advice', locals: { crop: @crop }
rendered.should have_content "Plant from:"
rendered.should have_content "seed (2), cutting (1)"
end
diff --git a/spec/views/crops/_popover.html.haml_spec.rb b/spec/views/crops/_popover.html.haml_spec.rb
index d503a7235..3ef9660f6 100644
--- a/spec/views/crops/_popover.html.haml_spec.rb
+++ b/spec/views/crops/_popover.html.haml_spec.rb
@@ -1,12 +1,28 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/_popover" do
before(:each) do
@tomato = FactoryGirl.create(:tomato)
- @sn = FactoryGirl.create(:solanum_lycopersicum, :crop => @tomato)
- @planting = FactoryGirl.create(:planting, :crop => @tomato)
+ @sn = FactoryGirl.create(:solanum_lycopersicum, crop: @tomato)
+ @planting = FactoryGirl.create(:planting, crop: @tomato)
@tomato.reload # to pick up latest plantings_count
- render :partial => 'crops/popover', :locals => { :crop => @tomato }
+ render partial: 'crops/popover', locals: { crop: @tomato }
end
it 'has a scientific name' do
diff --git a/spec/views/crops/edit.html.haml_spec.rb b/spec/views/crops/edit.html.haml_spec.rb
index 031addb30..98957fc85 100644
--- a/spec/views/crops/edit.html.haml_spec.rb
+++ b/spec/views/crops/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/edit" do
@@ -17,16 +33,4 @@ describe "crops/edit" do
rendered.should have_content "Added by #{@crop.creator} less than a minute ago."
end
- it "renders the edit crop form" do
- assert_select "form", :action => crops_path(@crop), :method => "post" do
- assert_select "input#crop_name", :name => "crop[name]"
- assert_select "input#crop_en_wikipedia_url", :name => "crop[en_wikipedia_url]"
- end
- end
-
- it "shows three fields for scientific_name" do
- assert_select "input#crop_scientific_names_attributes_0_scientific_name", :count => 1
- assert_select "input#crop_scientific_names_attributes_1_scientific_name", :count => 1
- assert_select "input#crop_scientific_names_attributes_2_scientific_name", :count => 1
- end
end
diff --git a/spec/views/crops/hierarchy.html.haml_spec.rb b/spec/views/crops/hierarchy.html.haml_spec.rb
index 22b02d18f..32bfc4248 100644
--- a/spec/views/crops/hierarchy.html.haml_spec.rb
+++ b/spec/views/crops/hierarchy.html.haml_spec.rb
@@ -1,15 +1,31 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/hierarchy" do
before(:each) do
controller.stub(:current_user) { nil }
@tomato = FactoryGirl.create(:tomato)
- @roma = FactoryGirl.create(:crop, :name => 'Roma tomato', :parent => @tomato)
+ @roma = FactoryGirl.create(:crop, name: 'Roma tomato', parent: @tomato)
assign(:crops, [@tomato, @roma])
render
end
it "shows crop hierarchy" do
- assert_select "ul>li>ul>li", :text => @roma.name
+ assert_select "ul>li>ul>li", text: @roma.name
end
end
diff --git a/spec/views/crops/index.html.haml_spec.rb b/spec/views/crops/index.html.haml_spec.rb
index 33ab3e07e..0a779241d 100644
--- a/spec/views/crops/index.html.haml_spec.rb
+++ b/spec/views/crops/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/index" do
@@ -16,16 +32,16 @@ describe "crops/index" do
end
it "shows photos where available" do
- @planting = FactoryGirl.create(:planting, :crop => @tomato)
+ @planting = FactoryGirl.create(:planting, crop: @tomato)
@photo = FactoryGirl.create(:photo)
@planting.photos << @photo
render
- assert_select "img", :src => @photo.thumbnail_url
+ assert_select "img", src: @photo.thumbnail_url
end
it "linkifies crop images" do
render
- assert_select "img", :src => :tomato
+ assert_select "img", src: :tomato
end
context "logged in and crop wrangler" do
@@ -45,9 +61,9 @@ describe "crops/index" do
it "offers data downloads" do
render
rendered.should have_content "The data on this page is available in the following formats:"
- assert_select "a", :href => crops_path(:format => 'csv')
- assert_select "a", :href => crops_path(:format => 'json')
- assert_select "a", :href => crops_path(:format => 'rss')
+ assert_select "a", href: crops_path(format: 'csv')
+ assert_select "a", href: crops_path(format: 'json')
+ assert_select "a", href: crops_path(format: 'rss')
end
end
end
diff --git a/spec/views/crops/index.rss.haml_spec.rb b/spec/views/crops/index.rss.haml_spec.rb
index 0e8887411..b07eab95a 100644
--- a/spec/views/crops/index.rss.haml_spec.rb
+++ b/spec/views/crops/index.rss.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe 'crops/index.rss.haml' do
diff --git a/spec/views/crops/new.html.haml_spec.rb b/spec/views/crops/new.html.haml_spec.rb
index 0c834d738..3e217f7d2 100644
--- a/spec/views/crops/new.html.haml_spec.rb
+++ b/spec/views/crops/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/new" do
@@ -13,23 +29,8 @@ describe "crops/new" do
render
end
- it "renders new crop form" do
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => crops_path, :method => "post" do
- assert_select "input#crop_name", :name => "crop[name]"
- assert_select "input#crop_en_wikipedia_url", :name => "crop[en_wikipedia_url]"
- assert_select "select#crop_parent_id", :name => "crop[parent_id]"
- end
- end
-
it "shows a link to crop wrangling guidelines" do
assert_select "a[href^=http://wiki.growstuff.org]", "crop wrangling guide"
end
- it "shows three fields for scientific_name" do
- assert_select "input#crop_scientific_names_attributes_0_scientific_name", :count => 1
- assert_select "input#crop_scientific_names_attributes_1_scientific_name", :count => 1
- assert_select "input#crop_scientific_names_attributes_2_scientific_name", :count => 1
- end
-
end
diff --git a/spec/views/crops/wrangle.html.haml_spec.rb b/spec/views/crops/wrangle.html.haml_spec.rb
index 4426382d2..e4f41b8c8 100644
--- a/spec/views/crops/wrangle.html.haml_spec.rb
+++ b/spec/views/crops/wrangle.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "crops/wrangle" do
@@ -24,13 +40,13 @@ describe "crops/wrangle" do
it 'has a link to add a crop' do
render
- assert_select "a", :href => new_crop_path
+ assert_select "a", href: new_crop_path
end
it "renders a list of crops" do
render
- assert_select "a", :text => @maize.name
- assert_select "a", :text => @tomato.name
+ assert_select "a", text: @maize.name
+ assert_select "a", text: @tomato.name
end
end
diff --git a/spec/views/devise/confirmations/new_spec.rb b/spec/views/devise/confirmations/new_spec.rb
index 1e1555db3..8d567d793 100644
--- a/spec/views/devise/confirmations/new_spec.rb
+++ b/spec/views/devise/confirmations/new_spec.rb
@@ -1,4 +1,4 @@
-describe 'devise/confirmations/new.html.haml', :type => "view" do
+describe 'devise/confirmations/new.html.haml', type: "view" do
before(:each) do
@view.stub(:resource).and_return(Member.new)
diff --git a/spec/views/devise/mailer/confirmation_instructions_spec.rb b/spec/views/devise/mailer/confirmation_instructions_spec.rb
index e42dd762c..6f60268e4 100644
--- a/spec/views/devise/mailer/confirmation_instructions_spec.rb
+++ b/spec/views/devise/mailer/confirmation_instructions_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/mailer/confirmation_instructions.html.haml', :type => "view" do
+describe 'devise/mailer/confirmation_instructions.html.haml', type: "view" do
context "logged in" do
before(:each) do
diff --git a/spec/views/devise/mailer/reset_password_instructions_spec.rb b/spec/views/devise/mailer/reset_password_instructions_spec.rb
index d75f69881..91c46a696 100644
--- a/spec/views/devise/mailer/reset_password_instructions_spec.rb
+++ b/spec/views/devise/mailer/reset_password_instructions_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/mailer/reset_password_instructions.html.haml', :type => "view" do
+describe 'devise/mailer/reset_password_instructions.html.haml', type: "view" do
context "logged in" do
before(:each) do
diff --git a/spec/views/devise/mailer/unlock_instructions_spec.rb b/spec/views/devise/mailer/unlock_instructions_spec.rb
index fd4c444f8..5c90260c5 100644
--- a/spec/views/devise/mailer/unlock_instructions_spec.rb
+++ b/spec/views/devise/mailer/unlock_instructions_spec.rb
@@ -1,5 +1,21 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/mailer/unlock_instructions.html.haml', :type => "view" do
+describe 'devise/mailer/unlock_instructions.html.haml', type: "view" do
context "logged in" do
before(:each) do
@resource = FactoryGirl.create(:member)
diff --git a/spec/views/devise/registrations/edit_spec.rb b/spec/views/devise/registrations/edit_spec.rb
index c99b84aed..8fb096255 100644
--- a/spec/views/devise/registrations/edit_spec.rb
+++ b/spec/views/devise/registrations/edit_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/registrations/edit.html.haml', :type => "view" do
+describe 'devise/registrations/edit.html.haml', type: "view" do
context "logged in" do
before(:each) do
@@ -42,11 +58,11 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do
end
it "contains a gravatar icon" do
- assert_select "img", :src => /gravatar\.com\/avatar/
+ assert_select "img", src: /gravatar\.com\/avatar/
end
it 'contains a link to gravatar.com' do
- assert_select "a", :href => /gravatar\.com/
+ assert_select "a", href: /gravatar\.com/
end
it 'shows bio field' do
@@ -68,15 +84,15 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do
end
context 'connected to twitter' do
before(:each) do
- @twitter_auth = FactoryGirl.create(:authentication, :member => @member)
+ @twitter_auth = FactoryGirl.create(:authentication, member: @member)
render
end
it 'has a link to twitter profile' do
- assert_select "a", :href => "http://twitter.com/#{@twitter_auth.name}"
+ assert_select "a", href: "http://twitter.com/#{@twitter_auth.name}"
end
it 'has a link to disconnect' do
render
- assert_select "a", :href => @twitter_auth, :text => "Disconnect"
+ assert_select "a", href: @twitter_auth, text: "Disconnect"
end
end
@@ -88,15 +104,15 @@ describe 'devise/registrations/edit.html.haml', :type => "view" do
end
context 'connected to flickr' do
before(:each) do
- @flickr_auth = FactoryGirl.create(:flickr_authentication, :member => @member)
+ @flickr_auth = FactoryGirl.create(:flickr_authentication, member: @member)
render
end
it 'has a link to flickr photostream' do
- assert_select "a", :href => "http://flickr.com/photos/#{@flickr_auth.uid}"
+ assert_select "a", href: "http://flickr.com/photos/#{@flickr_auth.uid}"
end
it 'has a link to disconnect' do
render
- assert_select "a", :href => @flickr_auth, :text => "Disconnect"
+ assert_select "a", href: @flickr_auth, text: "Disconnect"
end
end
diff --git a/spec/views/devise/registrations/new_spec.rb b/spec/views/devise/registrations/new_spec.rb
index f7dcfffe1..5d6d8ac5a 100644
--- a/spec/views/devise/registrations/new_spec.rb
+++ b/spec/views/devise/registrations/new_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/registrations/new.html.haml', :type => "view" do
+describe 'devise/registrations/new.html.haml', type: "view" do
context "logged in" do
before(:each) do
diff --git a/spec/views/devise/sessions/new_spec.rb b/spec/views/devise/sessions/new_spec.rb
index 6d66e6a48..674e92978 100644
--- a/spec/views/devise/sessions/new_spec.rb
+++ b/spec/views/devise/sessions/new_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/sessions/new.html.haml', :type => "view" do
+describe 'devise/sessions/new.html.haml', type: "view" do
context "logged in" do
before(:each) do
diff --git a/spec/views/devise/shared/_links_spec.rb b/spec/views/devise/shared/_links_spec.rb
index 41f9b45ef..7e71bbc12 100644
--- a/spec/views/devise/shared/_links_spec.rb
+++ b/spec/views/devise/shared/_links_spec.rb
@@ -1,28 +1,26 @@
-describe 'devise/shared/_links.haml', :type => "view" do
+describe 'devise/shared/_links.haml', type: "view" do
def devise_mapping(register, recover, confirm, lock, oauth)
dm = double("mappings")
- dm.stub(:registerable? => register)
- dm.stub(:recoverable? => recover)
- dm.stub(:confirmable? => confirm)
- dm.stub(:lockable? => lock)
- dm.stub(:omniauthable? => oauth)
+ dm.stub(registerable?: register)
+ dm.stub(recoverable?: recover)
+ dm.stub(confirmable?: confirm)
+ dm.stub(lockable?: lock)
+ dm.stub(omniauthable?: oauth)
return dm
end
it 'should have a sign-in link if not in sessions' do
@view.stub(:controller_name).and_return("anything but sessions")
@view.stub(:resource_name).and_return("member")
- @view.stub(:devise_mapping =>
- devise_mapping(false, false, false, false, false))
+ @view.stub(devise_mapping: devise_mapping(false, false, false, false, false))
render
end
it "shouldn't have a sign-in link if in sessions" do
@view.stub(:controller_name).and_return("sessions")
@view.stub(:resource_name).and_return("member")
- @view.stub(:devise_mapping =>
- devise_mapping(false, false, false, false, false))
+ @view.stub(devise_mapping: devise_mapping(false, false, false, false, false))
render
end
end
diff --git a/spec/views/devise/unlocks/new_spec.rb b/spec/views/devise/unlocks/new_spec.rb
index fec998c4d..e145900e4 100644
--- a/spec/views/devise/unlocks/new_spec.rb
+++ b/spec/views/devise/unlocks/new_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'devise/unlocks/new.html.haml', :type => "view" do
+describe 'devise/unlocks/new.html.haml', type: "view" do
context "logged in" do
before(:each) do
diff --git a/spec/views/forums/edit.html.haml_spec.rb b/spec/views/forums/edit.html.haml_spec.rb
index 8a49b38be..e3c874519 100644
--- a/spec/views/forums/edit.html.haml_spec.rb
+++ b/spec/views/forums/edit.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "forums/edit" do
before(:each) do
@forum = assign(:forum, stub_model(Forum,
- :name => "MyString",
- :description => "MyText",
- :owner_id => 1
+ name: "MyString",
+ description: "MyText",
+ owner_id: 1
))
end
@@ -13,10 +29,10 @@ describe "forums/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => forums_path(@forum), :method => "post" do
- assert_select "input#forum_name", :name => "forum[name]"
- assert_select "textarea#forum_description", :name => "forum[description]"
- assert_select "select#forum_owner_id", :name => "forum[owner_id]"
+ assert_select "form", action: forums_path(@forum), method: "post" do
+ assert_select "input#forum_name", name: "forum[name]"
+ assert_select "textarea#forum_description", name: "forum[description]"
+ assert_select "select#forum_owner_id", name: "forum[owner_id]"
end
end
end
diff --git a/spec/views/forums/index.html.haml_spec.rb b/spec/views/forums/index.html.haml_spec.rb
index a946c2407..dc1bdba58 100644
--- a/spec/views/forums/index.html.haml_spec.rb
+++ b/spec/views/forums/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "forums/index" do
@@ -11,7 +27,7 @@ describe "forums/index" do
it "renders a list of forums" do
render
- assert_select "h2", :text => @forum1.name, :count => 2
+ assert_select "h2", text: @forum1.name, count: 2
end
it "doesn't display posts for empty forums" do
@@ -21,19 +37,19 @@ describe "forums/index" do
context "posts" do
before(:each) do
- @post = FactoryGirl.create(:forum_post, :forum => @forum1)
- @comment = FactoryGirl.create(:comment, :post => @post)
+ @post = FactoryGirl.create(:forum_post, forum: @forum1)
+ @comment = FactoryGirl.create(:comment, post: @post)
render
end
it "displays posts" do
assert_select "table"
rendered.should have_content @post.subject
- rendered.should have_content "less than a minute ago"
+ rendered.should have_content Time.zone.today.to_s(:short)
end
it "displays comment count" do
- assert_select "td", :text => "1"
+ assert_select "td", text: "1"
end
end
diff --git a/spec/views/forums/new.html.haml_spec.rb b/spec/views/forums/new.html.haml_spec.rb
index 86043eb8c..59988ae90 100644
--- a/spec/views/forums/new.html.haml_spec.rb
+++ b/spec/views/forums/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "forums/new" do
@@ -7,10 +23,10 @@ describe "forums/new" do
end
it "renders new forum form" do
- assert_select "form", :action => forums_path, :method => "post" do
- assert_select "input#forum_name", :name => "forum[name]"
- assert_select "textarea#forum_description", :name => "forum[description]"
- assert_select "select#forum_owner_id", :name => "forum[owner_id]"
+ assert_select "form", action: forums_path, method: "post" do
+ assert_select "input#forum_name", name: "forum[name]"
+ assert_select "textarea#forum_description", name: "forum[description]"
+ assert_select "select#forum_owner_id", name: "forum[owner_id]"
end
end
end
diff --git a/spec/views/forums/show.html.haml_spec.rb b/spec/views/forums/show.html.haml_spec.rb
index 45ff9aeed..a012c248e 100644
--- a/spec/views/forums/show.html.haml_spec.rb
+++ b/spec/views/forums/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "forums/show" do
@@ -19,7 +35,7 @@ describe "forums/show" do
it 'links to new post with the forum id' do
render
- assert_select "a[href=#{new_post_path(:forum_id => @forum.id)}]"
+ assert_select "a[href=#{new_post_path(forum_id: @forum.id)}]"
end
it 'has no posts' do
@@ -28,7 +44,7 @@ describe "forums/show" do
end
it 'shows posts' do
- @post = FactoryGirl.create(:post, :forum => @forum)
+ @post = FactoryGirl.create(:post, forum: @forum)
render
assert_select "table"
rendered.should have_content @post.subject
diff --git a/spec/views/gardens/edit.html.haml_spec.rb b/spec/views/gardens/edit.html.haml_spec.rb
index e5381c324..959600d77 100644
--- a/spec/views/gardens/edit.html.haml_spec.rb
+++ b/spec/views/gardens/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "gardens/edit" do
@@ -7,7 +23,7 @@ describe "gardens/edit" do
@owner = FactoryGirl.create(:member)
sign_in @owner
controller.stub(:current_user) { @owner }
- @garden = assign(:garden, FactoryGirl.create(:garden, :owner => @owner))
+ @garden = assign(:garden, FactoryGirl.create(:garden, owner: @owner))
render
end
@@ -15,13 +31,13 @@ describe "gardens/edit" do
render
# 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]"
- assert_select "input#garden_location", :name => "garden[location]"
- assert_select "input#garden_area", :name => "garden[area]"
- assert_select "select#garden_area_unit", :name => "garden[area_unit]"
- assert_select "input#garden_active", :name => "garden[active]"
+ 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]"
+ assert_select "input#garden_location", name: "garden[location]"
+ assert_select "input#garden_area", name: "garden[area]"
+ assert_select "select#garden_area_unit", name: "garden[area_unit]"
+ assert_select "input#garden_active", name: "garden[active]"
end
end
end
diff --git a/spec/views/gardens/index.html.haml_spec.rb b/spec/views/gardens/index.html.haml_spec.rb
deleted file mode 100644
index a075822be..000000000
--- a/spec/views/gardens/index.html.haml_spec.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-require 'rails_helper'
-
-describe "gardens/index" do
- before(:each) do
- controller.stub(:current_user) { nil }
- @owner = FactoryGirl.create(:member)
- @garden = FactoryGirl.create(:garden, :owner => @owner)
- page = 1
- per_page = 2
- total_entries = 2
- gardens = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
- pager.replace([@garden, @garden])
- end
- assign(:gardens, gardens)
- end
-
- it "renders a list of gardens" do
- render
- # Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => @garden.name, :count => 2
- assert_select "tr>td>a", :text => @garden.location, :count => 2
- assert_select "tr>td", :text => pluralize(@garden.area, @garden.area_unit), :count => 2
- end
-
-end
diff --git a/spec/views/gardens/new.html.haml_spec.rb b/spec/views/gardens/new.html.haml_spec.rb
index ff52f1f28..84b689eb0 100644
--- a/spec/views/gardens/new.html.haml_spec.rb
+++ b/spec/views/gardens/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "gardens/new" do
@@ -5,19 +21,19 @@ describe "gardens/new" do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_user) { @member }
- @garden = FactoryGirl.create(:garden, :owner => @member)
+ @garden = FactoryGirl.create(:garden, owner: @member)
assign(:garden, @garden)
render
end
it "renders new garden form" do
- 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]"
- assert_select "input#garden_location", :name => "garden[location]"
- assert_select "input#garden_area", :name => "garden[area]"
- assert_select "select#garden_area_unit", :name => "garden[area_unit]"
- assert_select "input#garden_active", :name => "garden[active]"
+ 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]"
+ assert_select "input#garden_location", name: "garden[location]"
+ assert_select "input#garden_area", name: "garden[area]"
+ assert_select "select#garden_area_unit", name: "garden[area_unit]"
+ assert_select "input#garden_active", name: "garden[active]"
end
end
end
diff --git a/spec/views/gardens/show.html.haml_spec.rb b/spec/views/gardens/show.html.haml_spec.rb
index 6327073ee..3753e075e 100644
--- a/spec/views/gardens/show.html.haml_spec.rb
+++ b/spec/views/gardens/show.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "gardens/show" do
before(:each) do
@owner = FactoryGirl.create(:member)
controller.stub(:current_user) { @owner }
- @garden = FactoryGirl.create(:garden, :owner => @owner)
- @planting = FactoryGirl.create(:planting, :garden => @garden)
+ @garden = FactoryGirl.create(:garden, owner: @owner)
+ @planting = FactoryGirl.create(:planting, garden: @garden)
assign(:garden, @garden)
render
end
diff --git a/spec/views/harvests/edit.html.haml_spec.rb b/spec/views/harvests/edit.html.haml_spec.rb
index 4802bab88..f318e3a79 100644
--- a/spec/views/harvests/edit.html.haml_spec.rb
+++ b/spec/views/harvests/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "harvests/edit" do
@@ -7,15 +23,15 @@ describe "harvests/edit" do
end
it "renders new harvest form" do
- assert_select "form", :action => harvests_path, :method => "post" do
- assert_select "input#crop", :class => "ui-autocomplete-input"
- assert_select "input#harvest_crop_id", :name => "harvest[crop_id]"
- assert_select "select#harvest_plant_part_id", :name => "harvest[plant_part_id]"
- assert_select "input#harvest_quantity", :name => "harvest[quantity]"
- assert_select "input#harvest_weight_quantity", :name => "harvest[quantity]"
- assert_select "select#harvest_unit", :name => "harvest[unit]"
- assert_select "select#harvest_weight_unit", :name => "harvest[unit]"
- assert_select "textarea#harvest_description", :name => "harvest[description]"
+ assert_select "form", action: harvests_path, method: "post" do
+ assert_select "input#crop", class: "ui-autocomplete-input"
+ assert_select "input#harvest_crop_id", name: "harvest[crop_id]"
+ assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]"
+ assert_select "input#harvest_quantity", name: "harvest[quantity]"
+ assert_select "input#harvest_weight_quantity", name: "harvest[quantity]"
+ assert_select "select#harvest_unit", name: "harvest[unit]"
+ assert_select "select#harvest_weight_unit", name: "harvest[unit]"
+ assert_select "textarea#harvest_description", name: "harvest[description]"
end
end
end
diff --git a/spec/views/harvests/index.html.haml_spec.rb b/spec/views/harvests/index.html.haml_spec.rb
index 8751a5c41..923b3fb39 100644
--- a/spec/views/harvests/index.html.haml_spec.rb
+++ b/spec/views/harvests/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "harvests/index" do
@@ -13,13 +29,13 @@ describe "harvests/index" do
harvests = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
FactoryGirl.create(:harvest,
- :crop => @tomato,
- :owner => @member
+ crop: @tomato,
+ owner: @member
),
FactoryGirl.create(:harvest,
- :crop => @maize,
- :plant_part => @pp,
- :owner => @member
+ crop: @maize,
+ plant_part: @pp,
+ owner: @member
)
])
end
@@ -27,19 +43,11 @@ describe "harvests/index" do
render
end
- it "renders a list of harvests" do
- render
- assert_select "tr>td", :text => @member.login_name
- assert_select "tr>td", :text => @tomato.name
- assert_select "tr>td", :text => @maize.name
- assert_select "tr>td", :text => @pp.name
- end
-
it "provides data links" do
render
rendered.should have_content "The data on this page is available in the following formats:"
- assert_select "a", :href => harvests_path(:format => 'csv')
- assert_select "a", :href => harvests_path(:format => 'json')
+ assert_select "a", href: harvests_path(format: 'csv')
+ assert_select "a", href: harvests_path(format: 'json')
end
it "displays member's name in title" do
diff --git a/spec/views/harvests/new.html.haml_spec.rb b/spec/views/harvests/new.html.haml_spec.rb
index 93a595188..20a908310 100644
--- a/spec/views/harvests/new.html.haml_spec.rb
+++ b/spec/views/harvests/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "harvests/new" do
@@ -7,16 +23,16 @@ describe "harvests/new" do
end
it "renders new harvest form" do
- assert_select "form", :action => harvests_path, :method => "post" do
- assert_select "input#crop", :class => "ui-autocomplete-input"
- assert_select "input#harvest_crop_id", :name => "harvest[crop_id]"
- assert_select "select#harvest_plant_part_id", :name => "harvest[plant_part_id]"
+ assert_select "form", action: harvests_path, method: "post" do
+ assert_select "input#crop", class: "ui-autocomplete-input"
+ assert_select "input#harvest_crop_id", name: "harvest[crop_id]"
+ assert_select "select#harvest_plant_part_id", name: "harvest[plant_part_id]"
# some browsers interpret without a step as "integer"
- assert_select "input#harvest_quantity[step=any]", :name => "harvest[quantity]"
- assert_select "input#harvest_weight_quantity[step=any]", :name => "harvest[quantity]"
- assert_select "select#harvest_unit", :name => "harvest[unit]"
- assert_select "select#harvest_weight_unit", :name => "harvest[unit]"
- assert_select "textarea#harvest_description", :name => "harvest[description]"
+ assert_select "input#harvest_quantity[step=any]", name: "harvest[quantity]"
+ assert_select "input#harvest_weight_quantity[step=any]", name: "harvest[quantity]"
+ assert_select "select#harvest_unit", name: "harvest[unit]"
+ assert_select "select#harvest_weight_unit", name: "harvest[unit]"
+ assert_select "textarea#harvest_description", name: "harvest[description]"
end
end
end
diff --git a/spec/views/harvests/show.html.haml_spec.rb b/spec/views/harvests/show.html.haml_spec.rb
index 7c897a684..91014941b 100644
--- a/spec/views/harvests/show.html.haml_spec.rb
+++ b/spec/views/harvests/show.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "harvests/show" do
before(:each) do
controller.stub(:current_user) { nil }
@crop = FactoryGirl.create(:tomato)
- @harvest = assign(:harvest, FactoryGirl.create(:harvest, :crop => @crop))
+ @harvest = assign(:harvest, FactoryGirl.create(:harvest, crop: @crop))
render
end
diff --git a/spec/views/home/_blurb.html.haml_spec.rb b/spec/views/home/_blurb.html.haml_spec.rb
index 285363e5e..94e7550d1 100644
--- a/spec/views/home/_blurb.html.haml_spec.rb
+++ b/spec/views/home/_blurb.html.haml_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'home/_blurb.html.haml', :type => "view" do
+describe 'home/_blurb.html.haml', type: "view" do
context 'signed out' do
before :each do
controller.stub(:current_user) { nil }
@@ -13,12 +29,12 @@ describe 'home/_blurb.html.haml', :type => "view" do
it 'has signup section' do
assert_select "div.signup"
- assert_select "a", :href => new_member_registration_path
+ assert_select "a", href: new_member_registration_path
end
it 'has a link to sign in' do
rendered.should have_content "Or sign in if you already have an account"
- assert_select "a", :href => new_member_session_path
+ assert_select "a", href: new_member_session_path
end
end
diff --git a/spec/views/home/_crops.html.haml_spec.rb b/spec/views/home/_crops.html.haml_spec.rb
index 548e0a375..08b0cba01 100644
--- a/spec/views/home/_crops.html.haml_spec.rb
+++ b/spec/views/home/_crops.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'home/_crops.html.haml', :type => "view" do
+describe 'home/_crops.html.haml', type: "view" do
before(:each) do
# we need to set up an "interesting" crop
@crop = FactoryGirl.create(:crop)
(1..3).each do
- @planting = FactoryGirl.create(:planting, :crop => @crop)
+ @planting = FactoryGirl.create(:planting, crop: @crop)
end
@photo = FactoryGirl.create(:photo)
(1..3).each do
@@ -15,20 +31,20 @@ describe 'home/_crops.html.haml', :type => "view" do
end
it 'shows crops section' do
- assert_select 'h2', :text => 'Some of our crops'
+ assert_select 'h2', text: 'Some of our crops'
assert_select "a[href=#{crop_path(@crop)}]"
end
it 'shows plantings section' do
- assert_select 'h2', :text => 'Recently planted'
+ assert_select 'h2', text: 'Recently planted'
rendered.should have_content @planting.location
end
it 'shows recently added crops' do
- assert_select 'h2', :text => 'Recently planted'
+ assert_select 'h2', text: 'Recently planted'
end
it 'includes a link to all crops' do
- assert_select "a[href=#{crops_path}]", :text => /View all crops/
+ assert_select "a[href=#{crops_path}]", text: /View all crops/
end
end
diff --git a/spec/views/home/_members.html.haml_spec.rb b/spec/views/home/_members.html.haml_spec.rb
index 81f812a94..f208c1bde 100644
--- a/spec/views/home/_members.html.haml_spec.rb
+++ b/spec/views/home/_members.html.haml_spec.rb
@@ -1,12 +1,28 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'home/_members.html.haml', :type => "view" do
+describe 'home/_members.html.haml', type: "view" do
before(:each) do
@member = FactoryGirl.create(:london_member)
@member.updated_at = 2.days.ago
assign(:members, [@member])
- @planting = FactoryGirl.create(:planting, :owner => @member)
+ @planting = FactoryGirl.create(:planting, owner: @member)
render
end
diff --git a/spec/views/home/_seeds.html.haml_spec.rb b/spec/views/home/_seeds.html.haml_spec.rb
index 82efa194d..6cbd276f7 100644
--- a/spec/views/home/_seeds.html.haml_spec.rb
+++ b/spec/views/home/_seeds.html.haml_spec.rb
@@ -1,9 +1,25 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'home/_seeds.html.haml', :type => "view" do
+describe 'home/_seeds.html.haml', type: "view" do
before(:each) do
@owner = FactoryGirl.create(:london_member)
- @seed = FactoryGirl.create(:tradable_seed, :owner => @owner)
+ @seed = FactoryGirl.create(:tradable_seed, owner: @owner)
render
end
@@ -13,10 +29,10 @@ describe 'home/_seeds.html.haml', :type => "view" do
it 'lists seeds' do
assert_select "table"
- assert_select 'a', :href => crop_path(@seed.crop)
- assert_select 'a', :href => crop_path(@seed.owner)
+ assert_select 'a', href: crop_path(@seed.crop)
+ assert_select 'a', href: crop_path(@seed.owner)
assert_select 'td', @seed.tradable_to
assert_select 'td', @seed.owner.location
- assert_select 'a', :href => seed_path(@seed)
+ assert_select 'a', href: seed_path(@seed)
end
end
diff --git a/spec/views/home/_stats.html.haml_spec.rb b/spec/views/home/_stats.html.haml_spec.rb
index b067e44f8..0eeaf66f8 100644
--- a/spec/views/home/_stats.html.haml_spec.rb
+++ b/spec/views/home/_stats.html.haml_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'home/_stats.html.haml', :type => "view" do
+describe 'home/_stats.html.haml', type: "view" do
it 'has activity stats' do
render
rendered.should have_content "So far, 0 members have planted 0 crops"
diff --git a/spec/views/home/index_spec.rb b/spec/views/home/index_spec.rb
index fe651e149..84dd65bde 100644
--- a/spec/views/home/index_spec.rb
+++ b/spec/views/home/index_spec.rb
@@ -1,15 +1,31 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'home/index.html.haml', :type => "view" do
+describe 'home/index.html.haml', type: "view" do
before(:each) do
@member = FactoryGirl.create(:london_member)
@member.updated_at = 2.days.ago
assign(:interesting_members, [@member])
- @post = FactoryGirl.create(:post, :author => @member)
+ @post = FactoryGirl.create(:post, author: @member)
assign(:posts, [@post])
- @planting = FactoryGirl.create(:planting, :owner => @member)
+ @planting = FactoryGirl.create(:planting, owner: @member)
assign(:plantings, [@planting])
@crop = FactoryGirl.create(:crop)
diff --git a/spec/views/layouts/_header_spec.rb b/spec/views/layouts/_header_spec.rb
index f4ca3034a..cd531dc71 100644
--- a/spec/views/layouts/_header_spec.rb
+++ b/spec/views/layouts/_header_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'layouts/_header.html.haml', :type => "view" do
+describe 'layouts/_header.html.haml', type: "view" do
context "when not logged in" do
before(:each) do
controller.stub(:current_user) { nil }
@@ -8,7 +24,7 @@ describe 'layouts/_header.html.haml', :type => "view" do
end
it 'shows the brand logo in the navbar' do
- assert_select("img[src='/assets/growstuff-brand.png']", :href => root_path)
+ assert_select("img[src='/assets/growstuff-brand.png']", href: root_path)
end
it 'should have signup/signin links' do
@@ -46,7 +62,7 @@ describe 'layouts/_header.html.haml', :type => "view" do
it 'has a crop search' do
assert_select("form[action=#{crops_search_path}]")
- assert_select("input#search")
+ assert_select("input#term")
end
end
@@ -60,21 +76,21 @@ describe 'layouts/_header.html.haml', :type => "view" do
render
end
- context "your stuff" do
- it 'should have a Your Stuff section' do
- rendered.should have_content "Your Stuff"
+ context "login name" do
+ it 'should have member login name' do
+ rendered.should have_content "#{@member.login_name}"
end
it "should show link to member's gardens" do
- assert_select("a[href=#{gardens_by_owner_path(:owner => @member.slug)}]", "Gardens")
+ assert_select("a[href=#{gardens_by_owner_path(owner: @member.slug)}]", "Gardens")
end
it "should show link to member's plantings" do
- assert_select("a[href=#{plantings_by_owner_path(:owner => @member.slug)}]", "Plantings")
+ assert_select("a[href=#{plantings_by_owner_path(owner: @member.slug)}]", "Plantings")
end
it "should show link to member's seeds" do
- assert_select("a[href=#{seeds_by_owner_path(:owner => @member.slug)}]", "Seeds")
+ assert_select("a[href=#{seeds_by_owner_path(owner: @member.slug)}]", "Seeds")
end
it "should show link to member's posts" do
- assert_select("a[href=#{posts_by_author_path(:author => @member.slug)}]", "Posts")
+ assert_select("a[href=#{posts_by_author_path(author: @member.slug)}]", "Posts")
end
end
@@ -89,7 +105,7 @@ describe 'layouts/_header.html.haml', :type => "view" do
context 'has notifications' do
it 'should show inbox count' do
- FactoryGirl.create(:notification, :recipient => @member)
+ FactoryGirl.create(:notification, recipient: @member)
render
rendered.should have_content 'Inbox (1)'
end
diff --git a/spec/views/layouts/_meta_spec.rb b/spec/views/layouts/_meta_spec.rb
index 8419ea129..8b27d7a8b 100644
--- a/spec/views/layouts/_meta_spec.rb
+++ b/spec/views/layouts/_meta_spec.rb
@@ -1,22 +1,38 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'layouts/_meta.html.haml', :type => "view" do
+describe 'layouts/_meta.html.haml', type: "view" do
before(:each) do
render
end
it 'should have a Posts RSS feed' do
- posts_rss = url_for(:controller => 'posts', :format => 'rss', :only_path => false)
+ posts_rss = url_for(controller: 'posts', format: 'rss', only_path: false)
assert_select "head>link[href=#{posts_rss}]"
end
it 'should have a Crops RSS feed' do
- crops_rss = url_for(:controller => 'crops', :format => 'rss', :only_path => false)
+ crops_rss = url_for(controller: 'crops', format: 'rss', only_path: false)
assert_select "head>link[href=#{crops_rss}]"
end
it 'should have a Plantings RSS feed' do
- plantings_rss = url_for(:controller => 'plantings', :format => 'rss', :only_path => false)
+ plantings_rss = url_for(controller: 'plantings', format: 'rss', only_path: false)
assert_select "head>link[href=#{plantings_rss}]"
end
diff --git a/spec/views/layouts/application_spec.rb b/spec/views/layouts/application_spec.rb
index 45f1e7553..af710ce6f 100644
--- a/spec/views/layouts/application_spec.rb
+++ b/spec/views/layouts/application_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'layouts/application.html.haml', :type => "view" do
+describe 'layouts/application.html.haml', type: "view" do
before(:each) do
controller.stub(:current_user) { nil }
end
@@ -8,7 +24,7 @@ describe 'layouts/application.html.haml', :type => "view" do
it 'includes the analytics code' do
Growstuff::Application.config.analytics_code = ''
render
- assert_select "script", :text => 'alert("foo!")'
+ assert_select "script", text: 'alert("foo!")'
rendered.should_not have_content 'script'
end
diff --git a/spec/views/members/_location.html.haml_spec.rb b/spec/views/members/_location.html.haml_spec.rb
index 54c5d1198..43fb66285 100644
--- a/spec/views/members/_location.html.haml_spec.rb
+++ b/spec/views/members/_location.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "members/_location" do
context "member with location" do
before(:each) do
@member = FactoryGirl.create(:london_member)
- render :partial => 'members/location', :locals => { :member => @member }
+ render partial: 'members/location', locals: { member: @member }
end
it 'shows location if available' do
@@ -12,14 +28,14 @@ describe "members/_location" do
end
it "links to the places page" do
- assert_select "a", :href => place_path(@member.location)
+ assert_select "a", href: place_path(@member.location)
end
end
context "member with no location" do
before(:each) do
@member = FactoryGirl.create(:member)
- render :partial => 'members/location', :locals => { :member => @member }
+ render partial: 'members/location', locals: { member: @member }
end
it 'shows unknown location' do
diff --git a/spec/views/members/index.html.haml_spec.rb b/spec/views/members/index.html.haml_spec.rb
index e9174ffd7..ee1537b77 100644
--- a/spec/views/members/index.html.haml_spec.rb
+++ b/spec/views/members/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "members/index" do
@@ -15,7 +31,7 @@ describe "members/index" do
end
it "contains two gravatar icons" do
- assert_select "img", :src => /gravatar\.com\/avatar/, :count => 2
+ assert_select "img", src: /gravatar\.com\/avatar/, count: 2
end
it 'contains member locations' do
diff --git a/spec/views/members/show.rss.haml_spec.rb b/spec/views/members/show.rss.haml_spec.rb
index e5619cdd6..dcfa0b7b6 100644
--- a/spec/views/members/show.rss.haml_spec.rb
+++ b/spec/views/members/show.rss.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'members/show.rss.haml', :type => "view" do
+describe 'members/show.rss.haml', type: "view" do
before(:each) do
@member = assign(:member, FactoryGirl.create(:member))
- @post1 = FactoryGirl.create(:post, :id => 1, :author => @member)
- @post2 = FactoryGirl.create(:markdown_post, :id => 2, :author => @member)
+ @post1 = FactoryGirl.create(:post, id: 1, author: @member)
+ @post2 = FactoryGirl.create(:markdown_post, id: 2, author: @member)
assign(:posts, [@post1, @post2])
render
end
diff --git a/spec/views/notifications/index.html.haml_spec.rb b/spec/views/notifications/index.html.haml_spec.rb
index 43fd80ede..a7ec6a696 100644
--- a/spec/views/notifications/index.html.haml_spec.rb
+++ b/spec/views/notifications/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "notifications/index" do
@@ -8,28 +24,29 @@ describe "notifications/index" do
context "ordinary notifications" do
before(:each) do
- @notification = FactoryGirl.create(:notification, :sender => @member,
- :recipient => @member)
- assign(:notifications, [ @notification, @notification ])
+ @notification = FactoryGirl.create(:notification, sender: @member,
+ recipient: @member)
+ assign(:notifications, Kaminari.paginate_array([ @notification, @notification ]).page(1))
render
end
+
it "renders a list of notifications" do
assert_select "table"
- assert_select "tr>td", :text => @notification.sender.to_s, :count => 2
- assert_select "tr>td", :text => @notification.subject, :count => 2
+ assert_select "tr>td", text: @notification.sender.to_s, count: 2
+ assert_select "tr>td", text: @notification.subject, count: 2
end
it "links to sender's profile" do
- assert_select "a", :href => member_path(@notification.sender)
+ assert_select "a", href: member_path(@notification.sender)
end
end
context "no subject" do
it "shows (no subject)" do
@notification = FactoryGirl.create(:notification,
- :sender => @member, :recipient => @member, :subject => nil)
- assign(:notifications, [@notification])
+ sender: @member, recipient: @member, subject: nil)
+ assign(:notifications, Kaminari.paginate_array([@notification]).page(1))
render
rendered.should have_content "(no subject)"
end
@@ -38,8 +55,8 @@ describe "notifications/index" do
context "whitespace-only subject" do
it "shows (no subject)" do
@notification = FactoryGirl.create(:notification,
- :sender => @member, :recipient => @member, :subject => " ")
- assign(:notifications, [@notification])
+ sender: @member, recipient: @member, subject: " ")
+ assign(:notifications, Kaminari.paginate_array([@notification]).page(1))
render
rendered.should have_content "(no subject)"
end
diff --git a/spec/views/notifications/new.html.haml_spec.rb b/spec/views/notifications/new.html.haml_spec.rb
index 8b77f6422..b2e6cd125 100644
--- a/spec/views/notifications/new.html.haml_spec.rb
+++ b/spec/views/notifications/new.html.haml_spec.rb
@@ -1,19 +1,35 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "notifications/new" do
before(:each) do
@recipient = FactoryGirl.create(:member)
@sender = FactoryGirl.create(:member)
- assign(:notification, FactoryGirl.create(:notification, :recipient_id => @recipient.id, :sender_id => @sender.id))
+ assign(:notification, FactoryGirl.create(:notification, recipient_id: @recipient.id, sender_id: @sender.id))
sign_in @sender
controller.stub(:current_user) { @sender}
end
it "renders new message form" do
render
- assert_select "form", :action => notifications_path, :method => "notification" do
- assert_select "input#notification_subject", :name => "notification[subject]"
- assert_select "textarea#notification_body", :name => "notification[body]"
+ assert_select "form", action: notifications_path, method: "notification" do
+ assert_select "input#notification_subject", name: "notification[subject]"
+ assert_select "textarea#notification_body", name: "notification[body]"
end
end
@@ -24,18 +40,18 @@ describe "notifications/new" do
it "puts the recipient in a hidden field" do
render
- assert_select "input#notification_recipient_id[type=hidden]", :name => "notification[recipient_id]"
+ assert_select "input#notification_recipient_id[type=hidden]", name: "notification[recipient_id]"
end
it "fills in the subject if provided" do
assign(:subject, 'Foo')
render
- assert_select "input#notification_subject", :value => "Foo"
+ assert_select "input#notification_subject", value: "Foo"
end
it "leaves the subject empty if not provided" do
render
- assert_select "input#notification_subject", :value => ""
+ assert_select "input#notification_subject", value: ""
end
it "Tells you to write your message here" do
diff --git a/spec/views/notifications/show.html.haml_spec.rb b/spec/views/notifications/show.html.haml_spec.rb
index cc33a07e4..42b732ad5 100644
--- a/spec/views/notifications/show.html.haml_spec.rb
+++ b/spec/views/notifications/show.html.haml_spec.rb
@@ -1,9 +1,25 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "notifications/show" do
before(:each) do
@member = FactoryGirl.create(:member)
- @notification = FactoryGirl.create(:notification, :recipient => @member)
+ @notification = FactoryGirl.create(:notification, recipient: @member)
assign(:notification, @notification)
@reply_link = assign(:reply_link, new_notification_path)
controller.stub(:current_user) { @member }
diff --git a/spec/views/notifier/notify.html.haml_spec.rb b/spec/views/notifier/notify.html.haml_spec.rb
index b5740b548..1a4a607bc 100644
--- a/spec/views/notifier/notify.html.haml_spec.rb
+++ b/spec/views/notifier/notify.html.haml_spec.rb
@@ -1,10 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'notifier/notify.html.haml', :type => "view" do
+describe 'notifier/notify.html.haml', type: "view" do
before(:each) do
@notification = FactoryGirl.create(:notification)
@reply_link = "http://example.com"
+ @signed_message = "EncryptedMessage"
assign(:reply_link, @reply_link)
render
end
@@ -19,7 +36,7 @@ describe 'notifier/notify.html.haml', :type => "view" do
end
it 'should include a reply link' do
- assert_select "a[href=#{@reply_link}]", :text => /Reply/
+ assert_select "a[href=#{@reply_link}]", text: /Reply/
end
it 'should contain a link to your inbox' do
@@ -28,8 +45,8 @@ describe 'notifier/notify.html.haml', :type => "view" do
it 'should have fully qualified URLs' do
# lots of lovely fully qualified URLs
- assert_select "a[href^=http]", { :minimum => 4 }
+ assert_select "a[href^=http]", { minimum: 4 }
# no relative URLs starting with /
- assert_select "a[href^=/]", { :count => 0 }
+ assert_select "a[href^=/]", { count: 0 }
end
end
diff --git a/spec/views/orders/index.html.haml_spec.rb b/spec/views/orders/index.html.haml_spec.rb
index ad2116df7..3efdce690 100644
--- a/spec/views/orders/index.html.haml_spec.rb
+++ b/spec/views/orders/index.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "orders/index" do
before(:each) do
@member = FactoryGirl.create(:member)
sign_in @member
- @order1 = FactoryGirl.create(:order, :member => @member)
- @order2 = FactoryGirl.create(:completed_order, :member => @member)
+ @order1 = FactoryGirl.create(:order, member: @member)
+ @order2 = FactoryGirl.create(:completed_order, member: @member)
assign(:orders, [ @order1, @order2 ])
end
@@ -17,7 +33,7 @@ describe "orders/index" do
it "renders a list of orders" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => @order1.id
- assert_select "tr>td", :text => @order2.id
+ assert_select "tr>td", text: @order1.id
+ assert_select "tr>td", text: @order2.id
end
end
diff --git a/spec/views/orders/show.html.haml_spec.rb b/spec/views/orders/show.html.haml_spec.rb
index 98d0eb5e0..c4a2de1cf 100644
--- a/spec/views/orders/show.html.haml_spec.rb
+++ b/spec/views/orders/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "orders/show" do
@@ -10,11 +26,11 @@ describe "orders/show" do
context "current order" do
before(:each) do
- @order = assign(:order, FactoryGirl.create(:order, :member => @member))
+ @order = assign(:order, FactoryGirl.create(:order, member: @member))
@order_item = FactoryGirl.create(:order_item,
- :order => @order,
- :quantity => 2,
- :price => 9900
+ order: @order,
+ quantity: 2,
+ price: 9900
)
render
end
@@ -24,7 +40,7 @@ describe "orders/show" do
end
it "shows order items in a table" do
- assert_select "table>tr>th", :text => "Product"
+ assert_select "table>tr>th", text: "Product"
end
it "shows the total" do
@@ -46,27 +62,27 @@ describe "orders/show" do
end
it "shows a delete order button" do
- assert_select "a", :text => "Delete this order"
+ assert_select "a", text: "Delete this order"
end
end
context "completed order" do
before(:each) do
- @order = assign(:order, FactoryGirl.create(:completed_order, :member => @member))
+ @order = assign(:order, FactoryGirl.create(:completed_order, member: @member))
@order_item = FactoryGirl.create(:order_item,
- :order => @order,
- :quantity => 2,
- :price => 9900
+ order: @order,
+ quantity: 2,
+ price: 9900
)
render
end
it "doesn't show a checkout button" do
- assert_select "a", :text => "Checkout", :count => 0
+ assert_select "a", text: "Checkout", count: 0
end
it "doesn't show delete order button" do
- assert_select "a", :text => "Delete this order", :count => 0
+ assert_select "a", text: "Delete this order", count: 0
end
end
diff --git a/spec/views/photos/edit.html.haml_spec.rb b/spec/views/photos/edit.html.haml_spec.rb
index f3a9a0ed7..6df82b418 100644
--- a/spec/views/photos/edit.html.haml_spec.rb
+++ b/spec/views/photos/edit.html.haml_spec.rb
@@ -1,12 +1,28 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "photos/edit" do
before(:each) do
@photo = assign(:photo, stub_model(Photo,
- :owner_id => 1,
- :flickr_photo_id => 1,
- :thumbnail_url => "MyString",
- :fullsize_url => "MyString"
+ owner_id: 1,
+ flickr_photo_id: 1,
+ thumbnail_url: "MyString",
+ fullsize_url: "MyString"
))
end
diff --git a/spec/views/photos/index.html.haml_spec.rb b/spec/views/photos/index.html.haml_spec.rb
index 5daaa1eda..1741d9aa3 100644
--- a/spec/views/photos/index.html.haml_spec.rb
+++ b/spec/views/photos/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "photos/index" do
@@ -16,7 +32,7 @@ describe "photos/index" do
it "renders a gallery of photos" do
render
- assert_select ".thumbnail", :count => 2
- assert_select "img", :count => 2
+ assert_select ".thumbnail", count: 2
+ assert_select "img", count: 2
end
end
diff --git a/spec/views/photos/new.html.haml_spec.rb b/spec/views/photos/new.html.haml_spec.rb
index 8f0f241e3..46489e87e 100644
--- a/spec/views/photos/new.html.haml_spec.rb
+++ b/spec/views/photos/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "photos/new" do
@@ -11,7 +27,7 @@ describe "photos/new" do
pager.replace([])
end
assign(:photos, photos)
- assign(:flickr_auth, FactoryGirl.create(:flickr_authentication, :member => @member))
+ assign(:flickr_auth, FactoryGirl.create(:flickr_authentication, member: @member))
end
context "user has no photosets" do
diff --git a/spec/views/photos/show.html.haml_spec.rb b/spec/views/photos/show.html.haml_spec.rb
index 5ef9dc9c0..a7e014eac 100644
--- a/spec/views/photos/show.html.haml_spec.rb
+++ b/spec/views/photos/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "photos/show" do
@@ -8,7 +24,7 @@ describe "photos/show" do
context "CC-licensed photo" do
before(:each) do
- @photo = assign(:photo, FactoryGirl.create(:photo, :owner => @member))
+ @photo = assign(:photo, FactoryGirl.create(:photo, owner: @member))
render
end
@@ -17,16 +33,16 @@ describe "photos/show" do
end
it "links to the owner's profile" do
- assert_select "a", :href => @photo.owner
+ assert_select "a", href: @photo.owner
end
it "links to the CC license" do
- assert_select "a", :href => @photo.license_url,
- :text => @photo.license_name
+ assert_select "a", href: @photo.license_url,
+ text: @photo.license_name
end
it "shows a link to the original image" do
- assert_select "a", :href => @photo.link_url, :text => "View on Flickr"
+ assert_select "a", href: @photo.link_url, text: "View on Flickr"
end
it "has a delete button" do
@@ -46,19 +62,4 @@ describe "photos/show" do
end
- context "linked to a planting" do
- before(:each) do
- @photo = FactoryGirl.create(:photo)
- @planting = FactoryGirl.create(:planting)
- @planting.photos << @photo
- @photo = assign(:photo, @photo)
- render
- end
-
- it "shows link to planting" do
- assert_select "a[href=#{planting_path(@planting)}]"
- end
-
- end
-
end
diff --git a/spec/views/places/_map_attribution.html.haml_spec.rb b/spec/views/places/_map_attribution.html.haml_spec.rb
index d85875376..cbb305ed6 100644
--- a/spec/views/places/_map_attribution.html.haml_spec.rb
+++ b/spec/views/places/_map_attribution.html.haml_spec.rb
@@ -1,21 +1,37 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe "places/_map_attribution.html.haml", :type => :view do
+describe "places/_map_attribution.html.haml", type: :view do
before(:each) do
render
end
it "links to OpenStreetMap" do
- assert_select "a", :href => "http://openstreetmap.org",
- :text => "OpenStreetMap"
+ assert_select "a", href: "http://openstreetmap.org",
+ text: "OpenStreetMap"
end
it "links to the ODbL" do
- assert_select "a", :href => "http://www.openstreetmap.org/copyright",
- :text => "ODbL"
+ assert_select "a", href: "http://www.openstreetmap.org/copyright",
+ text: "ODbL"
end
it "links to CloudMade" do
- assert_select "a", :href => "http://cloudmade.com", :text => "CloudMade"
+ assert_select "a", href: "http://cloudmade.com", text: "CloudMade"
end
end
diff --git a/spec/views/places/index.html.haml_spec.rb b/spec/views/places/index.html.haml_spec.rb
index f3a3661ae..10c5caca6 100644
--- a/spec/views/places/index.html.haml_spec.rb
+++ b/spec/views/places/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "places/index" do
diff --git a/spec/views/places/show.html.haml_spec.rb b/spec/views/places/show.html.haml_spec.rb
index 8e3e346c5..7cfa2c16c 100644
--- a/spec/views/places/show.html.haml_spec.rb
+++ b/spec/views/places/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "places/show" do
@@ -15,7 +31,7 @@ describe "places/show" do
end
it "shows the selected place in the textbox" do
- assert_select "#new_place", :value => @place
+ assert_select "#new_place", value: @place
end
it "shows the names of nearby members" do
diff --git a/spec/views/plant_parts/edit.html.haml_spec.rb b/spec/views/plant_parts/edit.html.haml_spec.rb
index 6193ef1b0..1f92923d8 100644
--- a/spec/views/plant_parts/edit.html.haml_spec.rb
+++ b/spec/views/plant_parts/edit.html.haml_spec.rb
@@ -1,9 +1,25 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plant_parts/edit" do
before(:each) do
@plant_part = assign(:plant_part, stub_model(PlantPart,
- :name => "MyString"
+ name: "MyString"
))
end
@@ -11,8 +27,8 @@ describe "plant_parts/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => plant_parts_path(@plant_part), :method => "post" do
- assert_select "input#plant_part_name", :name => "plant_part[name]"
+ assert_select "form", action: plant_parts_path(@plant_part), method: "post" do
+ assert_select "input#plant_part_name", name: "plant_part[name]"
end
end
end
diff --git a/spec/views/plant_parts/index.html.haml_spec.rb b/spec/views/plant_parts/index.html.haml_spec.rb
index 1a9469c55..1fe26abba 100644
--- a/spec/views/plant_parts/index.html.haml_spec.rb
+++ b/spec/views/plant_parts/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plant_parts/index" do
@@ -10,7 +26,7 @@ describe "plant_parts/index" do
it "renders a list of plant_parts" do
render
rendered.should have_content @pp.name
- assert_select "a", :href => plant_part_path(@pp)
+ assert_select "a", href: plant_part_path(@pp)
end
end
diff --git a/spec/views/plant_parts/new.html.haml_spec.rb b/spec/views/plant_parts/new.html.haml_spec.rb
index d512ecee1..213eee57a 100644
--- a/spec/views/plant_parts/new.html.haml_spec.rb
+++ b/spec/views/plant_parts/new.html.haml_spec.rb
@@ -1,9 +1,25 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plant_parts/new" do
before(:each) do
assign(:plant_part, stub_model(PlantPart,
- :name => "MyString"
+ name: "MyString"
).as_new_record)
end
@@ -11,8 +27,8 @@ describe "plant_parts/new" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => plant_parts_path, :method => "post" do
- assert_select "input#plant_part_name", :name => "plant_part[name]"
+ assert_select "form", action: plant_parts_path, method: "post" do
+ assert_select "input#plant_part_name", name: "plant_part[name]"
end
end
end
diff --git a/spec/views/plant_parts/show.html.haml_spec.rb b/spec/views/plant_parts/show.html.haml_spec.rb
index b65ecb154..7c23b9bb9 100644
--- a/spec/views/plant_parts/show.html.haml_spec.rb
+++ b/spec/views/plant_parts/show.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plant_parts/show" do
before(:each) do
controller.stub(:current_user) { nil }
@pp = FactoryGirl.create(:plant_part)
- @harvest = FactoryGirl.create(:harvest, :plant_part => @pp)
+ @harvest = FactoryGirl.create(:harvest, plant_part: @pp)
assign(:plant_part, @pp)
end
@@ -12,7 +28,7 @@ describe "plant_parts/show" do
render
@pp.crops.each do |c|
rendered.should have_content c.name
- assert_select "a", :href => crop_path(c)
+ assert_select "a", href: crop_path(c)
end
end
end
diff --git a/spec/views/plantings/_form.html.haml_spec.rb b/spec/views/plantings/_form.html.haml_spec.rb
index 88b12bd9e..a8565dfda 100644
--- a/spec/views/plantings/_form.html.haml_spec.rb
+++ b/spec/views/plantings/_form.html.haml_spec.rb
@@ -1,18 +1,34 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plantings/_form" do
before(:each) do
controller.stub(:current_user) { nil }
@member = FactoryGirl.create(:member)
- @garden = FactoryGirl.create(:garden, :owner => @member)
+ @garden = FactoryGirl.create(:garden, owner: @member)
@uppercase = FactoryGirl.create(:uppercasecrop)
@lowercase = FactoryGirl.create(:lowercasecrop)
@crop = @lowercase # needed to render the form
@planting = FactoryGirl.create(:planting,
- :garden => @garden,
- :crop => @crop,
- :planted_at => Date.new(2013, 03, 01)
+ garden: @garden,
+ crop: @crop,
+ planted_at: Date.new(2013, 03, 01)
)
render
end
diff --git a/spec/views/plantings/_thumbnail.html.haml_spec.rb b/spec/views/plantings/_thumbnail.html.haml_spec.rb
deleted file mode 100644
index dd5cc2003..000000000
--- a/spec/views/plantings/_thumbnail.html.haml_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'rails_helper'
-
-describe "plantings/_thumbnail" do
- before(:each) do
- controller.stub(:current_user) { nil }
- @member = FactoryGirl.create(:member)
- @garden = FactoryGirl.create(:garden, :owner => @member)
- @crop = FactoryGirl.create(:tomato)
-
- @planting = FactoryGirl.create(:planting,
- :garden => @garden,
- :crop => @crop
- )
- end
-
- context "simple view" do
- before(:each) do
- render :partial => "thumbnail", :locals => {
- :planting => @planting,
- }
- end
-
- it "renders the quantity planted" do
- rendered.should have_content "33"
- end
-
- it "renders the date planted" do
- rendered.should have_content @planting.planted_at.to_s(:default)
- end
-
- it "shows the name of the crop" do
- rendered.should have_content @crop.name
- end
-
- it "shows the description by default" do
- rendered.should have_content "This is a"
- end
- end
-
- context "with complicated args" do
- before(:each) do
- render :partial => "thumbnail", :locals => {
- :planting => @planting,
- :hide_description => true
- }
- end
-
- it "hides the description if asked" do
- rendered.should_not have_content "This is a"
- end
- end
-
-end
diff --git a/spec/views/plantings/edit.html.haml_spec.rb b/spec/views/plantings/edit.html.haml_spec.rb
index 4cc06fcdc..b71b34d2a 100644
--- a/spec/views/plantings/edit.html.haml_spec.rb
+++ b/spec/views/plantings/edit.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plantings/edit" do
before(:each) do
@member = FactoryGirl.create(:member,
- :login_name => 'right',
- :email => 'right@example.com'
+ login_name: 'right',
+ email: 'right@example.com'
)
# creating two crops to make sure that the correct one is selected
@@ -13,11 +29,11 @@ describe "plantings/edit" do
@maize = FactoryGirl.create(:maize)
# and likewise for gardens
- @garden = FactoryGirl.create(:garden_z, :owner => @member)
- @garden2 = FactoryGirl.create(:garden_a, :owner => @member)
+ @garden = FactoryGirl.create(:garden_z, owner: @member)
+ @garden2 = FactoryGirl.create(:garden_a, owner: @member)
@planting = assign(:planting,
- FactoryGirl.create(:planting, :garden => @garden, :crop => @tomato)
+ FactoryGirl.create(:planting, garden: @garden, crop: @tomato)
)
end
@@ -30,17 +46,16 @@ describe "plantings/edit" do
end
it "renders the edit planting form" do
- assert_select "form", :action => plantings_path(@planting), :method => "post" do
- assert_select "input#planting_quantity", :name => "planting[quantity]"
- assert_select "textarea#planting_description", :name => "planting[description]"
- assert_select "select#planting_sunniness", :name => "planting[sunniness]"
- assert_select "select#planting_planted_from", :name => "planting[planted_from]"
+ assert_select "form", action: plantings_path(@planting), method: "post" do
+ assert_select "input#planting_quantity", name: "planting[quantity]"
+ assert_select "textarea#planting_description", name: "planting[description]"
+ assert_select "select#planting_sunniness", name: "planting[sunniness]"
+ assert_select "select#planting_planted_from", name: "planting[planted_from]"
end
end
it 'includes helpful links for crops and gardens' do
- assert_select "a[href=#{new_garden_path}]", :text => "Add a garden."
- assert_select "a[href=#{Growstuff::Application.config.new_crops_request_link}]", :text => "Request new crops."
+ assert_select "a[href=#{new_garden_path}]", text: "Add a garden."
end
it "chooses the right crop" do
@@ -49,7 +64,7 @@ describe "plantings/edit" do
it "chooses the right garden" do
assert_select "select#planting_garden_id",
- :html => /option selected="selected" value="#{@garden.id}"/
+ html: /option selected="selected" value="#{@garden.id}"/
end
end
diff --git a/spec/views/plantings/index.html.haml_spec.rb b/spec/views/plantings/index.html.haml_spec.rb
index 6a130c8c9..928735dde 100644
--- a/spec/views/plantings/index.html.haml_spec.rb
+++ b/spec/views/plantings/index.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plantings/index" do
before(:each) do
controller.stub(:current_user) { nil }
@member = FactoryGirl.create(:member)
- @garden = FactoryGirl.create(:garden, :owner => @member)
+ @garden = FactoryGirl.create(:garden, owner: @member)
@tomato = FactoryGirl.create(:tomato)
@maize = FactoryGirl.create(:maize)
page = 1
@@ -13,22 +29,22 @@ describe "plantings/index" do
plantings = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
FactoryGirl.create(:planting,
- :garden => @garden,
- :crop => @tomato,
- :owner => @member
+ garden: @garden,
+ crop: @tomato,
+ owner: @member
),
FactoryGirl.create(:planting,
- :garden => @garden,
- :crop => @maize,
- :description => '',
- :planted_at => Time.local(2013, 1, 13)
+ garden: @garden,
+ crop: @maize,
+ description: '',
+ planted_at: Time.local(2013, 1, 13)
),
FactoryGirl.create(:planting,
- :garden => @garden,
- :crop => @tomato,
- :planted_at => Time.local(2013, 1, 13),
- :finished_at => Time.local(2013, 1, 20),
- :finished => true
+ garden: @garden,
+ crop: @tomato,
+ planted_at: Time.local(2013, 1, 13),
+ finished_at: Time.local(2013, 1, 20),
+ finished: true
)
])
end
@@ -54,9 +70,9 @@ describe "plantings/index" do
it "provides data links" do
render
rendered.should have_content "The data on this page is available in the following formats:"
- assert_select "a", :href => plantings_path(:format => 'csv')
- assert_select "a", :href => plantings_path(:format => 'json')
- assert_select "a", :href => plantings_path(:format => 'rss')
+ assert_select "a", href: plantings_path(format: 'csv')
+ assert_select "a", href: plantings_path(format: 'json')
+ assert_select "a", href: plantings_path(format: 'rss')
end
it "displays member's name in title" do
diff --git a/spec/views/plantings/index.rss.haml_spec.rb b/spec/views/plantings/index.rss.haml_spec.rb
index c953382ce..9f3d7ccc1 100644
--- a/spec/views/plantings/index.rss.haml_spec.rb
+++ b/spec/views/plantings/index.rss.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe 'plantings/index.rss.haml' do
diff --git a/spec/views/plantings/new.html.haml_spec.rb b/spec/views/plantings/new.html.haml_spec.rb
index 455b9a411..cd3a95445 100644
--- a/spec/views/plantings/new.html.haml_spec.rb
+++ b/spec/views/plantings/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plantings/new" do
@@ -6,14 +22,14 @@ describe "plantings/new" do
controller.stub(:current_user) { @member }
# create gardens and crops to populate dropdowns
- @garden_a = FactoryGirl.create(:garden, :owner => @member)
- @garden_z = FactoryGirl.create(:garden, :owner => @member)
+ @garden_a = FactoryGirl.create(:garden, owner: @member)
+ @garden_z = FactoryGirl.create(:garden, owner: @member)
@crop1 = FactoryGirl.create(:tomato)
@crop2 = FactoryGirl.create(:maize)
assign(:planting, FactoryGirl.create(:planting,
- :garden => @garden_a,
- :crop => @crop2
+ garden: @garden_a,
+ crop: @crop2
))
end
@@ -28,25 +44,24 @@ describe "plantings/new" do
end
it "renders new planting form" do
- assert_select "form", :action => plantings_path, :method => "post" do
- assert_select "select#planting_garden_id", :name => "planting[garden_id]"
- assert_select "input#crop", :class => "ui-autocomplete-input"
- assert_select "input#planting_crop_id", :name => "planting[crop_id]"
- assert_select "input#planting_quantity", :name => "planting[quantity]"
- assert_select "textarea#planting_description", :name => "planting[description]"
- assert_select "select#planting_sunniness", :name => "planting[sunniness]"
- assert_select "select#planting_planted_from", :name => "planting[planted_from]"
+ assert_select "form", action: plantings_path, method: "post" do
+ assert_select "select#planting_garden_id", name: "planting[garden_id]"
+ assert_select "input#crop", class: "ui-autocomplete-input"
+ assert_select "input#planting_crop_id", name: "planting[crop_id]"
+ assert_select "input#planting_quantity", name: "planting[quantity]"
+ assert_select "textarea#planting_description", name: "planting[description]"
+ assert_select "select#planting_sunniness", name: "planting[sunniness]"
+ assert_select "select#planting_planted_from", name: "planting[planted_from]"
end
end
it 'includes helpful links for crops and gardens' do
- assert_select "a[href=#{new_garden_path}]", :text => "Add a garden."
- assert_select "a[href=#{Growstuff::Application.config.new_crops_request_link}]", :text => "Request new crops."
+ assert_select "a[href=#{new_garden_path}]", text: "Add a garden."
end
it "selects a garden given in a param" do
assert_select "select#planting_garden_id",
- :html => /option selected="selected" value="#{@garden_z.id}"/
+ html: /option selected="selected" value="#{@garden_z.id}"/
end
end
end
diff --git a/spec/views/plantings/show.html.haml_spec.rb b/spec/views/plantings/show.html.haml_spec.rb
index 28a44078a..79faf1d1d 100644
--- a/spec/views/plantings/show.html.haml_spec.rb
+++ b/spec/views/plantings/show.html.haml_spec.rb
@@ -1,12 +1,28 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "plantings/show" do
def create_planting_for(member)
- @garden = FactoryGirl.create(:garden, :owner => @member)
+ @garden = FactoryGirl.create(:garden, owner: @member)
@crop = FactoryGirl.create(:tomato)
@planting = assign(:planting,
- FactoryGirl.create(:planting, :garden => @garden, :crop => @crop,
- :planted_from => 'cutting')
+ FactoryGirl.create(:planting, garden: @garden, crop: @crop,
+ planted_from: 'cutting')
)
end
@@ -28,14 +44,6 @@ describe "plantings/show" do
rendered.should have_content 'Sun or shade?'
rendered.should have_content 'sun'
end
-
- it "doesn't show sunniness if blank" do
- @p.sunniness = ''
- @p.save
- render
- rendered.should_not have_content 'Sun or shade?'
- rendered.should_not have_content 'sun'
- end
end
context 'planted from' do
@@ -59,7 +67,7 @@ describe "plantings/show" do
end
it "shows photos" do
- @photo = FactoryGirl.create(:photo, :owner => @member)
+ @photo = FactoryGirl.create(:photo, owner: @member)
@p.photos << @photo
render
assert_select "img[src=#{@photo.thumbnail_url}]"
diff --git a/spec/views/policy/community_spec.rb b/spec/views/policy/community_spec.rb
deleted file mode 100644
index 17f6d3b11..000000000
--- a/spec/views/policy/community_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'rails_helper'
-
-describe 'policy/community.html.haml', :type => "view" do
- before(:each) do
- render
- end
-
- it 'should show community guidelines' do
- render
- rendered.should have_content 'is a community by and for food-gardeners.'
- end
-end
diff --git a/spec/views/policy/tos_spec.rb b/spec/views/policy/tos_spec.rb
deleted file mode 100644
index 24cacdf0d..000000000
--- a/spec/views/policy/tos_spec.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'rails_helper'
-
-describe 'policy/tos.html.haml', :type => "view" do
- before(:each) do
- render
- end
-
- it 'should show terms of service' do
- render
- rendered.should have_content 'Terms of Service'
- end
-end
diff --git a/spec/views/posts/_single.html.haml_spec.rb b/spec/views/posts/_single.html.haml_spec.rb
index 268db854d..b3a9c0dd9 100644
--- a/spec/views/posts/_single.html.haml_spec.rb
+++ b/spec/views/posts/_single.html.haml_spec.rb
@@ -1,9 +1,25 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "posts/_single" do
def render_post()
- render :partial => "single", :locals => { :post => @post }
+ render partial: "single", locals: { post: @post }
end
before(:each) do
@@ -21,7 +37,7 @@ describe "posts/_single" do
end
it "doesn't contain a link to new comment" do
- assert_select "a[href=#{new_comment_path(:post_id => @post.id)}]", false
+ assert_select "a[href=#{new_comment_path(post_id: @post.id)}]", false
end
end
@@ -34,7 +50,7 @@ describe "posts/_single" do
end
it "contains link to new comment" do
- assert_select "a[href=#{new_comment_path(:post_id => @post.id)}]", "Reply"
+ assert_select "a[href=#{new_comment_path(post_id: @post.id)}]", "Reply"
end
it "does not contain an edit link" do
@@ -47,7 +63,7 @@ describe "posts/_single" do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_user) { @member }
- @post = FactoryGirl.create(:post, :author => @member)
+ @post = FactoryGirl.create(:post, author: @member)
render_post
end
@@ -68,7 +84,7 @@ describe "posts/_single" do
context "when there is 1 comment" do
before(:each) do
- @comment = FactoryGirl.create(:comment, :post => @post)
+ @comment = FactoryGirl.create(:comment, post: @post)
render_post
end
@@ -79,8 +95,8 @@ describe "posts/_single" do
context "when there are 2 comments" do
before(:each) do
- @comment = FactoryGirl.create(:comment, :post => @post)
- @comment2 = FactoryGirl.create(:comment, :post => @post)
+ @comment = FactoryGirl.create(:comment, post: @post)
+ @comment2 = FactoryGirl.create(:comment, post: @post)
render_post
end
@@ -94,9 +110,9 @@ describe "posts/_single" do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_user) { @member }
- @comment = FactoryGirl.create(:comment, :post => @post)
- render :partial => "single", :locals => {
- :post => @post, :hide_comments => true
+ @comment = FactoryGirl.create(:comment, post: @post)
+ render partial: "single", locals: {
+ post: @post, hide_comments: true
}
end
@@ -109,12 +125,79 @@ describe "posts/_single" do
end
it "does not contain link to new comment" do
- assert_select "a[href=#{new_comment_path(:post_id => @post.id)}]", false
+ assert_select "a[href=#{new_comment_path(post_id: @post.id)}]", false
end
end
+
+ context "when post has been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @post.update(body: "I am updated")
+ render_post
+ end
+
+ it "shows edited at" do
+ rendered.should have_content "edited at"
+ end
+
+ it "shows the updated time" do
+ rendered.should have_content @post.updated_at
+ end
+ end
+
+ context "when comment has been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @comment = FactoryGirl.create(:comment, :post => @post)
+ @comment.update(body: "I've been updated")
+ render :partial => "comments/single", :locals => { :comment => @comment }
+ end
+
+ it "shows edited at time" do
+ rendered.should have_content "edited at"
+ end
+
+ it "shows updated time" do
+ rendered.should have_content @comment.updated_at
+ end
+ end
+
+ context "when post has not been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @post.update(updated_at: @post.created_at)
+ render_post
+ end
+
+ it "does not show edited at" do
+ rendered.should_not have_content "edited at #{@post.updated_at}"
+ end
+ end
+
+ context "when comment has not been edited" do
+ before(:each) do
+ @member = FactoryGirl.create(:member)
+ sign_in @member
+ controller.stub(:current_user) { @member }
+ @post = FactoryGirl.create(:post, :author => @member)
+ @comment = FactoryGirl.create(:comment, :post => @post)
+ @comment.update(updated_at: @comment.created_at)
+ render :partial => "comments/single", :locals => { :comment => @comment }
+ end
+
+ it "does not show edited at" do
+ rendered.should_not have_content "edited at #{@comment.updated_at}"
+ end
+ end
+
end
-
-
-
-
diff --git a/spec/views/posts/edit.html.haml_spec.rb b/spec/views/posts/edit.html.haml_spec.rb
index 7b3f0b195..e0a557db6 100644
--- a/spec/views/posts/edit.html.haml_spec.rb
+++ b/spec/views/posts/edit.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "posts/edit" do
before(:each) do
controller.stub(:current_user) { nil }
@author = FactoryGirl.create(:member)
- @post = assign(:post, FactoryGirl.create(:post, :author => @author))
+ @post = assign(:post, FactoryGirl.create(:post, author: @author))
end
context "logged in" do
@@ -14,9 +30,9 @@ describe "posts/edit" do
end
it "renders the edit post form" do
- assert_select "form", :action => posts_path(@post), :method => "post" do
- assert_select "input#post_subject", :name => "post[subject]"
- assert_select "textarea#post_body", :name => "post[body]"
+ assert_select "form", action: posts_path(@post), method: "post" do
+ assert_select "input#post_subject", name: "post[subject]"
+ assert_select "textarea#post_body", name: "post[body]"
end
end
@@ -32,8 +48,8 @@ describe "posts/edit" do
before(:each) do
@forum = assign(:forum, FactoryGirl.create(:forum))
assign(:post, FactoryGirl.create( :post,
- :forum => @forum,
- :author => @author
+ forum: @forum,
+ author: @author
))
render
end
diff --git a/spec/views/posts/index.html.haml_spec.rb b/spec/views/posts/index.html.haml_spec.rb
index d5d49951a..1290cc2c7 100644
--- a/spec/views/posts/index.html.haml_spec.rb
+++ b/spec/views/posts/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "posts/index" do
@@ -9,8 +25,8 @@ describe "posts/index" do
total_entries = 2
posts = WillPaginate::Collection.create(page, per_page, total_entries) do |pager|
pager.replace([
- FactoryGirl.create(:post, :author => @author),
- FactoryGirl.create(:post, :author => @author)
+ FactoryGirl.create(:post, author: @author),
+ FactoryGirl.create(:post, author: @author)
])
end
assign(:posts, posts)
@@ -18,18 +34,18 @@ describe "posts/index" do
end
it "renders a list of posts" do
- assert_select "div.post", :count => 2
- assert_select "h3", :text => "A Post".to_s, :count => 2
+ assert_select "div.post", count: 2
+ assert_select "h3", text: "A Post".to_s, count: 2
assert_select "div.post-body",
- :text => "This is some text.".to_s, :count => 2
+ text: "This is some text.".to_s, count: 2
end
it "contains two gravatar icons" do
- assert_select "img", :src => /gravatar\.com\/avatar/, :count => 2
+ assert_select "img", src: /gravatar\.com\/avatar/, count: 2
end
it "contains RSS feed links for posts and comments" do
- assert_select "a", :href => posts_path(:format => 'rss')
- assert_select "a", :href => comments_path(:format => 'rss')
+ assert_select "a", href: posts_path(format: 'rss')
+ assert_select "a", href: comments_path(format: 'rss')
end
end
diff --git a/spec/views/posts/index.rss.haml_spec.rb b/spec/views/posts/index.rss.haml_spec.rb
index 0a303f19b..496311efc 100644
--- a/spec/views/posts/index.rss.haml_spec.rb
+++ b/spec/views/posts/index.rss.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'posts/index.rss.haml', :type => "view" do
+describe 'posts/index.rss.haml', type: "view" do
before(:each) do
controller.stub(:current_user) { nil }
author = FactoryGirl.create(:member)
- @post1 = FactoryGirl.create(:post, :id => 1, :author => author)
- @post2 = FactoryGirl.create(:post, :id => 2, :author => author)
+ @post1 = FactoryGirl.create(:post, id: 1, author: author)
+ @post2 = FactoryGirl.create(:post, id: 2, author: author)
assign(:posts, [@post1, @post2])
render
end
diff --git a/spec/views/posts/new.html.haml_spec.rb b/spec/views/posts/new.html.haml_spec.rb
index 73448e24c..e9d26ba5e 100644
--- a/spec/views/posts/new.html.haml_spec.rb
+++ b/spec/views/posts/new.html.haml_spec.rb
@@ -1,9 +1,25 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "posts/new" do
before(:each) do
@author = FactoryGirl.create(:member)
- assign(:post, FactoryGirl.create(:post, :author => @author))
+ assign(:post, FactoryGirl.create(:post, author: @author))
# assign(:forum, Forum.new)
sign_in @author
controller.stub(:current_user) { @author }
@@ -11,9 +27,9 @@ describe "posts/new" do
it "renders new post form" do
render
- assert_select "form", :action => posts_path, :method => "post" do
- assert_select "input#post_subject", :name => "post[subject]"
- assert_select "textarea#post_body", :name => "post[body]"
+ assert_select "form", action: posts_path, method: "post" do
+ assert_select "input#post_subject", name: "post[subject]"
+ assert_select "textarea#post_body", name: "post[body]"
end
end
@@ -35,7 +51,7 @@ describe "posts/new" do
context "forum specified" do
before(:each) do
@forum = assign(:forum, FactoryGirl.create(:forum))
- assign(:post, FactoryGirl.create(:post, :forum => @forum))
+ assign(:post, FactoryGirl.create(:post, forum: @forum))
render
end
diff --git a/spec/views/posts/show.html.haml_spec.rb b/spec/views/posts/show.html.haml_spec.rb
index e1ea7a77e..e95d888b8 100644
--- a/spec/views/posts/show.html.haml_spec.rb
+++ b/spec/views/posts/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "posts/show" do
@@ -8,7 +24,7 @@ describe "posts/show" do
it "renders the post" do
@post = assign(:post,
- FactoryGirl.create(:post, :author => @author))
+ FactoryGirl.create(:post, author: @author))
render
# show the name of the member who posted the post
rendered.should match(/member\d+/)
@@ -21,14 +37,14 @@ describe "posts/show" do
it "should parse markdown into html" do
@post = assign(:post,
- FactoryGirl.create(:markdown_post, :author => @author))
+ FactoryGirl.create(:markdown_post, author: @author))
render
assert_select "strong", "strong"
end
it "shouldn't let html through in body" do
@post = assign(:post,
- FactoryGirl.create(:html_post, :author => @author))
+ FactoryGirl.create(:html_post, author: @author))
render
rendered.should match(/EVIL/)
rendered.should_not match(/a href="http:\/\/evil.com"/)
@@ -36,7 +52,7 @@ describe "posts/show" do
it 'has an anchor to the comments' do
@post = assign(:post,
- FactoryGirl.create(:post, :author => @author))
+ FactoryGirl.create(:post, author: @author))
render
assert_select 'a[name=comments]'
end
@@ -44,8 +60,8 @@ describe "posts/show" do
context "when there is one comment" do
before(:each) do
@post = assign(:post,
- FactoryGirl.create(:html_post, :author => @author))
- @comment = FactoryGirl.create(:comment, :post => @post)
+ FactoryGirl.create(:html_post, author: @author))
+ @comment = FactoryGirl.create(:comment, post: @post)
@comments = @post.comments
render
end
@@ -66,14 +82,14 @@ describe "posts/show" do
context "when there is more than one comment" do
before(:each) do
@post = assign(:post,
- FactoryGirl.create(:html_post, :author => @author))
- @comment1 = FactoryGirl.create(:comment, :post => @post, :body => "F1rst!!!",
- :created_at => Date.new(2010, 5, 17))
- @comment3 = FactoryGirl.create(:comment, :post => @post, :body => "Th1rd!!!",
- :created_at => Date.new(2012, 5, 17))
- @comment4 = FactoryGirl.create(:comment, :post => @post, :body => "F0urth!!!")
- @comment2 = FactoryGirl.create(:comment, :post => @post, :body => "S3c0nd!!1!",
- :created_at => Date.new(2011, 5, 17))
+ FactoryGirl.create(:html_post, author: @author))
+ @comment1 = FactoryGirl.create(:comment, post: @post, body: "F1rst!!!",
+ created_at: Date.new(2010, 5, 17))
+ @comment3 = FactoryGirl.create(:comment, post: @post, body: "Th1rd!!!",
+ created_at: Date.new(2012, 5, 17))
+ @comment4 = FactoryGirl.create(:comment, post: @post, body: "F0urth!!!")
+ @comment2 = FactoryGirl.create(:comment, post: @post, body: "S3c0nd!!1!",
+ created_at: Date.new(2011, 5, 17))
@comments = @post.comments
render
end
@@ -86,7 +102,7 @@ describe "posts/show" do
context "forum post" do
it "shows forum name" do
@post = assign(:post,
- FactoryGirl.create(:forum_post, :author => @author))
+ FactoryGirl.create(:forum_post, author: @author))
render
rendered.should have_content "in #{@post.forum.name}"
end
@@ -97,12 +113,12 @@ describe "posts/show" do
sign_in @author
controller.stub(:current_user) { @author }
@post = assign(:post,
- FactoryGirl.create(:post, :author => @author))
+ FactoryGirl.create(:post, author: @author))
render
end
it 'shows a comment button' do
- assert_select "a[href=#{new_comment_path(:post_id => @post.id)}]", "Comment"
+ assert_select "a[href=#{new_comment_path(post_id: @post.id)}]", "Comment"
end
end
diff --git a/spec/views/posts/show.rss.haml_spec.rb b/spec/views/posts/show.rss.haml_spec.rb
index 72e8e7347..abe9b81f4 100644
--- a/spec/views/posts/show.rss.haml_spec.rb
+++ b/spec/views/posts/show.rss.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe 'posts/show.rss.haml' do
@@ -5,8 +21,8 @@ describe 'posts/show.rss.haml' do
controller.stub(:current_user) { nil }
@author = FactoryGirl.create(:member)
@post = FactoryGirl.create(:post)
- FactoryGirl.create(:comment, :author => @author, :post => @post)
- FactoryGirl.create(:comment, :author => @author, :post => @post)
+ FactoryGirl.create(:comment, author: @author, post: @post)
+ FactoryGirl.create(:comment, author: @author, post: @post)
assign(:post, @post)
render
end
diff --git a/spec/views/products/edit.html.haml_spec.rb b/spec/views/products/edit.html.haml_spec.rb
index 3505c0216..107a32284 100644
--- a/spec/views/products/edit.html.haml_spec.rb
+++ b/spec/views/products/edit.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "products/edit" do
before(:each) do
@product = assign(:product, stub_model(Product,
- :name => "MyString",
- :description => "MyString",
- :min_price => "9.99"
+ name: "MyString",
+ description: "MyString",
+ min_price: "9.99"
))
end
@@ -13,11 +29,11 @@ describe "products/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => products_path(@product), :method => "post" do
- assert_select "input#product_name", :name => "product[name]"
- assert_select "textarea#product_description", :name => "product[description]"
- assert_select "input#product_min_price", :name => "product[min_price]"
- assert_select "input#product_recommended_price", :name => "product[recommended_price]"
+ assert_select "form", action: products_path(@product), method: "post" do
+ assert_select "input#product_name", name: "product[name]"
+ assert_select "textarea#product_description", name: "product[description]"
+ assert_select "input#product_min_price", name: "product[min_price]"
+ assert_select "input#product_recommended_price", name: "product[recommended_price]"
end
end
end
diff --git a/spec/views/products/index.html.haml_spec.rb b/spec/views/products/index.html.haml_spec.rb
index 2b96540c1..7fdaa0d20 100644
--- a/spec/views/products/index.html.haml_spec.rb
+++ b/spec/views/products/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "products/index" do
@@ -9,8 +25,8 @@ describe "products/index" do
it "renders a list of products" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => @product.name, :count => 2
- assert_select "tr>td", :text => @product.description, :count => 2
- assert_select "tr>td", :text => @product.min_price, :count => 2
+ assert_select "tr>td", text: @product.name, count: 2
+ assert_select "tr>td", text: @product.description, count: 2
+ assert_select "tr>td", text: @product.min_price, count: 2
end
end
diff --git a/spec/views/products/new.html.haml_spec.rb b/spec/views/products/new.html.haml_spec.rb
index ab7bc5f7e..db20a5c95 100644
--- a/spec/views/products/new.html.haml_spec.rb
+++ b/spec/views/products/new.html.haml_spec.rb
@@ -1,11 +1,27 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "products/new" do
before(:each) do
assign(:product, stub_model(Product,
- :name => "MyString",
- :description => "MyString",
- :min_price => "9.99"
+ name: "MyString",
+ description: "MyString",
+ min_price: "9.99"
).as_new_record)
end
@@ -13,13 +29,13 @@ describe "products/new" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => products_path, :method => "post" do
- assert_select "input#product_name", :name => "product[name]"
- assert_select "textarea#product_description", :name => "product[description]"
- assert_select "input#product_min_price", :name => "product[min_price]"
- assert_select "input#product_recommended_price", :name => "product[recommended_price]"
- assert_select "select#product_account_type_id", :name => "product[account_type_id]"
- assert_select "input#product_paid_months", :name => "product[paid_months]"
+ assert_select "form", action: products_path, method: "post" do
+ assert_select "input#product_name", name: "product[name]"
+ assert_select "textarea#product_description", name: "product[description]"
+ assert_select "input#product_min_price", name: "product[min_price]"
+ assert_select "input#product_recommended_price", name: "product[recommended_price]"
+ assert_select "select#product_account_type_id", name: "product[account_type_id]"
+ assert_select "input#product_paid_months", name: "product[paid_months]"
end
end
end
diff --git a/spec/views/products/show.html.haml_spec.rb b/spec/views/products/show.html.haml_spec.rb
index c33fd2b81..6fcb35654 100644
--- a/spec/views/products/show.html.haml_spec.rb
+++ b/spec/views/products/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "products/show" do
diff --git a/spec/views/roles/edit.html.haml_spec.rb b/spec/views/roles/edit.html.haml_spec.rb
index 2b12e05d5..a4026f63e 100644
--- a/spec/views/roles/edit.html.haml_spec.rb
+++ b/spec/views/roles/edit.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "roles/edit" do
before(:each) do
@role = assign(:role, stub_model(Role,
- :name => "MyString",
- :description => "MyText"
+ name: "MyString",
+ description: "MyText"
))
end
@@ -12,9 +28,9 @@ describe "roles/edit" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => roles_path(@role), :method => "post" do
- assert_select "input#role_name", :name => "role[name]"
- assert_select "textarea#role_description", :name => "role[description]"
+ assert_select "form", action: roles_path(@role), method: "post" do
+ assert_select "input#role_name", name: "role[name]"
+ assert_select "textarea#role_description", name: "role[description]"
end
end
end
diff --git a/spec/views/roles/index.html.haml_spec.rb b/spec/views/roles/index.html.haml_spec.rb
index 1b732c381..fe8e40333 100644
--- a/spec/views/roles/index.html.haml_spec.rb
+++ b/spec/views/roles/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "roles/index" do
@@ -5,12 +21,12 @@ describe "roles/index" do
controller.stub(:current_user) { nil }
assign(:roles, [
stub_model(Role,
- :name => "Name",
- :description => "MyText"
+ name: "Name",
+ description: "MyText"
),
stub_model(Role,
- :name => "Name",
- :description => "MyText"
+ name: "Name",
+ description: "MyText"
)
])
end
@@ -18,7 +34,7 @@ describe "roles/index" do
it "renders a list of roles" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "tr>td", :text => "Name".to_s, :count => 2
- assert_select "tr>td", :text => "MyText".to_s, :count => 2
+ assert_select "tr>td", text: "Name".to_s, count: 2
+ assert_select "tr>td", text: "MyText".to_s, count: 2
end
end
diff --git a/spec/views/roles/new.html.haml_spec.rb b/spec/views/roles/new.html.haml_spec.rb
index bba7e62b7..01dcd4c60 100644
--- a/spec/views/roles/new.html.haml_spec.rb
+++ b/spec/views/roles/new.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "roles/new" do
before(:each) do
assign(:role, stub_model(Role,
- :name => "MyString",
- :description => "MyText"
+ name: "MyString",
+ description: "MyText"
).as_new_record)
end
@@ -12,9 +28,9 @@ describe "roles/new" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => roles_path, :method => "post" do
- assert_select "input#role_name", :name => "role[name]"
- assert_select "textarea#role_description", :name => "role[description]"
+ assert_select "form", action: roles_path, method: "post" do
+ assert_select "input#role_name", name: "role[name]"
+ assert_select "textarea#role_description", name: "role[description]"
end
end
end
diff --git a/spec/views/roles/show.html.haml_spec.rb b/spec/views/roles/show.html.haml_spec.rb
index 16f48415f..cc0eb506e 100644
--- a/spec/views/roles/show.html.haml_spec.rb
+++ b/spec/views/roles/show.html.haml_spec.rb
@@ -1,10 +1,26 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "roles/show" do
before(:each) do
@role = assign(:role, stub_model(Role,
- :name => "Name",
- :description => "MyText"
+ name: "Name",
+ description: "MyText"
))
end
diff --git a/spec/views/scientific_names/edit.html.haml_spec.rb b/spec/views/scientific_names/edit.html.haml_spec.rb
index 3e5dc9e91..09ff5125b 100644
--- a/spec/views/scientific_names/edit.html.haml_spec.rb
+++ b/spec/views/scientific_names/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "scientific_names/edit" do
@@ -17,9 +33,9 @@ describe "scientific_names/edit" do
end
it "renders the edit scientific_name form" do
- assert_select "form", :action => scientific_names_path(@scientific_name), :method => "post" do
- assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]"
- assert_select "select#scientific_name_crop_id", :name => "scientific_name[crop_id]"
+ assert_select "form", action: scientific_names_path(@scientific_name), method: "post" do
+ assert_select "input#scientific_name_scientific_name", name: "scientific_name[scientific_name]"
+ assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]"
end
end
end
diff --git a/spec/views/scientific_names/index.html.haml_spec.rb b/spec/views/scientific_names/index.html.haml_spec.rb
index a49b9ef88..ea89ae101 100644
--- a/spec/views/scientific_names/index.html.haml_spec.rb
+++ b/spec/views/scientific_names/index.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "scientific_names/index" do
@@ -11,8 +27,8 @@ describe "scientific_names/index" do
it "renders a list of scientific_names" do
render
- assert_select "tr>td", :text => "Zea mays".to_s
- assert_select "tr>td", :text => "Solanum lycopersicum".to_s
+ assert_select "tr>td", text: "Zea mays".to_s
+ assert_select "tr>td", text: "Solanum lycopersicum".to_s
end
it "doesn't show edit/destroy links" do
diff --git a/spec/views/scientific_names/new.html.haml_spec.rb b/spec/views/scientific_names/new.html.haml_spec.rb
index 151908e7d..a8ad3f615 100644
--- a/spec/views/scientific_names/new.html.haml_spec.rb
+++ b/spec/views/scientific_names/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "scientific_names/new" do
@@ -16,9 +32,9 @@ describe "scientific_names/new" do
it "renders new scientific_name form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => scientific_names_path, :method => "post" do
- assert_select "input#scientific_name_scientific_name", :name => "scientific_name[scientific_name]"
- assert_select "select#scientific_name_crop_id", :name => "scientific_name[crop_id]"
+ assert_select "form", action: scientific_names_path, method: "post" do
+ assert_select "input#scientific_name_scientific_name", name: "scientific_name[scientific_name]"
+ assert_select "select#scientific_name_crop_id", name: "scientific_name[crop_id]"
end
end
diff --git a/spec/views/scientific_names/show.html.haml_spec.rb b/spec/views/scientific_names/show.html.haml_spec.rb
index d2927c5a9..a36646658 100644
--- a/spec/views/scientific_names/show.html.haml_spec.rb
+++ b/spec/views/scientific_names/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "scientific_names/show" do
@@ -12,6 +28,19 @@ describe "scientific_names/show" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
rendered.should match(/Zea mays/)
- rendered.should match(@scientific_name.id.to_s)
+ end
+
+ context 'signed in' do
+
+ before :each do
+ @wrangler = FactoryGirl.create(:crop_wrangling_member)
+ sign_in @wrangler
+ controller.stub(:current_user) { @wrangler }
+ render
+ end
+
+ it 'should have an edit button' do
+ rendered.should have_content 'Edit'
+ end
end
end
diff --git a/spec/views/seeds/edit.html.haml_spec.rb b/spec/views/seeds/edit.html.haml_spec.rb
index 6a0235e4b..1c9911afa 100644
--- a/spec/views/seeds/edit.html.haml_spec.rb
+++ b/spec/views/seeds/edit.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "seeds/edit" do
@@ -5,26 +21,26 @@ describe "seeds/edit" do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_user) { @member }
- @seed = FactoryGirl.create(:seed, :owner => @member)
+ @seed = FactoryGirl.create(:seed, owner: @member)
end
it "renders the edit seed form" do
render
# Run the generator again with the --webrat flag if you want to use webrat matchers
- assert_select "form", :action => seeds_path(@seed), :method => "post" do
- assert_select "input#crop", :class => "ui-autocomplete-input"
- assert_select "input#seed_crop_id", :name => "seed[crop_id]"
- assert_select "textarea#seed_description", :name => "seed[description]"
- assert_select "input#seed_quantity", :name => "seed[quantity]"
- assert_select "select#seed_tradable_to", :name => "seed[tradable_to]"
+ assert_select "form", action: seeds_path(@seed), method: "post" do
+ assert_select "input#crop", class: "ui-autocomplete-input"
+ assert_select "input#seed_crop_id", name: "seed[crop_id]"
+ assert_select "textarea#seed_description", name: "seed[description]"
+ assert_select "input#seed_quantity", name: "seed[quantity]"
+ assert_select "select#seed_tradable_to", name: "seed[tradable_to]"
end
end
it "doesn't revert tradable_to to nowhere" do
- @seed = FactoryGirl.create(:tradable_seed, :owner => @member)
+ @seed = FactoryGirl.create(:tradable_seed, owner: @member)
@seed.tradable_to.should_not eq "nowhere"
render
- assert_select "option[selected=selected]", :text => @seed.tradable_to
+ assert_select "option[selected=selected]", text: @seed.tradable_to
end
end
diff --git a/spec/views/seeds/index.html.haml_spec.rb b/spec/views/seeds/index.html.haml_spec.rb
deleted file mode 100644
index a1d478544..000000000
--- a/spec/views/seeds/index.html.haml_spec.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-require 'rails_helper'
-
-describe "seeds/index" do
- before(:each) do
- @member = FactoryGirl.create(:member)
- sign_in @member
- controller.stub(:current_user) { @member }
- @seed1 = FactoryGirl.create(:seed, :owner => @member)
- @page = 1
- @per_page = 2
- @total_entries = 2
- seeds = WillPaginate::Collection.create(@page, @per_page, @total_entries) do |pager|
- pager.replace([ @seed1, @seed1 ])
- end
- assign(:seeds, seeds)
- end
-
- it "renders a list of seeds" do
- render
- assert_select "tr>td", :text => @seed1.crop.name, :count => 2
- assert_select "tr>td", :text => @seed1.owner.login_name, :count => 2
- assert_select "tr>td", :text => @seed1.quantity.to_s, :count => 2
- end
-
- context "tradable" do
- before(:each) do
- @owner = FactoryGirl.create(:london_member)
- @seed1 = FactoryGirl.create(:tradable_seed, :owner => @owner)
- seeds = WillPaginate::Collection.create(@page, @per_page, @total_entries) do |pager|
- pager.replace([ @seed1, @seed1 ])
- end
- assign(:seeds, seeds)
- render
- end
-
- it "shows tradable seeds" do
- assert_select "tr>td", :text => @seed1.tradable_to, :count => 2
- end
-
- it "shows location of seed owner" do
- assert_select "tr>td", :text => @owner.location, :count => 2
- assert_select 'a', :href => place_path(@owner.location)
- end
- end
-
- it "provides data links" do
- render
- rendered.should have_content "The data on this page is available in the following formats:"
- assert_select "a", :href => seeds_path(:format => 'csv')
- assert_select "a", :href => seeds_path(:format => 'json')
- assert_select "a", :href => seeds_path(:format => 'rss')
- end
-end
diff --git a/spec/views/seeds/index.rss.haml_spec.rb b/spec/views/seeds/index.rss.haml_spec.rb
index 485f390d0..5e88fc014 100644
--- a/spec/views/seeds/index.rss.haml_spec.rb
+++ b/spec/views/seeds/index.rss.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe 'seeds/index.rss.haml' do
diff --git a/spec/views/seeds/new.html.haml_spec.rb b/spec/views/seeds/new.html.haml_spec.rb
index 9abb2f291..2f20412fa 100644
--- a/spec/views/seeds/new.html.haml_spec.rb
+++ b/spec/views/seeds/new.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "seeds/new" do
@@ -5,25 +21,25 @@ describe "seeds/new" do
@member = FactoryGirl.create(:member)
sign_in @member
controller.stub(:current_user) { @member }
- @seed1 = FactoryGirl.create(:seed, :owner => @member)
+ @seed1 = FactoryGirl.create(:seed, owner: @member)
assign(:seed, @seed1)
end
it "renders new seed form" do
render
- assert_select "form", :action => seeds_path, :method => "post" do
- assert_select "input#crop", :class => "ui-autocomplete-input"
- assert_select "input#seed_crop_id", :name => "seed[crop_id]"
- assert_select "textarea#seed_description", :name => "seed[description]"
- assert_select "input#seed_quantity", :name => "seed[quantity]"
- assert_select "select#seed_tradable_to", :name => "seed[tradable_to]"
+ assert_select "form", action: seeds_path, method: "post" do
+ assert_select "input#crop", class: "ui-autocomplete-input"
+ assert_select "input#seed_crop_id", name: "seed[crop_id]"
+ assert_select "textarea#seed_description", name: "seed[description]"
+ assert_select "input#seed_quantity", name: "seed[quantity]"
+ assert_select "select#seed_tradable_to", name: "seed[tradable_to]"
end
end
it 'reminds you to set your location' do
render
rendered.should have_content "Don't forget to set your location."
- assert_select "a", :text => "set your location"
+ assert_select "a", text: "set your location"
end
context 'member has location' do
@@ -31,19 +47,19 @@ describe "seeds/new" do
@member = FactoryGirl.create(:london_member)
sign_in @member
controller.stub(:current_user) { @member }
- @seed1 = FactoryGirl.create(:seed, :owner => @member)
+ @seed1 = FactoryGirl.create(:seed, owner: @member)
assign(:seed, @seed1)
end
it 'shows the location' do
render
rendered.should have_content "from #{@member.location}."
- assert_select 'a', :href => place_path(@member.location)
+ assert_select 'a', href: place_path(@member.location)
end
it 'links to change location' do
render
- assert_select "a", :text => "Change your location."
+ assert_select "a", text: "Change your location."
end
end
diff --git a/spec/views/seeds/show.html.haml_spec.rb b/spec/views/seeds/show.html.haml_spec.rb
index af00b4efe..db2bae6ce 100644
--- a/spec/views/seeds/show.html.haml_spec.rb
+++ b/spec/views/seeds/show.html.haml_spec.rb
@@ -1,3 +1,19 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
describe "seeds/show" do
@@ -16,7 +32,7 @@ describe "seeds/show" do
before(:each) do
@owner = FactoryGirl.create(:london_member)
assign(:seed, FactoryGirl.create(:tradable_seed,
- :owner => @owner))
+ owner: @owner))
# note current_member is not the owner of this seed
@member = FactoryGirl.create(:member)
sign_in @member
@@ -31,7 +47,7 @@ describe "seeds/show" do
it "shows location of seed owner" do
render
rendered.should have_content @owner.location
- assert_select 'a', :href => place_path(@owner.location)
+ assert_select 'a', href: place_path(@owner.location)
end
context 'with no location' do
@@ -39,7 +55,7 @@ describe "seeds/show" do
@owner = FactoryGirl.create(:member) # no location
sign_in @owner
controller.stub(:current_user) { @owner }
- assign(:seed, FactoryGirl.create(:tradable_seed, :owner => @owner))
+ assign(:seed, FactoryGirl.create(:tradable_seed, owner: @owner))
end
it 'says "from unspecified location"' do
@@ -49,7 +65,7 @@ describe "seeds/show" do
it "links to profile to set location" do
render
- assert_select "a[href=#{url_for(edit_member_registration_path)}]", :text => "Set Location"
+ assert_select "a[href=#{url_for(edit_member_registration_path)}]", text: "Set Location"
end
end
diff --git a/spec/views/shop/index_spec.rb b/spec/views/shop/index_spec.rb
index ee9ee59a9..df1f74920 100644
--- a/spec/views/shop/index_spec.rb
+++ b/spec/views/shop/index_spec.rb
@@ -1,6 +1,22 @@
+## DEPRECATION NOTICE: Do not add new tests to this file!
+##
+## View and controller tests are deprecated in the Growstuff project.
+## We no longer write new view and controller tests, but instead write
+## feature tests (in spec/features) using Capybara (https://github.com/jnicklas/capybara).
+## These test the full stack, behaving as a browser, and require less complicated setup
+## to run. Please feel free to delete old view/controller tests as they are reimplemented
+## in feature tests.
+##
+## If you submit a pull request containing new view or controller tests, it will not be
+## merged.
+
+
+
+
+
require 'rails_helper'
-describe 'shop/index.html.haml', :type => "view" do
+describe 'shop/index.html.haml', type: "view" do
before(:each) do
@product1 = FactoryGirl.create(:product)
@product2 = FactoryGirl.create(:product_with_recommended_price)
@@ -16,11 +32,11 @@ describe 'shop/index.html.haml', :type => "view" do
end
it 'shows products' do
- assert_select("h2", :text => @product1.name)
+ assert_select("h2", text: @product1.name)
end
- it 'shows prices in AUD' do
- rendered.should have_content '9.99 AUD'
+ it 'shows prices in configured currency' do
+ rendered.should have_content '9.99 %s' % Growstuff::Application.config.currency
end
it 'should contain an exchange rate link' do
@@ -29,7 +45,7 @@ describe 'shop/index.html.haml', :type => "view" do
end
it 'shows recommended price for products that have it' do
- rendered.should have_content '12.00 AUD'
+ rendered.should have_content '12.00 %s' % Growstuff::Application.config.currency
end
it 'should contain an exchange rate link for recommended price' do
@@ -38,11 +54,11 @@ describe 'shop/index.html.haml', :type => "view" do
end
it 'displays the order form' do
- assert_select "form", :count => 2
+ assert_select "form", count: 2
end
it 'renders markdown in product descriptions' do
- assert_select "em", :text => 'hurrah', :count => 2
+ assert_select "em", text: 'hurrah', count: 2
end
end
diff --git a/spec/views/support/index_spec.rb b/spec/views/support/index_spec.rb
deleted file mode 100644
index fc3a96b12..000000000
--- a/spec/views/support/index_spec.rb
+++ /dev/null
@@ -1,16 +0,0 @@
-require 'rails_helper'
-
-describe 'support/index.html.haml', :type => "view" do
- before(:each) do
- render
- end
-
- it 'should show support faq' do
- rendered.should have_content 'About Growstuff'
- end
-
- it 'should not mention Courtney any more' do
- rendered.should_not have_content 'Courtney'
- rendered.should_not have_content 'phazel'
- end
-end
diff --git a/vendor/gems/activemerchant-1.33.0/lib/support/ssl_verify.rb b/vendor/gems/activemerchant-1.33.0/lib/support/ssl_verify.rb
index 1ba28878a..ccb6650d5 100644
--- a/vendor/gems/activemerchant-1.33.0/lib/support/ssl_verify.rb
+++ b/vendor/gems/activemerchant-1.33.0/lib/support/ssl_verify.rb
@@ -10,7 +10,7 @@ class SSLVerify
def test_gateways
success, failed, missing, errored, disabled = [], [], [], [], []
- puts "Verifying #{@gateways.count} SSL certificates\n\n"
+ puts "Verifying #{@gateways.size} SSL certificates\n\n"
@gateways.each do |g|
if !g.live_url