Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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 @@ -187,18 +187,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 @@ -404,13 +404,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 @@ -430,9 +429,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 @@ -457,7 +453,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 @@ -737,7 +732,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
2 changes: 1 addition & 1 deletion crowdin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ files:
ignore:
- '/config/locales/ja.yml'
- source: '/config/locales/*.en.yml'
translation: '/config/locales/%file_name%.%two_letters_code%.yml'
translation: '/config/locales/%file_name%.%two_letters_code%.yml'
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
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@
t.integer "harvests_count", default: 0
t.integer "likes_count", default: 0
t.boolean "failed", default: false, null: false
t.boolean "from_other_source"
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"
Expand Down
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
2 changes: 0 additions & 2 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
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
Loading