mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-26 01:37:39 -04:00
Compare commits
44 Commits
fix-naming
...
datepicker
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75807ba2af | ||
|
|
62406a6573 | ||
|
|
53e90f57dd | ||
|
|
54acc2c108 | ||
|
|
0639cd5ab8 | ||
|
|
41c4ae1448 | ||
|
|
99221d7cf3 | ||
|
|
eeb8c84c31 | ||
|
|
e65dd4ef85 | ||
|
|
40ed3c8007 | ||
|
|
035decb132 | ||
|
|
7102552bfe | ||
|
|
e1270512dc | ||
|
|
8d40355355 | ||
|
|
919c3dbf37 | ||
|
|
3e7a58fcfc | ||
|
|
fc301558e1 | ||
|
|
2523bea154 | ||
|
|
f89d64ac3a | ||
|
|
65a0540e3d | ||
|
|
654aa318c4 | ||
|
|
5128c8be0e | ||
|
|
0e1578aeef | ||
|
|
c6b5cc61da | ||
|
|
dddc85c338 | ||
|
|
69e764dd63 | ||
|
|
8aa0f98196 | ||
|
|
4c8c54eadd | ||
|
|
9c6797e850 | ||
|
|
a5f774f043 | ||
|
|
fe0d4295be | ||
|
|
c5bdac4a5c | ||
|
|
195602288c | ||
|
|
c78a347002 | ||
|
|
5178e1257e | ||
|
|
03f8acdd1d | ||
|
|
426cb3ed37 | ||
|
|
4716b33d82 | ||
|
|
329c3ddddd | ||
|
|
3405d224b4 | ||
|
|
bd858a0b23 | ||
|
|
defc3def4f | ||
|
|
4b0e228525 | ||
|
|
0f9e151c15 |
@@ -17,9 +17,7 @@ encourage participation from people of all backgrounds and skill levels.
|
||||
## Want to contribute?
|
||||
|
||||
Don't ask to ask, the best way to get started is to fork the project, start a codespace and get hacking.
|
||||
Dive on in and submit your PRs!
|
||||
|
||||
Vibe Coding is more than okay, just make sure you indicate if you have done so and ensure there are tests.
|
||||
Dive on in and submit your PRs.
|
||||
|
||||
## Important links
|
||||
|
||||
@@ -37,10 +35,6 @@ frontend features. We welcome contributions -- see
|
||||
* To set up your development environment, see [Getting started](https://github.com/Growstuff/growstuff/wiki/New-contributor-guide).
|
||||
* You may also be interested in our [API](https://github.com/Growstuff/growstuff/wiki/API).
|
||||
|
||||
### For Home Automation enthusiasts
|
||||
|
||||
https://github.com/Growstuff/homeassistant-growstuff/
|
||||
|
||||
## For designers, writers, researchers, data wranglers, and other contributors
|
||||
|
||||
There are heaps of ways to get involved and contribute no matter what
|
||||
|
||||
@@ -133,7 +133,7 @@ class PlantingsController < DataController
|
||||
:crop_id, :description, :garden_id, :planted_at,
|
||||
:parent_seed_id,
|
||||
:quantity, :sunniness, :planted_from, :finished,
|
||||
:finished_at, :failed, :overall_rating
|
||||
:finished_at, :failed
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ class Harvest < ApplicationRecord
|
||||
|
||||
delegate :name, :slug, to: :crop, prefix: true
|
||||
delegate :login_name, :slug, to: :owner, prefix: true
|
||||
delegate :name, to: :plant_part, prefix: true
|
||||
|
||||
##
|
||||
## Validations
|
||||
@@ -108,7 +109,7 @@ class Harvest < ApplicationRecord
|
||||
def to_s
|
||||
# 50 individual apples, weighing 3lb
|
||||
# 2 buckets of apricots, weighing 10kg
|
||||
"#{quantity_to_human} #{unit_to_human} #{plant_part_name_to_human} of #{crop_name} #{weight_to_human}".strip
|
||||
"#{quantity_to_human} #{unit_to_human} #{crop_name_to_human} #{weight_to_human}".strip
|
||||
end
|
||||
|
||||
def quantity_to_human
|
||||
@@ -131,13 +132,13 @@ class Harvest < ApplicationRecord
|
||||
"weighing #{number_to_human(weight_quantity, strip_insignificant_zeros: true)} #{weight_unit}"
|
||||
end
|
||||
|
||||
def plant_part_name_to_human
|
||||
def crop_name_to_human
|
||||
if unit != 'individual' # buckets of apricot*s*
|
||||
plant_part.name.pluralize
|
||||
crop.name.pluralize
|
||||
elsif quantity == 1
|
||||
plant_part.name
|
||||
crop.name
|
||||
else
|
||||
plant_part.name.pluralize
|
||||
crop.name.pluralize
|
||||
end.to_s
|
||||
end
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ class Photo < ApplicationRecord
|
||||
flickr = owner.flickr
|
||||
info = flickr.photos.getInfo(photo_id: source_id)
|
||||
licenses = flickr.photos.licenses.getInfo
|
||||
license = licenses.find { |l| l.id.to_i == info.license.to_i }
|
||||
Rails.logger.error("Cannot find license: " + [info.license, licenses].inspect) unless license
|
||||
license = licenses.find { |l| l.id == info.license }
|
||||
{
|
||||
title: calculate_title(info),
|
||||
license_name: license.name,
|
||||
|
||||
@@ -11,10 +11,6 @@ class PlantPart < ApplicationRecord
|
||||
|
||||
scope :joins_members, -> { joins("INNER JOIN members ON members.id = harvests.owner_id") }
|
||||
|
||||
def whole_plant?
|
||||
name == 'whole plant'
|
||||
end
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
@@ -83,9 +83,6 @@ class Planting < ApplicationRecord
|
||||
validates :planted_from, allow_blank: true, inclusion: {
|
||||
in: PLANTED_FROM_VALUES, message: "%<value>s is not a valid planting method"
|
||||
}
|
||||
validates :overall_rating, allow_blank: true, numericality: {
|
||||
only_integer: true, greater_than_or_equal_to: 1, less_than_or_equal_to: 5
|
||||
}
|
||||
|
||||
def planting_slug
|
||||
[
|
||||
|
||||
@@ -39,9 +39,7 @@
|
||||
= link_to "Add a planting.", new_planting_path
|
||||
|
||||
.col-md-4
|
||||
= f.date_field :due_date,
|
||||
value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '',
|
||||
label: 'When?'
|
||||
= f.date_field :due_date, value: @activity.due_date ? @activity.due_date.to_fs(:ymd) : '', label: 'When?'
|
||||
|
||||
%hr
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
= link_to "Request new crops.", new_crop_path
|
||||
|
||||
.col-md-4
|
||||
= f.date_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '', label: 'When?'
|
||||
= f.date_field :harvested_at, value: @harvest.harvested_at ? @harvest.harvested_at.to_fs(:ymd) : '', label: 'When?', required: true
|
||||
.col-12
|
||||
= f.form_group :plant_part_id, label: { text: "Harvested Plant Part" } do
|
||||
.row
|
||||
|
||||
@@ -5,8 +5,3 @@
|
||||
- @matching_plantings.each do |planting|
|
||||
= f.radio_button :planting_id, planting.id, label: planting
|
||||
= f.submit "save", class: 'btn btn-sm'
|
||||
|
||||
- if @harvest.planting.present? && @harvest.planting.overall_rating.blank?
|
||||
.alert.alert-info{role: "alert"}
|
||||
This harvest is from a planting that hasn't been rated yet.
|
||||
= link_to "Rate this planting", edit_planting_path(@harvest.planting), class: 'alert-link'
|
||||
|
||||
@@ -89,9 +89,3 @@
|
||||
- if planting.finished_at.present?
|
||||
%span.plantingfact--finish
|
||||
= planting.finished_at.year
|
||||
- if planting.overall_rating.present?
|
||||
.card.fact-card
|
||||
.card-body
|
||||
%h3 Overall Rating
|
||||
%p.card-text
|
||||
%strong= "#{planting.overall_rating}/5"
|
||||
@@ -32,7 +32,7 @@
|
||||
label: 'Where did you plant it?')
|
||||
= link_to "Add a garden.", new_garden_path
|
||||
.col-md-4
|
||||
= f.text_field :planted_at,
|
||||
= f.date_field :planted_at,
|
||||
value: @planting.planted_at ? @planting.planted_at.to_fs(:ymd) : '',
|
||||
class: 'add-datepicker', label: 'When?', title: "Plan out your future plantings by forward dating, and subscribe to your iCalendar feed for reminders to plant"
|
||||
|
||||
@@ -43,15 +43,6 @@
|
||||
= f.select(:sunniness, Planting::SUNNINESS_VALUES, { include_blank: '', label: 'Sun or shade?' } )
|
||||
.col-md-4
|
||||
= f.number_field :quantity, label: 'How many?', min: 1
|
||||
.col-md-12
|
||||
= f.range_field :overall_rating, min: 1, max: 5, include_blank: 'Leave blank', label: 'Overall Rating', list: "rating-list", title: "How well is the planting going?"
|
||||
%datalist{"id": "rating-list"}
|
||||
%option{"value": "1"} Poor
|
||||
%option{"value": "2"}
|
||||
%option{"value": "3"}
|
||||
%option{"value": "4"}
|
||||
%option{"value": "5"} Great
|
||||
|
||||
= f.text_area :description, rows: 6, label: 'Tell us more about it'
|
||||
|
||||
.row
|
||||
@@ -59,9 +50,8 @@
|
||||
= f.check_box :finished, label: t('buttons.mark_as_finished'), title: t('.finish_helper')
|
||||
|
||||
.col-md-6
|
||||
= f.text_field :finished_at,
|
||||
= f.date_field :finished_at,
|
||||
value: @planting.finished_at ? @planting.finished_at.to_fs(:ymd) : '',
|
||||
class: 'add-datepicker',
|
||||
label: 'Finished date',
|
||||
placeholder: 'optional'
|
||||
.row
|
||||
|
||||
@@ -7,15 +7,6 @@
|
||||
= 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 @planting.overall_rating.present?
|
||||
%script{type: "application/ld+json"}
|
||||
:plain
|
||||
{
|
||||
"@context": "http://schema.org",
|
||||
"@type": "Rating",
|
||||
"ratingValue": "#{@planting.overall_rating}",
|
||||
"bestRating": "5"
|
||||
}
|
||||
|
||||
- content_for :breadcrumbs do
|
||||
%li.breadcrumb-item= link_to 'Plantings', plantings_path
|
||||
|
||||
@@ -28,23 +28,23 @@
|
||||
= link_to "Request new crops.", new_crop_path
|
||||
.row
|
||||
.col-12.col-md-4
|
||||
= f.text_field :saved_at,
|
||||
= f.date_field :saved_at,
|
||||
value: @seed.saved_at ? @seed.saved_at.to_fs(:ymd) : '',
|
||||
class: 'add-datepicker', label: 'When were the seeds harvested/saved?'
|
||||
label: 'When were the seeds harvested/saved?'
|
||||
.col-12.col-md-4= f.number_field :quantity, label: 'Quantity', min: 1
|
||||
.col-12.col-md-4
|
||||
= f.text_field :plant_before, class: 'add-datepicker',
|
||||
value: @seed.plant_before ? @seed.plant_before.to_fs(:ymd) : ''
|
||||
= f.date_field :plant_before, value: @seed.plant_before ? @seed.plant_before.to_fs(:ymd) : ''
|
||||
|
||||
.row
|
||||
.col-12.col-md-4
|
||||
= f.check_box :finished, label: t('buttons.mark_as_finished')
|
||||
.col-12.col-md-4
|
||||
= f.text_field :finished_at, class: 'add-datepicker', value: @seed.finished_at ? @seed.finished_at.to_fs(:ymd) : ''
|
||||
= f.date_field :finished_at, value: @seed.finished_at ? @seed.finished_at.to_fs(:ymd) : ''
|
||||
.col-12.col-md-4
|
||||
%span.help-inline= t('.finish_helper')
|
||||
|
||||
.row
|
||||
-# TODO: Range control?
|
||||
.col-md-6= f.number_field :days_until_maturity_min, label_as_placeholder: true, label: 'min', prepend: 'Days until maturity', min: 1
|
||||
.col-md-6= f.number_field :days_until_maturity_max, label_as_placeholder: true, label: 'max', prepend: 'to', append: "days", min: 1
|
||||
|
||||
|
||||
@@ -5,6 +5,5 @@
|
||||
= edit_icon
|
||||
.hide{id: "date--#{model.id}-#{field.to_s}"}
|
||||
= bootstrap_form_for(model) do |f|
|
||||
= f.date_field field,
|
||||
value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
|
||||
= f.date_field field, value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
|
||||
= f.submit :save
|
||||
|
||||
@@ -12,6 +12,5 @@
|
||||
- elsif field_type == :select
|
||||
= f.select field, collection
|
||||
- elsif field_type == :date
|
||||
= f.date_field field,
|
||||
value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
|
||||
= f.date_field field, value: model.send(field) ? model.send(field).to_fs(:ymd) : '', label: 'When?'
|
||||
= f.submit :save
|
||||
|
||||
@@ -4,6 +4,7 @@ class AddIndexesCrops < ActiveRecord::Migration[7.2]
|
||||
add_index :alternate_names, :creator_id
|
||||
add_index :alternate_names, :language
|
||||
|
||||
add_index :comments, %i(commentable_type commentable_id)
|
||||
add_index :comments, :author_id
|
||||
|
||||
add_index :crop_companions, %i(crop_a_id crop_b_id)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddOverallRatingPlantings < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
add_column :plantings, :overall_rating, :integer
|
||||
end
|
||||
end
|
||||
45
db/schema.rb
45
db/schema.rb
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_09_01_130830) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_09_01_110545) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@@ -555,6 +555,16 @@ ActiveRecord::Schema[7.2].define(version: 2025_09_01_130830) do
|
||||
t.index ["slug"], name: "index_plant_parts_on_slug", unique: true
|
||||
end
|
||||
|
||||
create_table "planting_problems", force: :cascade do |t|
|
||||
t.bigint "planting_id"
|
||||
t.bigint "problem_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["planting_id", "problem_id"], name: "index_planting_problems_on_planting_id_and_problem_id", unique: true
|
||||
t.index ["planting_id"], name: "index_planting_problems_on_planting_id"
|
||||
t.index ["problem_id"], name: "index_planting_problems_on_problem_id"
|
||||
end
|
||||
|
||||
create_table "plantings", id: :serial, force: :cascade do |t|
|
||||
t.integer "garden_id", null: false
|
||||
t.integer "crop_id", null: false
|
||||
@@ -576,7 +586,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_09_01_130830) do
|
||||
t.integer "harvests_count", default: 0
|
||||
t.integer "likes_count", default: 0
|
||||
t.boolean "failed", default: false, null: false
|
||||
t.integer "overall_rating"
|
||||
t.index ["crop_id"], name: "index_plantings_on_crop_id"
|
||||
t.index ["garden_id"], name: "index_plantings_on_garden_id"
|
||||
t.index ["owner_id"], name: "index_plantings_on_owner_id"
|
||||
@@ -599,6 +608,32 @@ ActiveRecord::Schema[7.2].define(version: 2025_09_01_130830) do
|
||||
t.index ["slug"], name: "index_posts_on_slug", unique: true
|
||||
end
|
||||
|
||||
create_table "problem_posts", force: :cascade do |t|
|
||||
t.bigint "problem_id"
|
||||
t.bigint "post_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["post_id"], name: "index_problem_posts_on_post_id"
|
||||
t.index ["problem_id", "post_id"], name: "index_problem_posts_on_problem_id_and_post_id", unique: true
|
||||
t.index ["problem_id"], name: "index_problem_posts_on_problem_id"
|
||||
end
|
||||
|
||||
create_table "problems", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.string "reason_for_rejection"
|
||||
t.string "rejection_notes"
|
||||
t.string "approval_status", default: "pending", null: false
|
||||
t.bigint "requester_id"
|
||||
t.bigint "creator_id"
|
||||
t.string "slug"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["creator_id"], name: "index_problems_on_creator_id"
|
||||
t.index ["name"], name: "index_problems_on_name"
|
||||
t.index ["requester_id"], name: "index_problems_on_requester_id"
|
||||
t.index ["slug"], name: "index_problems_on_slug"
|
||||
end
|
||||
|
||||
create_table "roles", id: :serial, force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.text "description"
|
||||
@@ -657,6 +692,12 @@ ActiveRecord::Schema[7.2].define(version: 2025_09_01_130830) do
|
||||
add_foreign_key "mailboxer_receipts", "mailboxer_notifications", column: "notification_id", name: "receipts_on_notification_id"
|
||||
add_foreign_key "photo_associations", "crops"
|
||||
add_foreign_key "photo_associations", "photos"
|
||||
add_foreign_key "planting_problems", "plantings"
|
||||
add_foreign_key "planting_problems", "problems"
|
||||
add_foreign_key "plantings", "seeds", column: "parent_seed_id", name: "parent_seed", on_delete: :nullify
|
||||
add_foreign_key "problem_posts", "posts"
|
||||
add_foreign_key "problem_posts", "problems"
|
||||
add_foreign_key "problems", "members", column: "creator_id"
|
||||
add_foreign_key "problems", "members", column: "requester_id"
|
||||
add_foreign_key "seeds", "plantings", column: "parent_planting_id", name: "parent_planting", on_delete: :nullify
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "footer" do
|
||||
describe "footer", :js do
|
||||
before { visit root_path }
|
||||
|
||||
it "footer is on home page" do
|
||||
|
||||
@@ -62,9 +62,9 @@ describe "Planting a crop", :js, :search do
|
||||
before do
|
||||
visit new_planting_path
|
||||
|
||||
@a_past_date = 15.days.ago.strftime("%Y-%m-%d")
|
||||
@right_now = Time.zone.today.strftime("%Y-%m-%d")
|
||||
@a_future_date = 1.year.from_now.strftime("%Y-%m-%d")
|
||||
@a_past_date = 15.days.ago
|
||||
@right_now = Time.zone.today
|
||||
@a_future_date = 1.year.from_now
|
||||
end
|
||||
|
||||
it "shows that it is not planted yet" do
|
||||
@@ -111,7 +111,7 @@ describe "Planting a crop", :js, :search do
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from"
|
||||
select "semi-shade", from: "Sun or shade?"
|
||||
fill_in "When?", with: '2013-03-10'
|
||||
fill_in "When?", with: Time.new(2013, 3, 10)
|
||||
fill_in "Tell us more about it", with: "It's rad."
|
||||
fill_in "Finished date", with: @a_future_date
|
||||
click_button "Save"
|
||||
@@ -185,7 +185,7 @@ describe "Planting a crop", :js, :search do
|
||||
click_link 'Actions'
|
||||
click_link "Edit"
|
||||
check "finished"
|
||||
fill_in "Finished date", with: "2015-06-25"
|
||||
fill_in "Finished date", with: Time.new(2015, 06, 25)
|
||||
click_button "Save"
|
||||
expect(page).to have_content "planting was successfully updated"
|
||||
expect(page).to have_content "Finished"
|
||||
@@ -196,10 +196,9 @@ describe "Planting a crop", :js, :search do
|
||||
select_from_autocomplete "maize"
|
||||
choose(member.gardens.first.name)
|
||||
within "form#new_planting" do
|
||||
fill_in "When?", with: "2014-07-01"
|
||||
fill_in "When?", with: Time.new(2014, 7, 1)
|
||||
check "Mark as finished"
|
||||
find_by_id('planting_overall_rating').set 4
|
||||
fill_in "Finished date", with: "2014-08-30"
|
||||
fill_in "Finished date", with: Time.new(2014, 8, 30)
|
||||
uncheck 'Mark as finished'
|
||||
end
|
||||
|
||||
@@ -221,7 +220,6 @@ describe "Planting a crop", :js, :search do
|
||||
expect(page).to have_content "planting was successfully created"
|
||||
expect(page).to have_content "Finished"
|
||||
expect(page).to have_content "Aug 2014"
|
||||
expect(page).to have_content "4/5"
|
||||
|
||||
# ensure we've indexed in elastic search
|
||||
planting.reindex(refresh: true)
|
||||
@@ -278,7 +276,7 @@ describe "Planting a crop", :js, :search do
|
||||
fill_autocomplete "crop", with: "mai"
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_planting" do
|
||||
fill_in "When", with: "2015-10-15"
|
||||
fill_in "When", with: Time.new(2015, 10, 15)
|
||||
fill_in "How many?", with: 42
|
||||
select "cutting", from: "Planted from"
|
||||
select "sun", from: "Sun or shade?"
|
||||
|
||||
@@ -33,7 +33,7 @@ describe "Seeds", :js, :search do
|
||||
select_from_autocomplete "maize"
|
||||
within "form#new_seed" do
|
||||
fill_in "Quantity", with: 42
|
||||
fill_in "Plant before", with: "2014-06-15"
|
||||
fill_in "Plant before", with: TIme.new(2014, 6, 15)
|
||||
fill_in "min", with: 999
|
||||
fill_in "max", with: 1999
|
||||
select "certified organic", from: "Organic?"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "signin" do
|
||||
describe "signin", :js do
|
||||
let(:member) { FactoryBot.create(:member) }
|
||||
let(:recipient) { FactoryBot.create(:member) }
|
||||
let(:wrangler) { FactoryBot.create(:crop_wrangling_member) }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "signup" do
|
||||
describe "signup", :js do
|
||||
it "sign up for new account from top menubar" do
|
||||
visit crops_path # something other than front page, which has multiple signup links
|
||||
click_link 'Sign up'
|
||||
|
||||
@@ -149,94 +149,78 @@ describe Harvest do
|
||||
end
|
||||
|
||||
context "stringification" do
|
||||
let(:whole_plant) { FactoryBot.create(:plant_part, name: "whole plant") }
|
||||
let(:leaf) { FactoryBot.create(:plant_part, name: "leaf") }
|
||||
let(:fruit) { FactoryBot.create(:plant_part, name: "fruit") }
|
||||
let(:other) { FactoryBot.create(:plant_part, name: "other") }
|
||||
let(:crop) { FactoryBot.create(:crop, name: "apricot") }
|
||||
|
||||
let(:apricot) { FactoryBot.create(:crop, name: "apricot") }
|
||||
let(:lettuce) { FactoryBot.create(:crop, name: "lettuce") }
|
||||
it "apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: nil,
|
||||
unit: nil,
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "apricots"
|
||||
end
|
||||
|
||||
context "apricots" do
|
||||
it "apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: nil,
|
||||
unit: nil,
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "fruits of apricot"
|
||||
end
|
||||
it "1 individual apricot" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: 1,
|
||||
unit: 'individual',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "1 individual apricot"
|
||||
end
|
||||
|
||||
it "1 individual apricot" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: 1,
|
||||
unit: 'individual',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "1 individual fruit of apricot"
|
||||
end
|
||||
it "10 individual apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: 10,
|
||||
unit: 'individual',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "10 individual apricots"
|
||||
end
|
||||
|
||||
it "10 individual apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: 10,
|
||||
unit: 'individual',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "10 individual fruits of apricot"
|
||||
end
|
||||
it "1 bushel of apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: 1,
|
||||
unit: 'bushel',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "1 bushel of apricots"
|
||||
end
|
||||
|
||||
it "1 bushel of apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: 1,
|
||||
unit: 'bushel',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "1 bushel of fruits of apricot"
|
||||
end
|
||||
it "1.5 bushels of apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: 1.5,
|
||||
unit: 'bushel',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "1.5 bushels of apricots"
|
||||
end
|
||||
|
||||
it "1.5 bushels of apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: 1.5,
|
||||
unit: 'bushel',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "1.5 bushels of fruits of apricot"
|
||||
end
|
||||
it "10 bushels of apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: 10,
|
||||
unit: 'bushel',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "10 bushels of apricots"
|
||||
end
|
||||
|
||||
it "10 bushels of apricots" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: 10,
|
||||
unit: 'bushel',
|
||||
weight_quantity: nil,
|
||||
weight_unit: nil)
|
||||
expect(@h.to_s).to eq "10 bushels of fruits of apricot"
|
||||
end
|
||||
it "apricots weighing 1.2 kg" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: nil,
|
||||
unit: nil,
|
||||
weight_quantity: 1.2,
|
||||
weight_unit: 'kg')
|
||||
expect(@h.to_s).to eq "apricots weighing 1.2 kg"
|
||||
end
|
||||
|
||||
it "apricots weighing 1.2 kg" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: nil,
|
||||
unit: nil,
|
||||
weight_quantity: 1.2,
|
||||
weight_unit: 'kg')
|
||||
expect(@h.to_s).to eq "fruits of apricot weighing 1.2 kg"
|
||||
end
|
||||
|
||||
it "10 bushels of apricots weighing 100 kg" do
|
||||
@h = FactoryBot.create(:harvest, crop: apricot,
|
||||
plant_part: fruit,
|
||||
quantity: 10,
|
||||
unit: 'bushel',
|
||||
weight_quantity: 100,
|
||||
weight_unit: 'kg')
|
||||
expect(@h.to_s).to eq "10 bushels of fruits of apricot weighing 100 kg"
|
||||
end
|
||||
it "10 bushels of apricots weighing 100 kg" do
|
||||
@h = FactoryBot.create(:harvest, crop:,
|
||||
quantity: 10,
|
||||
unit: 'bushel',
|
||||
weight_quantity: 100,
|
||||
weight_unit: 'kg')
|
||||
expect(@h.to_s).to eq "10 bushels of apricots weighing 100 kg"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -22,6 +22,6 @@ describe "plantings/_form" do
|
||||
end
|
||||
|
||||
it "has a free-form text field containing the planting date in ISO format" do
|
||||
assert_select "input#planting_planted_at[type='text'][value='2013-03-01']"
|
||||
assert_select "input#planting_planted_at[type='date'][value='2013-03-01']"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user