summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/application_system_test_case.rb5
-rw-r--r--test/controllers/crops_controller_test.rb48
-rw-r--r--test/controllers/dashboard_controller_test.rb8
-rw-r--r--test/controllers/fertilizer_products_controller_test.rb48
-rw-r--r--test/controllers/nutrient_measurement_controller_test.rb8
-rw-r--r--test/controllers/rafts_controller_test.rb7
-rw-r--r--test/controllers/recipes_controller_test.rb7
-rw-r--r--test/fixtures/beds.yml7
-rw-r--r--test/fixtures/crops.yml41
-rw-r--r--test/fixtures/fertilizer_products.yml9
-rw-r--r--test/fixtures/files/.keep0
-rw-r--r--test/fixtures/nutrient_measurements.yml39
-rw-r--r--test/fixtures/nutrients.yml9
-rw-r--r--test/fixtures/rafts.yml9
-rw-r--r--test/helpers/.keep0
-rw-r--r--test/integration/.keep0
-rw-r--r--test/mailers/.keep0
-rw-r--r--test/models/.keep0
-rw-r--r--test/models/bed_test.rb7
-rw-r--r--test/models/crop_test.rb7
-rw-r--r--test/models/fertilizer_composition_test.rb7
-rw-r--r--test/models/fertilizer_product_test.rb7
-rw-r--r--test/models/fertilizer_test.rb7
-rw-r--r--test/models/nutrient_measurement_test.rb7
-rw-r--r--test/models/nutrient_test.rb7
-rw-r--r--test/models/raft_test.rb7
-rw-r--r--test/system/.keep0
-rw-r--r--test/system/crops_test.rb75
-rw-r--r--test/system/fertilizer_products_test.rb43
-rw-r--r--test/test_helper.rb15
30 files changed, 434 insertions, 0 deletions
diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb
new file mode 100644
index 0000000..cee29fd
--- /dev/null
+++ b/test/application_system_test_case.rb
@@ -0,0 +1,5 @@
+require "test_helper"
+
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
+ driven_by :selenium, using: :headless_chrome, screen_size: [ 1400, 1400 ]
+end
diff --git a/test/controllers/crops_controller_test.rb b/test/controllers/crops_controller_test.rb
new file mode 100644
index 0000000..71821b1
--- /dev/null
+++ b/test/controllers/crops_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class CropsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @crop = crops(:one)
+ end
+
+ test "should get index" do
+ get crops_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_crop_url
+ assert_response :success
+ end
+
+ test "should create crop" do
+ assert_difference("Crop.count") do
+ post crops_url, params: { crop: { b: @crop.b, ca: @crop.ca, cl: @crop.cl, crop_type: @crop.crop_type, cu: @crop.cu, fe: @crop.fe, k: @crop.k, mg: @crop.mg, mn: @crop.mn, mo: @crop.mo, na: @crop.na, name: @crop.name, nnh4: @crop.nnh4, nno3: @crop.nno3, p: @crop.p, s: @crop.s, si: @crop.si, zn: @crop.zn } }
+ end
+
+ assert_redirected_to crop_url(Crop.last)
+ end
+
+ test "should show crop" do
+ get crop_url(@crop)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_crop_url(@crop)
+ assert_response :success
+ end
+
+ test "should update crop" do
+ patch crop_url(@crop), params: { crop: { b: @crop.b, ca: @crop.ca, cl: @crop.cl, crop_type: @crop.crop_type, cu: @crop.cu, fe: @crop.fe, k: @crop.k, mg: @crop.mg, mn: @crop.mn, mo: @crop.mo, na: @crop.na, name: @crop.name, nnh4: @crop.nnh4, nno3: @crop.nno3, p: @crop.p, s: @crop.s, si: @crop.si, zn: @crop.zn } }
+ assert_redirected_to crop_url(@crop)
+ end
+
+ test "should destroy crop" do
+ assert_difference("Crop.count", -1) do
+ delete crop_url(@crop)
+ end
+
+ assert_redirected_to crops_url
+ end
+end
diff --git a/test/controllers/dashboard_controller_test.rb b/test/controllers/dashboard_controller_test.rb
new file mode 100644
index 0000000..447c045
--- /dev/null
+++ b/test/controllers/dashboard_controller_test.rb
@@ -0,0 +1,8 @@
+require "test_helper"
+
+class DashboardControllerTest < ActionDispatch::IntegrationTest
+ test "should get index" do
+ get dashboard_index_url
+ assert_response :success
+ end
+end
diff --git a/test/controllers/fertilizer_products_controller_test.rb b/test/controllers/fertilizer_products_controller_test.rb
new file mode 100644
index 0000000..dbdd44f
--- /dev/null
+++ b/test/controllers/fertilizer_products_controller_test.rb
@@ -0,0 +1,48 @@
+require "test_helper"
+
+class FertilizerProductsControllerTest < ActionDispatch::IntegrationTest
+ setup do
+ @fertilizer_product = fertilizer_products(:one)
+ end
+
+ test "should get index" do
+ get fertilizer_products_url
+ assert_response :success
+ end
+
+ test "should get new" do
+ get new_fertilizer_product_url
+ assert_response :success
+ end
+
+ test "should create fertilizer_product" do
+ assert_difference("FertilizerProduct.count") do
+ post fertilizer_products_url, params: { fertilizer_product: { name: @fertilizer_product.name, purity: @fertilizer_product.purity } }
+ end
+
+ assert_redirected_to fertilizer_product_url(FertilizerProduct.last)
+ end
+
+ test "should show fertilizer_product" do
+ get fertilizer_product_url(@fertilizer_product)
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get edit_fertilizer_product_url(@fertilizer_product)
+ assert_response :success
+ end
+
+ test "should update fertilizer_product" do
+ patch fertilizer_product_url(@fertilizer_product), params: { fertilizer_product: { name: @fertilizer_product.name, purity: @fertilizer_product.purity } }
+ assert_redirected_to fertilizer_product_url(@fertilizer_product)
+ end
+
+ test "should destroy fertilizer_product" do
+ assert_difference("FertilizerProduct.count", -1) do
+ delete fertilizer_product_url(@fertilizer_product)
+ end
+
+ assert_redirected_to fertilizer_products_url
+ end
+end
diff --git a/test/controllers/nutrient_measurement_controller_test.rb b/test/controllers/nutrient_measurement_controller_test.rb
new file mode 100644
index 0000000..02523e0
--- /dev/null
+++ b/test/controllers/nutrient_measurement_controller_test.rb
@@ -0,0 +1,8 @@
+require "test_helper"
+
+class NutrientMeasurementControllerTest < ActionDispatch::IntegrationTest
+ test "should get index" do
+ get nutrient_measurement_index_url
+ assert_response :success
+ end
+end
diff --git a/test/controllers/rafts_controller_test.rb b/test/controllers/rafts_controller_test.rb
new file mode 100644
index 0000000..0d608d3
--- /dev/null
+++ b/test/controllers/rafts_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class RaftsControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/recipes_controller_test.rb b/test/controllers/recipes_controller_test.rb
new file mode 100644
index 0000000..2280833
--- /dev/null
+++ b/test/controllers/recipes_controller_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class RecipesControllerTest < ActionDispatch::IntegrationTest
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/fixtures/beds.yml b/test/fixtures/beds.yml
new file mode 100644
index 0000000..330db85
--- /dev/null
+++ b/test/fixtures/beds.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ number: 1
+
+two:
+ number: 1
diff --git a/test/fixtures/crops.yml b/test/fixtures/crops.yml
new file mode 100644
index 0000000..32cd3d5
--- /dev/null
+++ b/test/fixtures/crops.yml
@@ -0,0 +1,41 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: MyString
+ crop_type: 1
+ nno3: 1.5
+ p: 1.5
+ k: 1.5
+ ca: 1.5
+ mg: 1.5
+ s: 1.5
+ na: 1.5
+ cl: 1.5
+ si: 1.5
+ fe: 1.5
+ zn: 1.5
+ b: 1.5
+ mn: 1.5
+ cu: 1.5
+ mo: 1.5
+ nnh4: 1.5
+
+two:
+ name: MyString
+ crop_type: 1
+ nno3: 1.5
+ p: 1.5
+ k: 1.5
+ ca: 1.5
+ mg: 1.5
+ s: 1.5
+ na: 1.5
+ cl: 1.5
+ si: 1.5
+ fe: 1.5
+ zn: 1.5
+ b: 1.5
+ mn: 1.5
+ cu: 1.5
+ mo: 1.5
+ nnh4: 1.5
diff --git a/test/fixtures/fertilizer_products.yml b/test/fixtures/fertilizer_products.yml
new file mode 100644
index 0000000..5784aac
--- /dev/null
+++ b/test/fixtures/fertilizer_products.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ name: MyString
+ purity: 9.99
+
+two:
+ name: MyString
+ purity: 9.99
diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/fixtures/files/.keep
diff --git a/test/fixtures/nutrient_measurements.yml b/test/fixtures/nutrient_measurements.yml
new file mode 100644
index 0000000..8408647
--- /dev/null
+++ b/test/fixtures/nutrient_measurements.yml
@@ -0,0 +1,39 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ measured_on: 2025-08-20
+ nno3: 1.5
+ p: 1.5
+ k: 1.5
+ ca: 1.5
+ mg: 1.5
+ s: 1.5
+ na: 1.5
+ cl: 1.5
+ si: 1.5
+ fe: 1.5
+ zn: 1.5
+ b: 1.5
+ mn: 1.5
+ cu: 1.5
+ mo: 1.5
+ nnh4: 1.5
+
+two:
+ measured_on: 2025-08-20
+ nno3: 1.5
+ p: 1.5
+ k: 1.5
+ ca: 1.5
+ mg: 1.5
+ s: 1.5
+ na: 1.5
+ cl: 1.5
+ si: 1.5
+ fe: 1.5
+ zn: 1.5
+ b: 1.5
+ mn: 1.5
+ cu: 1.5
+ mo: 1.5
+ nnh4: 1.5
diff --git a/test/fixtures/nutrients.yml b/test/fixtures/nutrients.yml
new file mode 100644
index 0000000..f3c6fc9
--- /dev/null
+++ b/test/fixtures/nutrients.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ formula: MyString
+ name: MyString
+
+two:
+ formula: MyString
+ name: MyString
diff --git a/test/fixtures/rafts.yml b/test/fixtures/rafts.yml
new file mode 100644
index 0000000..1869e29
--- /dev/null
+++ b/test/fixtures/rafts.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+one:
+ bed: one
+ location: 1
+
+two:
+ bed: two
+ location: 1
diff --git a/test/helpers/.keep b/test/helpers/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/helpers/.keep
diff --git a/test/integration/.keep b/test/integration/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/.keep
diff --git a/test/mailers/.keep b/test/mailers/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/mailers/.keep
diff --git a/test/models/.keep b/test/models/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/models/.keep
diff --git a/test/models/bed_test.rb b/test/models/bed_test.rb
new file mode 100644
index 0000000..67b50da
--- /dev/null
+++ b/test/models/bed_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class BedTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/crop_test.rb b/test/models/crop_test.rb
new file mode 100644
index 0000000..52e4feb
--- /dev/null
+++ b/test/models/crop_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class CropTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/fertilizer_composition_test.rb b/test/models/fertilizer_composition_test.rb
new file mode 100644
index 0000000..5823d3e
--- /dev/null
+++ b/test/models/fertilizer_composition_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class FertilizerCompositionTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/fertilizer_product_test.rb b/test/models/fertilizer_product_test.rb
new file mode 100644
index 0000000..2da4ee7
--- /dev/null
+++ b/test/models/fertilizer_product_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class FertilizerProductTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/fertilizer_test.rb b/test/models/fertilizer_test.rb
new file mode 100644
index 0000000..71c9769
--- /dev/null
+++ b/test/models/fertilizer_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class FertilizerTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/nutrient_measurement_test.rb b/test/models/nutrient_measurement_test.rb
new file mode 100644
index 0000000..866c8f6
--- /dev/null
+++ b/test/models/nutrient_measurement_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class NutrientMeasurementTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/nutrient_test.rb b/test/models/nutrient_test.rb
new file mode 100644
index 0000000..61649ad
--- /dev/null
+++ b/test/models/nutrient_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class NutrientTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/raft_test.rb b/test/models/raft_test.rb
new file mode 100644
index 0000000..adb1ef0
--- /dev/null
+++ b/test/models/raft_test.rb
@@ -0,0 +1,7 @@
+require "test_helper"
+
+class RaftTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/system/.keep b/test/system/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/system/.keep
diff --git a/test/system/crops_test.rb b/test/system/crops_test.rb
new file mode 100644
index 0000000..bbf3e28
--- /dev/null
+++ b/test/system/crops_test.rb
@@ -0,0 +1,75 @@
+require "application_system_test_case"
+
+class CropsTest < ApplicationSystemTestCase
+ setup do
+ @crop = crops(:one)
+ end
+
+ test "visiting the index" do
+ visit crops_url
+ assert_selector "h1", text: "Crops"
+ end
+
+ test "should create crop" do
+ visit crops_url
+ click_on "New crop"
+
+ fill_in "B", with: @crop.b
+ fill_in "Ca", with: @crop.ca
+ fill_in "Cl", with: @crop.cl
+ fill_in "Crop type", with: @crop.crop_type
+ fill_in "Cu", with: @crop.cu
+ fill_in "Fe", with: @crop.fe
+ fill_in "K", with: @crop.k
+ fill_in "Mg", with: @crop.mg
+ fill_in "Mn", with: @crop.mn
+ fill_in "Mo", with: @crop.mo
+ fill_in "Na", with: @crop.na
+ fill_in "Name", with: @crop.name
+ fill_in "Nnh4", with: @crop.nnh4
+ fill_in "Nno3", with: @crop.nno3
+ fill_in "P", with: @crop.p
+ fill_in "S", with: @crop.s
+ fill_in "Si", with: @crop.si
+ fill_in "Zn", with: @crop.zn
+ click_on "Create Crop"
+
+ assert_text "Crop was successfully created"
+ click_on "Back"
+ end
+
+ test "should update Crop" do
+ visit crop_url(@crop)
+ click_on "Edit this crop", match: :first
+
+ fill_in "B", with: @crop.b
+ fill_in "Ca", with: @crop.ca
+ fill_in "Cl", with: @crop.cl
+ fill_in "Crop type", with: @crop.crop_type
+ fill_in "Cu", with: @crop.cu
+ fill_in "Fe", with: @crop.fe
+ fill_in "K", with: @crop.k
+ fill_in "Mg", with: @crop.mg
+ fill_in "Mn", with: @crop.mn
+ fill_in "Mo", with: @crop.mo
+ fill_in "Na", with: @crop.na
+ fill_in "Name", with: @crop.name
+ fill_in "Nnh4", with: @crop.nnh4
+ fill_in "Nno3", with: @crop.nno3
+ fill_in "P", with: @crop.p
+ fill_in "S", with: @crop.s
+ fill_in "Si", with: @crop.si
+ fill_in "Zn", with: @crop.zn
+ click_on "Update Crop"
+
+ assert_text "Crop was successfully updated"
+ click_on "Back"
+ end
+
+ test "should destroy Crop" do
+ visit crop_url(@crop)
+ click_on "Destroy this crop", match: :first
+
+ assert_text "Crop was successfully destroyed"
+ end
+end
diff --git a/test/system/fertilizer_products_test.rb b/test/system/fertilizer_products_test.rb
new file mode 100644
index 0000000..be82ed5
--- /dev/null
+++ b/test/system/fertilizer_products_test.rb
@@ -0,0 +1,43 @@
+require "application_system_test_case"
+
+class FertilizerProductsTest < ApplicationSystemTestCase
+ setup do
+ @fertilizer_product = fertilizer_products(:one)
+ end
+
+ test "visiting the index" do
+ visit fertilizer_products_url
+ assert_selector "h1", text: "Fertilizer products"
+ end
+
+ test "should create fertilizer product" do
+ visit fertilizer_products_url
+ click_on "New fertilizer product"
+
+ fill_in "Name", with: @fertilizer_product.name
+ fill_in "Purity", with: @fertilizer_product.purity
+ click_on "Create Fertilizer product"
+
+ assert_text "Fertilizer product was successfully created"
+ click_on "Back"
+ end
+
+ test "should update Fertilizer product" do
+ visit fertilizer_product_url(@fertilizer_product)
+ click_on "Edit this fertilizer product", match: :first
+
+ fill_in "Name", with: @fertilizer_product.name
+ fill_in "Purity", with: @fertilizer_product.purity
+ click_on "Update Fertilizer product"
+
+ assert_text "Fertilizer product was successfully updated"
+ click_on "Back"
+ end
+
+ test "should destroy Fertilizer product" do
+ visit fertilizer_product_url(@fertilizer_product)
+ click_on "Destroy this fertilizer product", match: :first
+
+ assert_text "Fertilizer product was successfully destroyed"
+ end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
new file mode 100644
index 0000000..0c22470
--- /dev/null
+++ b/test/test_helper.rb
@@ -0,0 +1,15 @@
+ENV["RAILS_ENV"] ||= "test"
+require_relative "../config/environment"
+require "rails/test_help"
+
+module ActiveSupport
+ class TestCase
+ # Run tests in parallel with specified workers
+ parallelize(workers: :number_of_processors)
+
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
+ fixtures :all
+
+ # Add more helper methods to be used by all tests here...
+ end
+end
Copyright 2019--2025 Marius PETER