diff --git a/app/models/thesis.rb b/app/models/thesis.rb index 74cf7a7..790eb22 100644 --- a/app/models/thesis.rb +++ b/app/models/thesis.rb @@ -35,6 +35,7 @@ def certify_content_correct_present has_many :thesis_subjectships, dependent: :delete_all has_many :loc_subjects, through: :thesis_subjectships + validates_presence_of :loc_subjects, if: :updating_by_student? belongs_to :assigned_to, foreign_key: 'assigned_to_id', class_name: 'User' belongs_to :embargoed_by, foreign_key: 'embargoed_by_id', class_name: 'User' diff --git a/app/views/student_view/process/review.html.erb b/app/views/student_view/process/review.html.erb index 873f967..5d9aa5b 100644 --- a/app/views/student_view/process/review.html.erb +++ b/app/views/student_view/process/review.html.erb @@ -28,7 +28,7 @@ <%= simple_form_for([@current_user, @thesis], url: accept_licences_student_thesis_path(@current_user, @thesis), method: :post, html: { class: "p-0" }) do |f| %> <% if @thesis.errors.any? %>
-

<%= pluralize(@thesis.errors.count, "error") %> prohibited this thesis from being saved:

+

<%= pluralize(@thesis.errors.count, "error") %>

<%= simple_form_for [@student, @thesis], html: { class: "form-horizontal border border-2 bg-light" } do |f| %> + <% if @thesis.errors.any? %> +
+

<%= pluralize(@thesis.errors.count, "error") %>

+ +
+ <% end %> +

Please provide the information requested in the following fields.

<%= render partial: "theses/form_student_editable", locals: { f: f } %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0653957..95ee2dd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -20,4 +20,7 @@ # available at http://guides.rubyonrails.org/i18n.html. en: - hello: "Hello world" + activerecord: + attributes: + thesis: + loc_subjects: "Subject" diff --git a/db/seeds.rb b/db/seeds.rb index e52f7cf..20cb798 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # rails db:seed -LocSubject.load_from_file('lib/loc_subjects.txt') if (Rails.env != 'test') && LocSubject.all.count.zero? +LocSubject.load_from_file('lib/loc_subjects.txt') if LocSubject.all.count.zero? if (Rails.env != 'test') && User.all.count.zero? [User::ADMIN, User::MANAGER, User::STAFF].each do |role| diff --git a/test/controllers/theses_controller_test.rb b/test/controllers/theses_controller_test.rb index 731454d..799919e 100644 --- a/test/controllers/theses_controller_test.rb +++ b/test/controllers/theses_controller_test.rb @@ -345,7 +345,8 @@ class ThesesControllerTest < ActionController::TestCase context 'as a student' do setup do @student = create(:student) - @thesis = create(:thesis, student: @student, status: Thesis::OPEN) + @thesis = create(:thesis, student: @student, status: Thesis::OPEN, loc_subjects: create_list(:loc_subject, 1)) + log_user_in(@student) end diff --git a/test/models/thesis_test.rb b/test/models/thesis_test.rb index 3043dd7..e298b40 100644 --- a/test/models/thesis_test.rb +++ b/test/models/thesis_test.rb @@ -34,7 +34,7 @@ class ThesisTest < ActiveSupport::TestCase should 'not validate presence of certify_content_correct if updating by student but not submitting for review' do student_user = create(:student) - thesis = build(:thesis, current_user: student_user, certify_content_correct: nil) + thesis = build(:thesis, current_user: student_user, certify_content_correct: nil, loc_subjects: create_list(:loc_subject, 1)) assert thesis.valid?, 'Should validate thesis if certify_content_correct is missing for students when not submitting for review' end @@ -68,7 +68,7 @@ class ThesisTest < ActiveSupport::TestCase should 'not validate presence of licence agreements if updating by student but not accepting licences' do student_user = create(:student) - thesis = build(:thesis, current_user: student_user, lac_licence_agreement: nil, yorkspace_licence_agreement: nil, etd_licence_agreement: nil) + thesis = build(:thesis, current_user: student_user, lac_licence_agreement: nil, yorkspace_licence_agreement: nil, etd_licence_agreement: nil, loc_subjects: create_list(:loc_subject, 1)) assert thesis.valid?, 'Should validate thesis if licence agreements are missing for students when not accepting licences' end diff --git a/test/system/app_settings_test.rb b/test/system/app_settings_test.rb index afec16c..b7dede9 100644 --- a/test/system/app_settings_test.rb +++ b/test/system/app_settings_test.rb @@ -106,6 +106,8 @@ class AppSettingsTest < ApplicationSystemTestCase fill_in 'student_email_external', with: 'test@test.com' click_button('Continue') fill_in 'thesis_abstract', with: 'Abstract Text Test' + find('#select_subjects_11_chosen a.chosen-default').click + first('#select_subjects_11_chosen .active-result').click click_link('Continue') assert_text "Upload Files Text Test" click_link_or_button('Upload Supplementary Thesis Files') @@ -141,6 +143,8 @@ class AppSettingsTest < ApplicationSystemTestCase fill_in 'student_email_external', with: 'test@test.com' click_button('Continue') fill_in 'thesis_abstract', with: 'Abstract Text Test' + find('#select_subjects_11_chosen a.chosen-default').click + first('#select_subjects_11_chosen .active-result').click click_link('Continue') click_link_or_button('Upload Primary Thesis File') attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf')) @@ -175,6 +179,8 @@ class AppSettingsTest < ApplicationSystemTestCase fill_in 'student_email_external', with: 'test@test.com' click_button('Continue') fill_in 'thesis_abstract', with: 'Abstract Text Test' + find('#select_subjects_11_chosen a.chosen-default').click + first('#select_subjects_11_chosen .active-result').click click_link('Continue') click_link_or_button('Upload Primary Thesis File') attach_file('document_file', Rails.root.join('test/fixtures/files/pdf-document.pdf')) diff --git a/test/system/students_test.rb b/test/system/students_test.rb index 2d13b71..c26db02 100644 --- a/test/system/students_test.rb +++ b/test/system/students_test.rb @@ -106,6 +106,8 @@ class StudentsTest < ApplicationSystemTestCase visit root_url fill_in('Non-YorkU Email Address', with: Faker::Internet.email) click_button('Continue') + find('#select_subjects_11_chosen a.chosen-default').click + first('#select_subjects_11_chosen .active-result').click click_link('Continue') #update click_link('Continue') #upload click_link('Continue') #review @@ -226,10 +228,6 @@ class StudentsTest < ApplicationSystemTestCase ## Page 2 and 3 tests should "upload primary file" do @thesis = FactoryGirl.create(:thesis) - create(:loc_subject, name: "Accounting", category: "BUSINESS") - create(:loc_subject, name: "Management", category: "BUSINESS") - create(:loc_subject, name: "Finance", category: "BUSINESS") - login_as(@thesis.student) visit root_url @@ -271,6 +269,8 @@ class StudentsTest < ApplicationSystemTestCase select "Management", from: 'select_subjects_12' select "Finance", from: 'select_subjects_13' + save_screenshot + fill_in "thesis_keywords", with: "accounting-kw, management-kw" click_on("Continue") @@ -352,9 +352,6 @@ class StudentsTest < ApplicationSystemTestCase ## Supplementary Info displays on edit/error should "Supplementary Info displays on edit/error" do @thesis = FactoryGirl.create(:thesis) - create(:loc_subject, name: "Accounting", category: "BUSINESS") - create(:loc_subject, name: "Management", category: "BUSINESS") - create(:loc_subject, name: "Finance", category: "BUSINESS") login_as(@thesis.student) visit root_url @@ -368,6 +365,10 @@ class StudentsTest < ApplicationSystemTestCase ## Page 2: Thesis Details select "English", from: "thesis_language" fill_in "thesis_abstract", with: Faker::Lorem.paragraph + + find('#select_subjects_11_chosen a.chosen-default').click + first('#select_subjects_11_chosen .active-result').click + click_on("Continue") ## Page 3: Upload Supplementary diff --git a/test/system/theses_test.rb b/test/system/theses_test.rb index eddec15..4e6c974 100644 --- a/test/system/theses_test.rb +++ b/test/system/theses_test.rb @@ -220,6 +220,10 @@ class ThesesTest < ApplicationSystemTestCase click_on("Continue") fill_in("Abstract", with: "Abstract Test") + + find('#select_subjects_11_chosen a.chosen-default').click + first('#select_subjects_11_chosen .active-result').click + click_on("Continue") click_on("Upload Supplementary Thesis Files")