From 4b048b515b56d07eca699093c576b321000ab298 Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 9 Jul 2024 13:17:01 -0400 Subject: [PATCH 01/12] first commit --- lib/tasks/gem_records_csv.rake | 14 +++++++++ lib/tasks/load_gem_records_csv.rb | 45 +++++++++++++++++++++++++++ test/helpers/load_gem_records_test.rb | 32 +++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 lib/tasks/gem_records_csv.rake create mode 100644 lib/tasks/load_gem_records_csv.rb create mode 100644 test/helpers/load_gem_records_test.rb diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake new file mode 100644 index 0000000..a7fb311 --- /dev/null +++ b/lib/tasks/gem_records_csv.rake @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require Rails.root.join('lib/tasks/load_gem_records_csv.rb') + +namespace :gem_records_csv do + desc 'Loading Gem Records.' + # Usage: cat /file/with/gem_records.txt | rake gem_records:load + + task load: :environment do + GemRecord.delete_all + gem_load = LoadGemRecordsCSV.new + gem_load.load_csv('dummy_gem_records.csv') + end +end diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb new file mode 100644 index 0000000..ae93e83 --- /dev/null +++ b/lib/tasks/load_gem_records_csv.rb @@ -0,0 +1,45 @@ +# frozen_string_literal: true + +## +# Function to load gem records from a text file, delimited by __ETD_COLSEP__ +## + +require 'csv' + +class LoadGemRecordsCSV + + def load_csv(filename) + count = 0 + + filename = File.join(File.dirname(__FILE__), filename) + + CSV.foreach(filename, headers: true) do |row| + seqgradevent = row['seqgradevent'].strip + unless GemRecord.find_by_seqgradevent(seqgradevent) + gr = GemRecord.new + gr.seqgradevent = seqgradevent + gr.studentname = row['studentname'].strip + gr.sisid = row['sisid'].strip + gr.emailaddress = row['emailaddress'].strip + gr.eventtype = row['eventtype'].strip + gr.eventdate = row['eventdate'].strip + gr.examresult = row['examresult'].strip + gr.title = row['title'].strip + gr.program = row['program'].strip + gr.superv = row['superv'].strip + gr.examdate = row['examdate'].strip + + if gr.save!(validate: false) + count += 1 + else + warn('Error: Load Gem Records Save Failed!') + warn("Error: #{gr.errors.inspect}") + end + end + rescue StandardError => e + warn("ERROR: #{e}") + warn('Hint: Possible Bad File if strip nil') + end + + end +end diff --git a/test/helpers/load_gem_records_test.rb b/test/helpers/load_gem_records_test.rb new file mode 100644 index 0000000..556d6c6 --- /dev/null +++ b/test/helpers/load_gem_records_test.rb @@ -0,0 +1,32 @@ +require 'test_helper' + +require Rails.root.join('lib/tasks/load_gem_records_csv.rb') +class LoadGemRecordsTest < ActiveSupport::TestCase + setup do + gem_load = LoadGemRecordsCSV.new + gem_load.load_csv + end + + should "parse csv" do + puts "\nRunning test..." + + assert_equal 3, GemRecord.count + + records = GemRecord.order(:seqgradevent) + + assert_equal 1, records[0].seqgradevent + assert_equal 'John Doe', records[0].studentname + assert_equal 123456, records[0].sisid + assert_equal 'johndoe@example.com', records[0].emailaddress + + assert_equal 2, records[1].seqgradevent + assert_equal 'Jane Smith', records[1].studentname + assert_equal 654321, records[1].sisid + assert_equal 'janesmith@example.com', records[1].emailaddress + + assert_equal 3, records[2].seqgradevent + assert_equal 'Alice Johnson', records[2].studentname + assert_equal 789012, records[2].sisid + assert_equal 'alicejohnson@example.com', records[2].emailaddress + end +end From b8a88c54db04c0b03ac366afbb4c6964ee580c0f Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 9 Jul 2024 14:46:05 -0400 Subject: [PATCH 02/12] fixed typo --- test/helpers/load_gem_records_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helpers/load_gem_records_test.rb b/test/helpers/load_gem_records_test.rb index 556d6c6..b234f99 100644 --- a/test/helpers/load_gem_records_test.rb +++ b/test/helpers/load_gem_records_test.rb @@ -4,7 +4,7 @@ class LoadGemRecordsTest < ActiveSupport::TestCase setup do gem_load = LoadGemRecordsCSV.new - gem_load.load_csv + gem_load.load_csv('dummy_gem_records.csv') end should "parse csv" do From fd55ddb8d8e5d5fc1c08d0f933d929ae54d684ef Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 9 Jul 2024 14:50:16 -0400 Subject: [PATCH 03/12] added dummy data gem records --- lib/tasks/dummy_gem_records.csv | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 lib/tasks/dummy_gem_records.csv diff --git a/lib/tasks/dummy_gem_records.csv b/lib/tasks/dummy_gem_records.csv new file mode 100644 index 0000000..6b3c2f0 --- /dev/null +++ b/lib/tasks/dummy_gem_records.csv @@ -0,0 +1,4 @@ +seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate +1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 +2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 +3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file From 9c501abc16bd215e33629e453279fbb07eb02e1d Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 9 Jul 2024 15:06:30 -0400 Subject: [PATCH 04/12] moved dummy record file and updated file path --- lib/{tasks => }/dummy_gem_records.csv | 0 lib/tasks/gem_records_csv.rake | 2 +- lib/tasks/load_gem_records_csv.rb | 2 -- test/helpers/load_gem_records_test.rb | 2 +- 4 files changed, 2 insertions(+), 4 deletions(-) rename lib/{tasks => }/dummy_gem_records.csv (100%) diff --git a/lib/tasks/dummy_gem_records.csv b/lib/dummy_gem_records.csv similarity index 100% rename from lib/tasks/dummy_gem_records.csv rename to lib/dummy_gem_records.csv diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake index a7fb311..7543cbf 100644 --- a/lib/tasks/gem_records_csv.rake +++ b/lib/tasks/gem_records_csv.rake @@ -9,6 +9,6 @@ namespace :gem_records_csv do task load: :environment do GemRecord.delete_all gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('dummy_gem_records.csv') + gem_load.load_csv('lib/dummy_gem_records.csv') end end diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb index ae93e83..b5a6fbf 100644 --- a/lib/tasks/load_gem_records_csv.rb +++ b/lib/tasks/load_gem_records_csv.rb @@ -11,8 +11,6 @@ class LoadGemRecordsCSV def load_csv(filename) count = 0 - filename = File.join(File.dirname(__FILE__), filename) - CSV.foreach(filename, headers: true) do |row| seqgradevent = row['seqgradevent'].strip unless GemRecord.find_by_seqgradevent(seqgradevent) diff --git a/test/helpers/load_gem_records_test.rb b/test/helpers/load_gem_records_test.rb index b234f99..c396804 100644 --- a/test/helpers/load_gem_records_test.rb +++ b/test/helpers/load_gem_records_test.rb @@ -4,7 +4,7 @@ class LoadGemRecordsTest < ActiveSupport::TestCase setup do gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('dummy_gem_records.csv') + gem_load.load_csv('lib/dummy_gem_records.csv') end should "parse csv" do From 8776582105870f8e0b1f6befde855dafb5b4d69b Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 9 Jul 2024 16:57:42 -0400 Subject: [PATCH 05/12] added arguments to rake file --- docker-compose.yml | 3 --- lib/tasks/gem_records_csv.rake | 9 +++++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 6492e47..5b6db04 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,9 +23,6 @@ services: - RAILS_SERVE_STATIC_FILES=true - NODE_OPTIONS=--openssl-legacy-provider - SELENIUM_SERVER=chrome-server - env_file: - - path: ./override.env - required: false db: image: mysql diff --git a/lib/tasks/gem_records_csv.rake b/lib/tasks/gem_records_csv.rake index 7543cbf..0474dfa 100644 --- a/lib/tasks/gem_records_csv.rake +++ b/lib/tasks/gem_records_csv.rake @@ -6,9 +6,14 @@ namespace :gem_records_csv do desc 'Loading Gem Records.' # Usage: cat /file/with/gem_records.txt | rake gem_records:load - task load: :environment do + task :load, [:filename] => :environment do |t, args| + filename = args[:filename] + if filename.nil? || filename.empty? + puts "Error: Filename is required" + exit 1 + end GemRecord.delete_all gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('lib/dummy_gem_records.csv') + gem_load.load_csv(filename) end end From e1ccdd6a08aa72642c71796412c00b54c30614fe Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 9 Jul 2024 17:01:16 -0400 Subject: [PATCH 06/12] reset docker compose --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 5b6db04..6492e47 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,9 @@ services: - RAILS_SERVE_STATIC_FILES=true - NODE_OPTIONS=--openssl-legacy-provider - SELENIUM_SERVER=chrome-server + env_file: + - path: ./override.env + required: false db: image: mysql From f8e6ea70363b1c9ba7c1d3ea7d1fd643842c9481 Mon Sep 17 00:00:00 2001 From: DevAdm Date: Wed, 10 Jul 2024 10:11:35 -0400 Subject: [PATCH 07/12] moved load gem records test to lib folder --- test/{helpers => lib}/load_gem_records_test.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{helpers => lib}/load_gem_records_test.rb (100%) diff --git a/test/helpers/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb similarity index 100% rename from test/helpers/load_gem_records_test.rb rename to test/lib/load_gem_records_test.rb From 7c94f4ed4ca46fd81a8ed98b3231095df89eb156 Mon Sep 17 00:00:00 2001 From: dennis Date: Mon, 15 Jul 2024 16:57:36 -0400 Subject: [PATCH 08/12] updated with committee members in gem records --- lib/dummy_gem_records.csv | 8 ++++---- lib/tasks/load_gem_records_csv.rb | 11 +++++++++++ test/lib/load_gem_records_test.rb | 27 +++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/lib/dummy_gem_records.csv b/lib/dummy_gem_records.csv index 6b3c2f0..55aaebc 100644 --- a/lib/dummy_gem_records.csv +++ b/lib/dummy_gem_records.csv @@ -1,4 +1,4 @@ -seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate -1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 -2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 -3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file +seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate,committee_members +1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01,"John,Smith,Chair;Jane,Doe,Committee Member" +2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02,"Jim,Brown,Chair;Jake,White,Committee Member" +3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03, "Eve Green:Chair,Frank Black:Committee Member" \ No newline at end of file diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb index b5a6fbf..204569a 100644 --- a/lib/tasks/load_gem_records_csv.rb +++ b/lib/tasks/load_gem_records_csv.rb @@ -28,6 +28,17 @@ def load_csv(filename) gr.examdate = row['examdate'].strip if gr.save!(validate: false) + committee_members = row['committee_members'].split(';') + committee_members.each do |member| + first_name, last_name, role = member.split(',') + CommitteeMember.create!( + gem_record: gr, + first_name: first_name.strip, + last_name: last_name.strip, + role: role.strip + ) + end + count += 1 else warn('Error: Load Gem Records Save Failed!') diff --git a/test/lib/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb index c396804..26d5874 100644 --- a/test/lib/load_gem_records_test.rb +++ b/test/lib/load_gem_records_test.rb @@ -28,5 +28,32 @@ class LoadGemRecordsTest < ActiveSupport::TestCase assert_equal 'Alice Johnson', records[2].studentname assert_equal 789012, records[2].sisid assert_equal 'alicejohnson@example.com', records[2].emailaddress + + assert_equal 2, records[0].committee_members.count + assert_equal 'John', records[0].committee_members.first.first_name + assert_equal 'Smith', records[0].committee_members.first.last_name + assert_equal 'Chair', records[0].committee_members.first.role + + assert_equal 'Jane', records[0].committee_members.last.first_name + assert_equal 'Doe', records[0].committee_members.last.last_name + assert_equal 'Committee Member', records[0].committee_members.last.role + + assert_equal 2, records[1].committee_members.count + assert_equal 'Jim', records[1].committee_members.first.first_name + assert_equal 'Brown', records[1].committee_members.first.last_name + assert_equal 'Chair', records[1].committee_members.first.role + + assert_equal 'Jake', records[1].committee_members.last.first_name + assert_equal 'White', records[1].committee_members.last.last_name + assert_equal 'Committee Member', records[1].committee_members.last.role + + assert_equal 2, records[2].committee_members.count + assert_equal 'Eve', records[2].committee_members.first.first_name + assert_equal 'Green', records[2].committee_members.first.last_name + assert_equal 'Chair', records[2].committee_members.first.role + + assert_equal 'Frank', records[2].committee_members.last.first_name + assert_equal 'Black', records[2].committee_members.last.last_name + assert_equal 'Committee Member', records[2].committee_members.last.role end end From 9db3ff99b54b01f7c5b3b9fcb0ef30c38075f364 Mon Sep 17 00:00:00 2001 From: DevAdm Date: Tue, 16 Jul 2024 10:23:19 -0400 Subject: [PATCH 09/12] added gem_record_id in committee_member --- app/controllers/committee_members_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/committee_members_controller.rb b/app/controllers/committee_members_controller.rb index 7dc631e..a5ecb9b 100644 --- a/app/controllers/committee_members_controller.rb +++ b/app/controllers/committee_members_controller.rb @@ -44,6 +44,6 @@ def destroy private def committee_member_params - params.require(:committee_member).permit(:first_name, :last_name, :role, :thesis_id) + params.require(:committee_member).permit(:first_name, :last_name, :role, :thesis_id, :gem_record_id) end end From 944a32bc5397454bb6e96971f75f2eba6648b6d7 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Wed, 17 Jul 2024 19:18:11 -0400 Subject: [PATCH 10/12] add committee members belongs to gem record association --- app/models/committee_member.rb | 1 + app/models/gem_record.rb | 2 ++ ..._add_gem_record_id_to_committee_members.rb | 5 +++ db/schema.rb | 3 +- lib/dummy_gem_records.csv | 4 --- lib/tasks/load_gem_records_csv.rb | 33 +++++++++++-------- test/fixtures/files/committee_members.csv | 7 ++++ test/fixtures/files/gem_records.csv | 4 +++ test/lib/load_gem_records_test.rb | 5 ++- 9 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb delete mode 100644 lib/dummy_gem_records.csv create mode 100644 test/fixtures/files/committee_members.csv create mode 100644 test/fixtures/files/gem_records.csv diff --git a/app/models/committee_member.rb b/app/models/committee_member.rb index 3c755b3..91ebd7a 100644 --- a/app/models/committee_member.rb +++ b/app/models/committee_member.rb @@ -13,6 +13,7 @@ class CommitteeMember < ApplicationRecord ## RELATIONS ## belongs_to :thesis + belongs_to :gem_record ## VALIDATIONS ## validates_presence_of :first_name, message: 'Please choose a name.' diff --git a/app/models/gem_record.rb b/app/models/gem_record.rb index baba38b..87d02c9 100644 --- a/app/models/gem_record.rb +++ b/app/models/gem_record.rb @@ -14,6 +14,8 @@ class GemRecord < ApplicationRecord MASTERS_EXAM = "Master's Thesis Exam" ACCEPTED = 'Accepted' + has_many :committee_members + scope :completed, lambda { where('eventtype = ? OR eventtype = ?', GemRecord::PHD_COMPLETED, GemRecord::MASTERS_COMPLETED) } diff --git a/db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb b/db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb new file mode 100644 index 0000000..18508fb --- /dev/null +++ b/db/migrate/20240717225736_add_gem_record_id_to_committee_members.rb @@ -0,0 +1,5 @@ +class AddGemRecordIdToCommitteeMembers < ActiveRecord::Migration[7.0] + def change + add_column :committee_members, :gem_record_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index ac53eec..d36be1a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_06_11_142734) do +ActiveRecord::Schema[7.0].define(version: 2024_07_17_225736) do create_table "action_text_rich_texts", charset: "utf8mb3", force: :cascade do |t| t.string "name", null: false t.text "body", size: :long @@ -79,6 +79,7 @@ t.datetime "updated_at", precision: nil, null: false t.string "first_name" t.string "last_name" + t.integer "gem_record_id" end create_table "delayed_jobs", id: :integer, charset: "utf8mb3", force: :cascade do |t| diff --git a/lib/dummy_gem_records.csv b/lib/dummy_gem_records.csv deleted file mode 100644 index 55aaebc..0000000 --- a/lib/dummy_gem_records.csv +++ /dev/null @@ -1,4 +0,0 @@ -seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate,committee_members -1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01,"John,Smith,Chair;Jane,Doe,Committee Member" -2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02,"Jim,Brown,Chair;Jake,White,Committee Member" -3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03, "Eve Green:Chair,Frank Black:Committee Member" \ No newline at end of file diff --git a/lib/tasks/load_gem_records_csv.rb b/lib/tasks/load_gem_records_csv.rb index 204569a..1ee16dc 100644 --- a/lib/tasks/load_gem_records_csv.rb +++ b/lib/tasks/load_gem_records_csv.rb @@ -1,17 +1,18 @@ # frozen_string_literal: true ## -# Function to load gem records from a text file, delimited by __ETD_COLSEP__ +# Function to load gem records from a CSV file ## require 'csv' class LoadGemRecordsCSV - def load_csv(filename) + def load_gem_records(filename) count = 0 - CSV.foreach(filename, headers: true) do |row| + converter = lambda { |header| header.downcase } + CSV.foreach(filename, headers: true, header_converters: converter) do |row| seqgradevent = row['seqgradevent'].strip unless GemRecord.find_by_seqgradevent(seqgradevent) gr = GemRecord.new @@ -28,17 +29,6 @@ def load_csv(filename) gr.examdate = row['examdate'].strip if gr.save!(validate: false) - committee_members = row['committee_members'].split(';') - committee_members.each do |member| - first_name, last_name, role = member.split(',') - CommitteeMember.create!( - gem_record: gr, - first_name: first_name.strip, - last_name: last_name.strip, - role: role.strip - ) - end - count += 1 else warn('Error: Load Gem Records Save Failed!') @@ -49,6 +39,21 @@ def load_csv(filename) warn("ERROR: #{e}") warn('Hint: Possible Bad File if strip nil') end + end + + def load_committee_members(filename) + count = 0 + converter = lambda { |header| header.downcase } + CSV.foreach(filename, headers: true, header_converters: converter) do |row| + seqgradevent = row['seqgradevent'].strip + gr = GemRecord.find_by_seqgradevent(seqgradevent) + cm = CommitteeMember.new + cm.gem_record = gr + cm.first_name = row['firstname'].strip + cm.last_name = row['surname'].strip + cm.role = row['role'].strip + cm.save! + end end end diff --git a/test/fixtures/files/committee_members.csv b/test/fixtures/files/committee_members.csv new file mode 100644 index 0000000..edc6928 --- /dev/null +++ b/test/fixtures/files/committee_members.csv @@ -0,0 +1,7 @@ +"SEQGRADEVENT","SISID","FIRSTNAME","SURNAME","ROLE" +1,12345,"John","Smith","Chair" +1,12345,"Jane","Doe","Committee Member" +2,654321,"Jim","Brown","Chair" +2,654321,"Jake","White","Committee Member" +3,789012,"Eve","Green","Chair" +3,789012,"Frank","Black","Committee Member" diff --git a/test/fixtures/files/gem_records.csv b/test/fixtures/files/gem_records.csv new file mode 100644 index 0000000..6b3c2f0 --- /dev/null +++ b/test/fixtures/files/gem_records.csv @@ -0,0 +1,4 @@ +seqgradevent,studentname,sisid,emailaddress,eventtype,eventdate,examresult,title,program,superv,examdate +1,John Doe,123456,johndoe@example.com,Exam,2023-06-15,Pass,Thesis Title,Program A,Supervisor X,2023-07-01 +2,Jane Smith,654321,janesmith@example.com,Defense,2023-06-20,Pass,Thesis Title B,Program B,Supervisor Y,2023-07-02 +3,Alice Johnson,789012,alicejohnson@example.com,Exam,2023-06-25,Fail,Thesis Title C,Program C,Supervisor Z,2023-07-03 \ No newline at end of file diff --git a/test/lib/load_gem_records_test.rb b/test/lib/load_gem_records_test.rb index 26d5874..9bbfd55 100644 --- a/test/lib/load_gem_records_test.rb +++ b/test/lib/load_gem_records_test.rb @@ -4,12 +4,11 @@ class LoadGemRecordsTest < ActiveSupport::TestCase setup do gem_load = LoadGemRecordsCSV.new - gem_load.load_csv('lib/dummy_gem_records.csv') + gem_load.load_gem_records("test/fixtures/files/gem_records.csv") + gem_load.load_committee_members("test/fixtures/files/committee_members.csv") end should "parse csv" do - puts "\nRunning test..." - assert_equal 3, GemRecord.count records = GemRecord.order(:seqgradevent) From d784bd98e380ef334a9c7cca4793944ae76d9335 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Wed, 17 Jul 2024 21:38:57 -0400 Subject: [PATCH 11/12] increase Capybara max wait time and use headless chrome --- test/application_system_test_case.rb | 2 +- test/test_helper.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index ba34155..81ba0a1 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -3,7 +3,7 @@ require 'test_helper' class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: { + driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400], options: { browser: :remote, url: "http://#{ENV.fetch('SELENIUM_SERVER')}:4444" } diff --git a/test/test_helper.rb b/test/test_helper.rb index 812ca9c..cc7a0d7 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,6 +24,7 @@ Capybara.server_host = '0.0.0.0' Capybara.app_host = "http://#{Socket.gethostname}:#{Capybara.server_port}" +Capybara.default_max_wait_time = 5 include ActionDispatch::TestProcess From 7d483a52ca51916f7fd1c1b83854fc6f18a5c810 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Wed, 17 Jul 2024 22:17:24 -0400 Subject: [PATCH 12/12] require 'helpers/system_test_helper' --- test/system/students_test.rb | 5 +---- test/system/theses_test.rb | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/system/students_test.rb b/test/system/students_test.rb index 28b80e8..ddd48da 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'application_system_test_case' -require_relative '../helpers/system_test_helper' +require 'helpers/system_test_helper' class StudentsTest < ApplicationSystemTestCase include SystemTestHelper # Include the SystemTestHelper module here @@ -26,11 +26,8 @@ class StudentsTest < ApplicationSystemTestCase visit root_url fill_in('Non-YorkU Email Address', with: Faker::Internet.email) click_button('Continue') - puts "\nGoing to Update Details\n" click_link('Continue') #update - puts "Going to Upload\n" click_link('Continue') #upload - puts "Going to Review\n" click_link('Continue') #review assert_selector '.alert-warning', text: 'Error: You have to upload a primary file to continue' # page.accept_alert diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index c3b1816..c9650be 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'application_system_test_case' +require 'helpers/system_test_helper' class ThesesTest < ApplicationSystemTestCase setup do