Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ group :development, :test do
gem 'rubocop-rspec_rails'
gem 'webrat' # provides HTML matchers for view tests

gem 'crowdin-cli' # for translations
gem 'crowdin-cli' # for translations
gem 'dotenv-rails'

# cli utils
Expand All @@ -188,18 +188,16 @@ end
group :test do
gem 'axe-core-capybara'
gem 'axe-core-rspec'
gem "percy-capybara", "~> 5.0.0"
gem 'rails-controller-testing'
gem "rspec-rebound"
gem 'selenium-webdriver'
gem 'timecop'
gem 'vcr'
gem "rspec-rebound"
gem "percy-capybara", "~> 5.0.0"
end

group :travis do
gem 'platform-api'
end



gem "i18n_data", "~> 1.1"
8 changes: 1 addition & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,12 @@ GEM
mime-types (3.7.0)
logger
mime-types-data (~> 3.2025, >= 3.2025.0507)
mime-types-data (3.2025.0805)
mime-types-data (3.2025.0826)
mimemagic (0.4.3)
nokogiri (~> 1)
rake
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.9)
minitest (5.25.5)
moneta (1.0.0)
msgpack (1.8.0)
Expand All @@ -436,9 +435,6 @@ GEM
net-protocol
netrc (0.11.0)
nio4r (2.7.4)
nokogiri (1.18.9)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.18.9-x86_64-linux-gnu)
racc (~> 1.4)
oauth (0.5.6)
Expand All @@ -463,7 +459,6 @@ GEM
racc
percy-capybara (5.0.0)
capybara (>= 3)
pg (1.6.1)
pg (1.6.1-x86_64-linux)
platform-api (3.8.0)
heroics (~> 0.1.1)
Expand Down Expand Up @@ -744,7 +739,6 @@ GEM
zeitwerk (2.7.3)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/plantings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def create
end

def update
if planting_params[:from_other_source] == 'true'
@planting.parent_seed_id = nil
@planting.from_other_source = true
end
@planting.update(planting_params)
respond_with @planting
end
Expand Down Expand Up @@ -131,7 +135,7 @@ def planting_params
params[:planted_at] = parse_date(params[:planted_at]) if params[:planted_at]
params.require(:planting).permit(
:crop_id, :description, :garden_id, :planted_at,
:parent_seed_id,
:parent_seed_id, :from_other_source,
:quantity, :sunniness, :planted_from, :finished,
:finished_at, :failed
)
Expand Down
2 changes: 2 additions & 0 deletions app/models/planting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Planting < ApplicationRecord

friendly_id :planting_slug, use: %i(slugged finders)

attr_accessor :from_other_source

# Constants
SUNNINESS_VALUES = %w(sun semi-shade shade).freeze
PLANTED_FROM_VALUES = [
Expand Down
1 change: 1 addition & 0 deletions app/views/plantings/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
Is this from one of these plantings?
- @matching_seeds.each do |seed|
= f.radio_button :parent_seed_id, seed.id, label: seed
= f.radio_button :parent_seed_id, 'other', label: 'Other source'
= f.submit "save", class: 'btn btn-sm'

.planting
Expand Down
22 changes: 0 additions & 22 deletions crowdin.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class AddFromOtherSourceToPlantings < ActiveRecord::Migration[7.1]
def change
add_column :plantings, :from_other_source, :boolean
end
end
11 changes: 11 additions & 0 deletions spec/features/plantings/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
it { expect(page).to have_text 'Parent seed' }
it { expect(page).to have_link href: planting_path(planting) }
end

describe 'selecting other source' do
before do
choose 'Other source'
click_button 'save'
end

it "hides the seed source question" do
expect(page).to have_no_text 'Is this from one of these plantings?'
end
end
end
end
end
13 changes: 5 additions & 8 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
require 'axe-capybara'
require 'axe-rspec'

# TODO: We may want to trial options.add_argument('--disable-dev-shm-usage') ### optional

# Required for running in the dev container
Capybara.register_driver :selenium_chrome_customised_headless do |app|
options = Selenium::WebDriver::Options.chrome
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--window-size=1920,1080")
options.add_argument("--disable-dev-shm-usage")

# driver = Selenium::WebDriver.for :chrome, options: options

Expand Down Expand Up @@ -120,8 +120,8 @@
# Prevent Poltergeist from fetching external URLs during feature tests
config.before(:each, :js) do
# TODO: Why are we setting this page size then straight afterwards, maximising?
width = 1920
height = 1080
width = 1280
height = 1280
Capybara.current_session.driver.browser.manage.window.resize_to(width, height)

if page.driver.browser.respond_to?(:url_blacklist)
Expand All @@ -132,9 +132,6 @@
]
end

# Historically, we wanted to .maximize; but this actually undoes the resize_to step above
# with chrome headless
# page.driver.browser.manage.window.maximize if page.driver.browser.respond_to?(:manage)
# puts "Maximized window size: #{page.driver.browser.manage.window.size}"
page.driver.browser.manage.window.maximize if page.driver.browser.respond_to?(:manage)
end
end
Loading