Skip to content

Commit

Permalink
update app_settings_test and fix prepopulate thesis w/ committee memb…
Browse files Browse the repository at this point in the history
…ers test
  • Loading branch information
DevAdm committed Jul 31, 2024
1 parent bc169a2 commit 66d2071
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 58 deletions.
6 changes: 4 additions & 2 deletions app/controllers/theses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def new
@thesis.exam_date = record.examdate
@thesis.program = record.program
@thesis.assign_degree_name_and_level
@thesis.committee_members = record.committee_members
@thesis.committee_members = record.committee_members.map do |cm|
CommitteeMember.new(full_name: cm.full_name, role: cm.role, gem_record: record)
end

end

Expand Down Expand Up @@ -92,7 +94,7 @@ def update
if thesis_params.key?(:notes) && !thesis_params[:notes].blank?
redirect_to [@student, @thesis], alert: 'You cannot edit thesis notes' and return
end
end
end
# params[:thesis] = params[:thesis].reject { |p| Student::IMMUTABLE_THESIS_FIELDS.include?(p) } if current_user.role == User::STUDENT
## Need to check if thesis params are empty or not, if they are -> don't update
if @thesis.update(thesis_params)
Expand Down
14 changes: 10 additions & 4 deletions test/controllers/theses_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,22 @@ class ThesesControllerTest < ActionController::TestCase
end

should 'prepopulate the thesis if gem record id is passed and student ids match' do
record = create(:gem_record, sisid: @student.sisid)
record = create(:gem_record, sisid: @student.sisid, program: 'GS MA PSYC>CLDV - Faculty Of Graduate Studies, M.A., Psychology(Functional Area: Clinical-Developmental)')

get :new, params: { gem_record: record.id, student_id: @student.id }
get :new, params: { gem_record: record, student_id: @student.id }

thesis = assigns(:thesis)
assert thesis, 'ensure that thesis is assigned'

assert_equal record.committee_members.count, thesis.committee_members.count, 'Number of committee members should match'
post :create,
params: { student_id: @student.id,
thesis: thesis.attributes, committee_member_ids: record.committee_members.pluck(:id)}

saved_thesis = assigns(:thesis)

assert_equal record.committee_members.count, saved_thesis.committee_members.count, 'Number of committee members should match'
record.committee_members.each do |record_member|
thesis_member = thesis.committee_members.find { |tm| tm.first_name == record_member.first_name && tm.last_name == record_member.last_name && tm.role == record_member.role }
thesis_member = saved_thesis.committee_members.find { |tm| tm.first_name == record_member.first_name && tm.last_name == record_member.last_name && tm.role == record_member.role }
assert thesis_member, "Committee member #{record_member.first_name} #{record_member.last_name} should be present in the thesis"
end
assert_equal record.title, thesis.title, 'Title should be prepopulated'
Expand Down
98 changes: 47 additions & 51 deletions test/system/app_settings_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class AppSettingsTest < ApplicationSystemTestCase
assert_text "Supplementary Upload files Text Test"
end
end

test 'Student submission Review Licences message' do
user = FactoryGirl.create(:user, role: User::ADMIN)
login_as(user)
Expand Down Expand Up @@ -152,58 +152,54 @@ class AppSettingsTest < ApplicationSystemTestCase
click_button('Upload Primary File')
attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf'))
click_button('Upload')
within('div.student-view') do
assert_text "Review License Info Text Test"
assert_text "LAC licence Text Test"
assert_text "YorkSpace Non-Exclusive Distribution Licence Text Test"
assert_text "YorkU ETD Licence Text Test"
end
click_link('Accept and Continue')
click_link('Continue')
assert_selector 'div.student-view.fitted.submit > div', text: 'Review License Info Text Test'

click_button('Accept and Continue')
end

# test 'Student submission Submit Review message' do
# user = FactoryGirl.create(:user, role: User::ADMIN)
# login_as(user)
# visit root_url
# find('i.fa.fa-cog').click
# click_link("App Settings")
# click_button('Review Licenses')
# fill_in 'app_settings_student_review_license_info', with: 'Review License Info Text Test'
# fill_in 'app_settings_student_review_license_lac', with: 'LAC licence Text Test'
# fill_in 'app_settings_student_review_license_etd', with: 'YorkU ETD Licence Text Test'
# click_button('Save Settings')
# visit root_url
# click_link('Gem Records')
# click_link(@gem_record.studentname)
# click_link('Create ETD Student Record')
# page.accept_alert
# click_link('Start this thesis')
# select "EMBA", from: "thesis_degree_name"
# select "Master's", from: "thesis_degree_level"
# click_button('Create Thesis')
# assert_selector "a", text: @gem_record.studentname
# click_link("Students")
# click_link(@gem_record.studentname)
# click_link("Login as this student")
# fill_in 'student_email_external', with: '[email protected]'
# click_button('Continue')
# fill_in 'app_settings_student_update_details_abstract', with: 'Abstract Text Test'
# click_button('Continue')
# click_button('Upload Primary File')
# attach_file('document_file', Rails.root.join('test\fixtures\files\pdf-document.pdf'))
# click_button('Upload')
# click_button('Continue')
# click_button('Upload License Files')
# attach_file('document_file', Rails.root.join('test\fixtures\files\pdf-document.pdf'))
# click_button('Upload')
# check 'thesis_lac_licence_agreement'
# assert_selector "input[type=checkbox][id=thesis_lac_licence_agreement]:checked"
# check 'thesis_yorkspace_licence_agreement'
# assert_selector "input[type=checkbox][id=thesis_yorkspace_licence_agreement]:checked"
# check 'thesis_etd_licence_agreement'
# assert_selector "input[type=checkbox][id=thesis_etd_licence_agreement]:checked"
# click_button('Accept and Continue')
# end
test 'Student submission Submit Review message' do
user = FactoryGirl.create(:user, role: User::ADMIN)
login_as(user)
visit root_url
find('i.fa.fa-cog').click
click_link("App Settings")
click_button('Submit for Review')
find('trix-editor#app_settings_student_submit_for_review').click.set('Submit for Review Text Test')
click_button('Save Settings')
visit root_url
click_link('Gem Records')
click_link(@gem_record.studentname)
click_link('Create ETD Student Record')
page.accept_alert
click_link('Start this thesis')
select "EMBA", from: "thesis_degree_name"
select "Master's", from: "thesis_degree_level"
click_button('Create Thesis')
assert_selector "a", text: @gem_record.studentname
click_link("Students")
click_link(@gem_record.studentname)
click_link("Login as this student")
fill_in 'student_email_external', with: '[email protected]'
click_button('Continue')
fill_in 'thesis_abstract', with: 'Abstract Text Test'
click_link('Continue')
click_button('Upload Primary File')
attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf'))
click_button('Upload')
click_link('Continue')
click_button('Upload Licence Files')
attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf'))
click_button('Upload')
check 'thesis_lac_licence_agreement'
assert_selector "input[type=checkbox][id=thesis_lac_licence_agreement]:checked"
check 'thesis_yorkspace_licence_agreement'
assert_selector "input[type=checkbox][id=thesis_yorkspace_licence_agreement]:checked"
check 'thesis_etd_licence_agreement'
assert_selector "input[type=checkbox][id=thesis_etd_licence_agreement]:checked"
click_button('Accept and Continue')
assert_selector 'div.alert .alert-secondary > div', text: 'Submit for Review Text Test'
end
end

########################################
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

Capybara.server_host = '0.0.0.0'
Capybara.app_host = "http://#{Socket.gethostname}:#{Capybara.server_port}"
Capybara.default_max_wait_time = 5
Capybara.default_max_wait_time = 60

include ActionDispatch::TestProcess

Expand Down

0 comments on commit 66d2071

Please sign in to comment.