mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-25 09:19:15 -04:00
Compare commits
33 Commits
RSpec/Incl
...
add-garden
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2c0c314a7 | ||
|
|
fe4dd5c185 | ||
|
|
2019d0e952 | ||
|
|
e7659a75a4 | ||
|
|
4a66bdc9fe | ||
|
|
8de6b083f9 | ||
|
|
accab7f84c | ||
|
|
3f6dd59dfa | ||
|
|
0a71b44dea | ||
|
|
ba75afb3f5 | ||
|
|
aa1c9ceb05 | ||
|
|
6f59635ca7 | ||
|
|
6736ae3142 | ||
|
|
49a248e8dd | ||
|
|
703c119e28 | ||
|
|
699fdb8859 | ||
|
|
ead197a597 | ||
|
|
02a3776698 | ||
|
|
bc089646fb | ||
|
|
fca91a0a71 | ||
|
|
a4cfb6086a | ||
|
|
a081a8d2f5 | ||
|
|
775986d1dd | ||
|
|
dee6000537 | ||
|
|
e9ec6f2ca9 | ||
|
|
4596698f1b | ||
|
|
99d5b08898 | ||
|
|
7ed0d0d036 | ||
|
|
d0e3a8ff19 | ||
|
|
8ee0881d02 | ||
|
|
3087443794 | ||
|
|
5ef4ca339a | ||
|
|
bbd8c94897 |
@@ -242,12 +242,6 @@ RSpec/BeforeAfterAll:
|
||||
Exclude:
|
||||
- 'spec/tasks/import_spec.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
RSpec/ContextMethod:
|
||||
Exclude:
|
||||
- 'spec/requests/api/v1/activities_request_spec.rb'
|
||||
|
||||
# Offense count: 299
|
||||
# Configuration parameters: Prefixes, AllowedPatterns.
|
||||
# Prefixes: when, with, without
|
||||
@@ -299,14 +293,6 @@ RSpec/EmptyLineAfterExample:
|
||||
RSpec/ExampleLength:
|
||||
Max: 27
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: method_call, block
|
||||
RSpec/ExpectChange:
|
||||
Exclude:
|
||||
- 'spec/models/crop_spec.rb'
|
||||
|
||||
# Offense count: 32
|
||||
RSpec/ExpectInHook:
|
||||
Exclude:
|
||||
@@ -486,23 +472,6 @@ RSpec/VerifiedDoubles:
|
||||
- 'spec/controllers/gardens_controller_spec.rb'
|
||||
- 'spec/views/devise/shared/_links_spec.rb'
|
||||
|
||||
# Offense count: 7
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: ResponseMethods.
|
||||
# ResponseMethods: response, last_response
|
||||
RSpecRails/HaveHttpStatus:
|
||||
Exclude:
|
||||
- 'spec/controllers/api/v1/plantings_controller_spec.rb'
|
||||
- 'spec/controllers/harvests_controller_spec.rb'
|
||||
- 'spec/controllers/likes_controller_spec.rb'
|
||||
- 'spec/requests/harvests_spec.rb'
|
||||
|
||||
# Offense count: 17
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
# Configuration parameters: Inferences.
|
||||
RSpecRails/InferredSpecType:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 30
|
||||
# Configuration parameters: Database.
|
||||
# SupportedDatabases: mysql, postgresql
|
||||
@@ -622,7 +591,6 @@ Rails/RedundantActiveRecordAllMethod:
|
||||
- 'app/controllers/scientific_names_controller.rb'
|
||||
- 'spec/features/members/deletion_spec.rb'
|
||||
- 'spec/features/percy/percy_spec.rb'
|
||||
- 'spec/models/harvest_spec.rb'
|
||||
|
||||
# Offense count: 5
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
@@ -704,12 +672,6 @@ Rails/WhereEquals:
|
||||
- 'app/models/harvest.rb'
|
||||
- 'app/models/planting.rb'
|
||||
|
||||
# Offense count: 1
|
||||
# This cop supports safe autocorrection (--autocorrect).
|
||||
Rails/WhereMissing:
|
||||
Exclude:
|
||||
- 'app/controllers/crops_controller.rb'
|
||||
|
||||
# Offense count: 3
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all).
|
||||
Rails/WhereRange:
|
||||
|
||||
@@ -160,7 +160,7 @@ class CropsController < ApplicationController
|
||||
when 'youtube'
|
||||
Crop.approved.where(en_youtube_url: [nil, '']).order(plantings_count: :desc)
|
||||
when 'alternate_names'
|
||||
Crop.approved.left_joins(:alternate_names).where(alternate_names: { id: nil }).order(plantings_count: :desc)
|
||||
Crop.approved.where.missing(:alternate_names).order(plantings_count: :desc)
|
||||
when 'wikidata'
|
||||
crops_with_wikidata = Crop.joins(:scientific_names).where.not(scientific_names: { wikidata_id: nil }).distinct
|
||||
Crop.approved.where.not(id: crops_with_wikidata).order(plantings_count: :desc)
|
||||
|
||||
53
app/controllers/weather_observations_controller.rb
Normal file
53
app/controllers/weather_observations_controller.rb
Normal file
@@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WeatherObservationsController < DataController
|
||||
def index
|
||||
@owner = Member.find_by(slug: params[:member_slug])
|
||||
@show_all = params[:all] == '1'
|
||||
@show_jump_to = params[:member_slug].present? ? true : false
|
||||
|
||||
# @weather_observations = @weather_observations.includes(:owner)
|
||||
# @weather_observations = @weather_observations.active unless @show_all
|
||||
# @weather_observations = @weather_observations.where(owner: @owner) if @owner.present?
|
||||
# @weather_observations = @weather_observations.where.not(members: { confirmed_at: nil })
|
||||
# .order(:name).paginate(page: params[:page])
|
||||
respond_with(@weather_observations)
|
||||
end
|
||||
|
||||
def show
|
||||
respond_with(@weather_observation)
|
||||
end
|
||||
|
||||
def new
|
||||
@weather_observation = WeatherObservation.new
|
||||
respond_with(@weather_observation)
|
||||
end
|
||||
|
||||
def edit
|
||||
respond_with(@weather_observation)
|
||||
end
|
||||
|
||||
def create
|
||||
@weather_observation.owner_id = current_member.id
|
||||
flash[:notice] = I18n.t('weather_observations.created') if @weather_observation.save
|
||||
respond_with(@weather_observation)
|
||||
end
|
||||
|
||||
def update
|
||||
flash[:notice] = I18n.t('weather_observations.updated') if @weather_observation.update(weather_observation_params)
|
||||
respond_with(@weather_observation)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@weather_observation.destroy
|
||||
flash[:notice] = I18n.t('weather_observations.deleted')
|
||||
redirect_to(member_weather_observations_path(@weather_observation.owner))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def weather_observation_params
|
||||
params.require(:weather_observation).permit!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,6 +10,7 @@ class Garden < ApplicationRecord
|
||||
|
||||
has_many :plantings, dependent: :destroy
|
||||
has_many :crops, through: :plantings
|
||||
has_many :weather_observations, dependent: :destroy
|
||||
has_many :activities, dependent: :destroy
|
||||
has_many :garden_collaborators, dependent: :destroy
|
||||
|
||||
|
||||
22
app/models/weather_observation.rb
Normal file
22
app/models/weather_observation.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# A weather observation is intended to be a snapshot aligned to
|
||||
# https://github.com/schemaorg/schemaorg/issues/362
|
||||
class WeatherObservation < ApplicationRecord
|
||||
belongs_to :owner
|
||||
|
||||
validates :source, presence: true
|
||||
validates :observed_at, presence: true
|
||||
|
||||
attr_accessible :source, :observation_at, :solvar_uv_index, :dew_point_temperature_centigrade,
|
||||
:air_temperature_centigrade, :relative_humidity, :wind_speed_kmh, :wind_gust_speed_kmh, :owner_id, :wind_direction, :precipitation_probability, :pressure,
|
||||
:visibility_distance_metres, :weather_type
|
||||
|
||||
# Lowest temp on earth: -89.2°C (-128.6°F)
|
||||
# Highest: 56.7°C
|
||||
validates :dew_point_temperature_centigrade, numericality: { min: -90, max: 60 }, allow_nil: true
|
||||
validates :air_temperature_centigrade, numericality: { min: -90, max: 60 }, allow_nil: true
|
||||
validates :relative_humidity, numericality: { min: 0, max: 100 }, allow_nil: true
|
||||
validates :wind_speed_kmh, numericality: { min: 0, max: 450 }, allow_nil: true # Highest 408 km/h
|
||||
validates :wind_gust_speed_kmh, min: 0, max: 450, allow_nil: true # Highest 408 km/h
|
||||
end
|
||||
18
app/views/weather_observations/_actions.html.haml
Normal file
18
app/views/weather_observations/_actions.html.haml
Normal file
@@ -0,0 +1,18 @@
|
||||
- if can?(:edit, garden)
|
||||
.dropdown.garden-actions
|
||||
%a#garden-actions-button.btn.dropdown-toggle{"aria-expanded" => "false", "aria-haspopup" => "true", "data-toggle" => "dropdown", type: "button", href: '#'} Actions
|
||||
.dropdown-menu.dropdown-menu-xs{"aria-labelledby" => "garden-actions-button"}
|
||||
- if can?(:edit, garden)
|
||||
= garden_plant_something_button(garden, classes: 'dropdown-item') if garden.active
|
||||
- if garden.active
|
||||
= garden_mark_inactive_button(garden, classes: 'dropdown-item')
|
||||
- else
|
||||
= garden_mark_active_button(garden, classes: 'dropdown-item')
|
||||
|
||||
= garden_edit_button(garden, classes: 'dropdown-item')
|
||||
= add_photo_button(garden, classes: 'dropdown-item')
|
||||
|
||||
- if can?(:destroy, garden)
|
||||
.dropdown-divider
|
||||
= delete_button(garden, classes: 'dropdown-item text-danger',
|
||||
message: 'All plantings associated with this garden will also be deleted. Are you sure?')
|
||||
40
app/views/weather_observations/_form.html.haml
Normal file
40
app/views/weather_observations/_form.html.haml
Normal file
@@ -0,0 +1,40 @@
|
||||
.card.col-md-8.col-lg-7.mx-auto.float-none.white.z-depth-1.py-2.px-2
|
||||
= bootstrap_form_for(@garden) do |f|
|
||||
- if content_for? :title
|
||||
.card-header
|
||||
%h1.h2-responsive.text-center
|
||||
%strong=yield :title
|
||||
.card-body
|
||||
= required_field_help_text
|
||||
- if @garden.errors.any?
|
||||
#error_explanation.alert.alert-warning{:role => "alert"}
|
||||
%h4.alert-heading
|
||||
= pluralize(@garden.errors.size, "error")
|
||||
prohibited this garden from being saved
|
||||
%ul
|
||||
- @garden.errors.full_messages.each do |msg|
|
||||
%li= msg
|
||||
|
||||
= f.text_field :name, maxlength: 255, required: true
|
||||
= f.text_area :description, rows: 6
|
||||
= f.text_field :location,
|
||||
value: @garden.location || current_member.location,
|
||||
class: 'form-control', maxlength: 255
|
||||
%span.help-block
|
||||
= t('.location_helper')
|
||||
- if current_member.location.blank?
|
||||
= link_to "Set your location now.", edit_member_registration_path
|
||||
- else
|
||||
= link_to "Change your location.", edit_member_registration_path
|
||||
.row
|
||||
.col-md-5.col-12= f.number_field :area, class: 'input-small', step: "any"
|
||||
.col-md-7.col-12= f.select(:area_unit, Garden::AREA_UNITS_VALUES, { include_blank: false })
|
||||
.col-12= f.select(:garden_type_id, GardenType.all.order(:name).pluck(:name, :id),
|
||||
selected: @garden.garden_type_id, include_blank: true)
|
||||
.col-12
|
||||
= f.check_box :active, label: 'Active?'
|
||||
%p
|
||||
You can mark a garden as inactive if you no longer use it.
|
||||
Note: this will mark all plantings in the garden as "finished".
|
||||
.card-footer
|
||||
.text-right= f.submit 'Save Garden'
|
||||
20
app/views/weather_observations/_overview.html.haml
Normal file
20
app/views/weather_observations/_overview.html.haml
Normal file
@@ -0,0 +1,20 @@
|
||||
.panel.panel-success
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
= link_to garden.name, garden_path(garden)
|
||||
.panel-body
|
||||
.row
|
||||
.col-md-2.col-xs-12.garden-info
|
||||
%p= render 'gardens/photo', garden: garden
|
||||
%p= display_garden_description(garden)
|
||||
- if can?(:edit, garden)
|
||||
= render 'gardens/actions', garden: garden
|
||||
|
||||
.col-md-10
|
||||
- if garden.plantings.current.size.positive?
|
||||
.row
|
||||
- garden.plantings.current.order(created_at: :desc).includes(:crop, :photos).each do |planting|
|
||||
.col-lg-2.col-sm-4.col-xs-6
|
||||
= render "plantings/thumbnail", planting: planting
|
||||
- else
|
||||
no plantings
|
||||
3
app/views/weather_observations/_photo.html.haml
Normal file
3
app/views/weather_observations/_photo.html.haml
Normal file
@@ -0,0 +1,3 @@
|
||||
= link_to image_tag(garden_image_path(garden),
|
||||
alt: garden.name, class: 'img-responsive'),
|
||||
garden_path(garden)
|
||||
18
app/views/weather_observations/_previously.haml
Normal file
18
app/views/weather_observations/_previously.haml
Normal file
@@ -0,0 +1,18 @@
|
||||
%h2 Previously planted in this garden
|
||||
|
||||
- if @finished_plantings.any?
|
||||
- year = nil
|
||||
- @finished_plantings.where.not(planted_at: nil).order(planted_at: :desc).each do |planting|
|
||||
- if year != planting.planted_at.year
|
||||
- year = planting.planted_at.year
|
||||
%h4= year
|
||||
= render "plantings/tiny", planting: planting
|
||||
|
||||
- if @finished_plantings.where(planted_at: nil).any?
|
||||
%h4 Unknown year
|
||||
- @finished_plantings.where(planted_at: nil).each do |planting|
|
||||
= render "plantings/tiny", planting: planting
|
||||
- else
|
||||
.col-md-12
|
||||
%p Nothing has been planted here.
|
||||
|
||||
3
app/views/weather_observations/edit.html.haml
Normal file
3
app/views/weather_observations/edit.html.haml
Normal file
@@ -0,0 +1,3 @@
|
||||
= content_for :title, "Edit garden"
|
||||
|
||||
= render "form"
|
||||
65
app/views/weather_observations/index.html.haml
Normal file
65
app/views/weather_observations/index.html.haml
Normal file
@@ -0,0 +1,65 @@
|
||||
- content_for :title, @owner ? "#{@owner}'s weather_observations" : "Everyone's weather_observations"
|
||||
|
||||
%h1= @owner ? "#{@owner}'s weather_observations" : "Everyone's weather_observations"
|
||||
|
||||
- content_for :breadcrumbs do
|
||||
- if @owner
|
||||
%li.breadcrumb-item= link_to 'weather_observations', weather_observations_path
|
||||
%li.breadcrumb-item.active= link_to "#{@owner}'s weather_observations", member_weather_observations_path(@owner)
|
||||
- else
|
||||
%li.breadcrumb-item.active= link_to 'weather_observations', weather_observations_path
|
||||
|
||||
.row
|
||||
.col-md-2
|
||||
= render 'layouts/nav', model: weather_observation
|
||||
= link_to show_inactive_tickbox_path('weather_observations', owner: @owner, show_all: @show_all) do
|
||||
= check_box_tag 'active', 'all', @show_all
|
||||
include in-active
|
||||
- if @owner.present?
|
||||
%hr/
|
||||
= render @owner
|
||||
|
||||
.col-md-10
|
||||
- if @weather_observations.empty?
|
||||
%p There are no weather_observations to display.
|
||||
- if can?(:create, weather_observation) && @owner == current_member
|
||||
= link_to 'Add a weather_observation', new_weather_observation_path, class: 'btn btn-primary'
|
||||
|
||||
- else
|
||||
%section
|
||||
%h2= page_entries_info @weather_observations
|
||||
= will_paginate @weather_observations
|
||||
|
||||
- if @show_jump_to == true
|
||||
%section
|
||||
.jump
|
||||
jump to:
|
||||
- @weather_observations.each do |weather_observation|
|
||||
.badge.badge-primary
|
||||
- if @owner.present?
|
||||
= link_to weather_observation.weather_type, member_weather_observations_path(@owner, anchor: "weather_observation-#{weather_observation.id}")
|
||||
- else
|
||||
= link_to weather_observation.weather_type, weather_observations_path(anchor: "weather_observation-#{weather_observation.id}")
|
||||
- @weather_observations.each do |weather_observation|
|
||||
.card
|
||||
.card-header
|
||||
.row
|
||||
.col-12.col-md-3
|
||||
%h2= link_to weather_observation.weather_type, weather_observation, name: "weather_observation-#{weather_observation.id}"
|
||||
.row
|
||||
.col-md-3
|
||||
- if @owner.blank?
|
||||
owner:
|
||||
= render 'members/tiny', member: weather_observation.owner
|
||||
|
||||
.col-md-9
|
||||
%section
|
||||
= render 'weather_observations/actions', weather_observation: weather_observation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.row
|
||||
.col-12= page_entries_info @weather_observations
|
||||
.col-12= will_paginate @weather_observations
|
||||
3
app/views/weather_observations/new.html.haml
Normal file
3
app/views/weather_observations/new.html.haml
Normal file
@@ -0,0 +1,3 @@
|
||||
- content_for :title, "New weather observation"
|
||||
|
||||
= render 'form'
|
||||
117
app/views/weather_observations/show.html.haml
Normal file
117
app/views/weather_observations/show.html.haml
Normal file
@@ -0,0 +1,117 @@
|
||||
= content_for :title, "#{@weather_observation.owner}'s #{@weather_observation}"
|
||||
|
||||
- content_for :opengraph do
|
||||
- if @weather_observation.weather_type
|
||||
= tag("meta", property: "og:description", content: og_description(@weather_observation. - if @weather_observation.weather_type))
|
||||
= tag("meta", property: "og:title", content: "#{@weather_observation.owner}'s #{@weather_observation}")
|
||||
= 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'])
|
||||
|
||||
- content_for :breadcrumbs do
|
||||
%li.breadcrumb-item= link_to 'weather_observations', weather_observations_path
|
||||
%li.breadcrumb-item.active= link_to @weather_observation.weather_type, weather_observations_path(@weather_observation)
|
||||
|
||||
.row
|
||||
.col-md-9.col-12
|
||||
%h2.h1
|
||||
%strong= @weather_observation
|
||||
.col-md-3.col-12
|
||||
= render 'weather_observations/actions', weather_observation: @weather_observation
|
||||
.row
|
||||
%div
|
||||
%p
|
||||
:growstuff_markdown
|
||||
#{strip_tags @weather_observation.weather_type}
|
||||
- unless @weather_observation.description
|
||||
.row-fluid
|
||||
%p No description available yet.
|
||||
|
||||
- if can? :edit, @weather_observation
|
||||
%p
|
||||
Why not
|
||||
= link_to 'tell us more.', edit_weather_observation_path(@weather_observation)
|
||||
|
||||
- if @weather_observation.plantings.where.not(planted_at: nil).any?
|
||||
%section.card
|
||||
%h2 weather_observation progress
|
||||
.card-body
|
||||
= render 'plantings/progress_list', plantings: @weather_observation.plantings.active
|
||||
|
||||
%section
|
||||
%h2 Current plantings in weather_observation
|
||||
.index-cards
|
||||
- if @current_plantings.size.positive?
|
||||
- @current_plantings.each do |planting|
|
||||
= render "plantings/card", planting: planting
|
||||
- else
|
||||
.col-md-12
|
||||
%p Nothing is currently planted here.
|
||||
|
||||
%section.companions
|
||||
%h2 Suggestioned companions
|
||||
- @suggested_companions.each do |companion|
|
||||
= render 'crops/tiny', crop: companion
|
||||
|
||||
%section= render 'previously'
|
||||
|
||||
.col-md-3
|
||||
.card
|
||||
.card-image
|
||||
= image_tag weather_observation_image_path(@weather_observation), class: 'img-card', alt: 'photo of this weather_observation'
|
||||
.card-body
|
||||
%h4 About this weather_observation
|
||||
%p
|
||||
%strong Owner:
|
||||
= link_to @weather_observation.owner, @weather_observation.owner
|
||||
- if @weather_observation.location.present?
|
||||
%p
|
||||
%strong Location:
|
||||
= @weather_observation.location
|
||||
- if @weather_observation.area.present?
|
||||
%p
|
||||
%strong Area:
|
||||
= pluralize(@weather_observation.area, @weather_observation.area_unit)
|
||||
- if @weather_observation.weather_observation_type.present?
|
||||
%p
|
||||
%strong weather_observation type:
|
||||
= @weather_observation.weather_observation_type.name
|
||||
|
||||
.card
|
||||
.card-header
|
||||
%h4 #{@weather_observation.owner}'s weather_observations
|
||||
.card-body
|
||||
%ul.list-group.list-group-flush
|
||||
- @weather_observation.owner.weather_observations.active.order_by_name.each do |weather_observation|
|
||||
%li.list-group-item.list-group-flush
|
||||
= weather_observation_icon
|
||||
- if @weather_observation == weather_observation
|
||||
= @weather_observation
|
||||
- else
|
||||
= link_to weather_observation, weather_observation_path(weather_observation)
|
||||
|
||||
- unless @weather_observation.owner.weather_observations.inactive.empty?
|
||||
%h4 Inactive weather_observations
|
||||
%ul
|
||||
- @weather_observation.owner.weather_observations.inactive.order_by_name.each do |otherweather_observation|
|
||||
%li
|
||||
- if @weather_observation == otherweather_observation
|
||||
= @weather_observation.name
|
||||
- else
|
||||
= link_to otherweather_observation, weather_observation_path(otherweather_observation)
|
||||
|
||||
- if @weather_observation.owner == current_member
|
||||
%p
|
||||
= link_to new_weather_observation_path, class: 'btn btn-default btn-xs' do
|
||||
Add New weather_observation
|
||||
|
||||
- if can?(:edit, @weather_observation) && can?(:create, Photo)
|
||||
%%p
|
||||
= add_photo_button(@weather_observation)
|
||||
|
||||
- if @weather_observation.photos.size.positive?
|
||||
%section.photos
|
||||
%h2= localize_plural(@weather_observation.photos, Photo)
|
||||
.index-cards
|
||||
- @weather_observation.photos.includes(:owner).each do |photo|
|
||||
= render 'photos/thumbnail', photo: photo
|
||||
@@ -117,6 +117,7 @@ Rails.application.routes.draw do
|
||||
resources :plantings
|
||||
resources :harvests
|
||||
resources :posts
|
||||
resources :weather_observations
|
||||
resources :activities
|
||||
|
||||
resources :follows
|
||||
|
||||
24
db/migrate/20230916061712_add_weather_observations.rb
Normal file
24
db/migrate/20230916061712_add_weather_observations.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class AddWeatherObservations < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
# See https://github.com/schemaorg/schemaorg/issues/362
|
||||
create_table :weather_observations do |t|
|
||||
t.string :source
|
||||
t.datetime :observation_at
|
||||
t.integer :solar_uv_index
|
||||
t.decimal :wind_speed_kmh
|
||||
t.decimal :wind_gust_speed_kmh
|
||||
t.string :wind_direction
|
||||
t.decimal :air_temperature_centigrade
|
||||
t.decimal :relative_humidity
|
||||
t.decimal :precipitation_probability
|
||||
t.decimal :dew_point_temperature_centigrade
|
||||
t.decimal :pressure
|
||||
t.integer :visibility_distance_metres
|
||||
t.string :weather_type
|
||||
t.references :owner
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
20
db/schema.rb
20
db/schema.rb
@@ -970,6 +970,26 @@ ActiveRecord::Schema[7.2].define(version: 2025_12_01_045000) do
|
||||
t.index ["item_type", "item_id"], name: "index_versions_on_item_type_and_item_id"
|
||||
end
|
||||
|
||||
create_table "weather_observations", force: :cascade do |t|
|
||||
t.string "source"
|
||||
t.datetime "observation_at"
|
||||
t.integer "solar_uv_index"
|
||||
t.decimal "wind_speed_kmh"
|
||||
t.decimal "wind_gust_speed_kmh"
|
||||
t.string "wind_direction"
|
||||
t.decimal "air_temperature_centigrade"
|
||||
t.decimal "relative_humidity"
|
||||
t.decimal "precipitation_probability"
|
||||
t.decimal "dew_point_temperature_centigrade"
|
||||
t.decimal "pressure"
|
||||
t.integer "visibility_distance_metres"
|
||||
t.string "weather_type"
|
||||
t.bigint "owner_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["owner_id"], name: "index_weather_observations_on_owner_id"
|
||||
end
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "harvests", "plantings"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Api::V1::PlantingsController, type: :controller do
|
||||
RSpec.describe Api::V1::PlantingsController do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let!(:member) { create(:member) }
|
||||
@@ -42,7 +42,7 @@ RSpec.describe Api::V1::PlantingsController, type: :controller do
|
||||
|
||||
it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
|
||||
it { expect(matching_planting['attributes']).to eq expected_attributes }
|
||||
it { expect(response.status).to eq 200 }
|
||||
it { expect(response).to have_http_status :ok }
|
||||
end
|
||||
|
||||
context 'with photo' do
|
||||
@@ -81,7 +81,7 @@ RSpec.describe Api::V1::PlantingsController, type: :controller do
|
||||
|
||||
it { expect(matching_planting).to include('id' => my_planting.id.to_s) }
|
||||
it { expect(matching_planting['attributes']).to eq expected_attributes }
|
||||
it { expect(response.status).to eq 200 }
|
||||
it { expect(response).to have_http_status :ok }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe GardenTypesController, type: :controller do
|
||||
RSpec.describe GardenTypesController do
|
||||
include Devise::Test::ControllerHelpers
|
||||
|
||||
let(:valid_params) { { name: 'My second GardenType' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe GardensController, type: :controller do
|
||||
RSpec.describe GardensController do
|
||||
include Devise::Test::ControllerHelpers
|
||||
|
||||
let(:valid_params) { { name: 'My second Garden' } }
|
||||
|
||||
@@ -51,7 +51,7 @@ describe HarvestsController, :search do
|
||||
describe "generates a csv" do
|
||||
before { get :index, format: "csv" }
|
||||
|
||||
it { expect(response.status).to eq 200 }
|
||||
it { expect(response).to have_http_status :ok }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ describe LikesController do
|
||||
it { JSON.parse(response.body)["description"] == "1 like" }
|
||||
|
||||
describe "Liking someone else's post" do
|
||||
it { expect(response.code).to eq('201') }
|
||||
it { expect(response).to have_http_status(:created) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,14 +29,14 @@ describe LikesController do
|
||||
it { expect(response.content_type).to eq "application/json; charset=utf-8" }
|
||||
|
||||
describe "un-liking something i liked before" do
|
||||
it { expect(response.code).to eq('200') }
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
it { JSON.parse(response.body)["description"] == "0 likes" }
|
||||
end
|
||||
|
||||
describe "Deleting someone else's like" do
|
||||
let(:like) { create(:like) }
|
||||
|
||||
it { expect(response.code).to eq('403') }
|
||||
it { expect(response).to have_http_status(:forbidden) }
|
||||
it { JSON.parse(response.body)["error"] == "Unable to like" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe 'Test with visual testing', :js, type: :feature do
|
||||
describe 'Test with visual testing', :js do
|
||||
# Use the same random seed every time so our random data is the same
|
||||
# on every run, so doesn't trigger percy to see changes
|
||||
before { Faker::Config.random = Random.new(42) }
|
||||
|
||||
@@ -12,7 +12,7 @@ require 'rails_helper'
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe ButtonsHelper, type: :helper do
|
||||
RSpec.describe ButtonsHelper do
|
||||
before { allow(self).to receive(:can?).and_return(true) }
|
||||
|
||||
let(:garden) { create(:garden) }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EventHelper, type: :helper do
|
||||
RSpec.describe EventHelper do
|
||||
subject { resolve_model(event) }
|
||||
|
||||
let(:planting) { create(:planting) }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe CropCompanion, type: :model do
|
||||
RSpec.describe CropCompanion do
|
||||
it 'has a crop' do
|
||||
cc = described_class.new
|
||||
cc.crop_a = create :tomato
|
||||
|
||||
@@ -554,7 +554,7 @@ describe Crop do
|
||||
end
|
||||
|
||||
it "destroys companion links" do
|
||||
expect { crop_a.destroy }.to change { CropCompanion.count }.from(2).to(0)
|
||||
expect { crop_a.destroy }.to change(CropCompanion, :count).from(2).to(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -144,7 +144,7 @@ describe Harvest do
|
||||
it 'lists most recent harvests first' do
|
||||
@h1 = create(:harvest, created_at: 1.day.ago)
|
||||
@h2 = create(:harvest, created_at: 1.hour.ago)
|
||||
expect(described_class.all.order(created_at: :desc)).to eq [@h2, @h1]
|
||||
expect(described_class.order(created_at: :desc)).to eq [@h2, @h1]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Activities', type: :request do
|
||||
RSpec.describe 'Activities' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:member) { create(:member) }
|
||||
@@ -60,7 +60,7 @@ RSpec.describe 'Activities', type: :request do
|
||||
end
|
||||
end
|
||||
|
||||
context '#update' do
|
||||
describe '#update' do
|
||||
let(:params) do
|
||||
{
|
||||
'data' => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Crops', type: :request do
|
||||
RSpec.describe 'Crops' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Gardens', type: :request do
|
||||
RSpec.describe 'Gardens' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Harvests', type: :request do
|
||||
RSpec.describe 'Harvests' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Members', type: :request do
|
||||
RSpec.describe 'Members' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Photos', type: :request do
|
||||
RSpec.describe 'Photos' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Plantings', type: :request do
|
||||
RSpec.describe 'Plantings' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Seeds', type: :request do
|
||||
RSpec.describe 'Seeds' do
|
||||
subject { JSON.parse response.body }
|
||||
|
||||
let(:headers) { { 'Accept' => 'application/vnd.api+json' } }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "GardenTypes", type: :request do
|
||||
RSpec.describe "GardenTypes" do
|
||||
describe "GET /garden_types" do
|
||||
it "works! (now write some real specs)" do
|
||||
get garden_types_path
|
||||
|
||||
@@ -6,7 +6,7 @@ describe "Harvests" do
|
||||
describe "GET /harvests" do
|
||||
it "works! (now write some real specs)" do
|
||||
get harvests_path
|
||||
expect(response.status).to be 200
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe "places/_map_attribution.html.haml", type: :view do
|
||||
describe "places/_map_attribution.html.haml" do
|
||||
before do
|
||||
render
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user