From c83b3ec0d79a618f68bea3fc7830355a474ab84c Mon Sep 17 00:00:00 2001 From: Julian Gallimore Date: Sat, 13 Jan 2024 12:07:07 +0100 Subject: [PATCH] Moves acadmic image to assets folder Some feature not active anymore, but some lab pages seem to try to load this image from academies template, but is not found by assets library. --- {public => app/assets/images}/academic.png | Bin app/models/academic.rb | 2 +- .../academics/listing_students_spec.rb | 29 ++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) rename {public => app/assets/images}/academic.png (100%) create mode 100644 spec/features/academics/listing_students_spec.rb diff --git a/public/academic.png b/app/assets/images/academic.png similarity index 100% rename from public/academic.png rename to app/assets/images/academic.png diff --git a/app/models/academic.rb b/app/models/academic.rb index 34a04dd61..8412176a7 100644 --- a/app/models/academic.rb +++ b/app/models/academic.rb @@ -28,7 +28,7 @@ class Academic < ActiveRecord::Base belongs_to :user belongs_to :lab - belongs_to :approver + belongs_to :approver, class_name: 'User' validates_presence_of :started_in, :lab, :user diff --git a/spec/features/academics/listing_students_spec.rb b/spec/features/academics/listing_students_spec.rb new file mode 100644 index 000000000..6947f49d2 --- /dev/null +++ b/spec/features/academics/listing_students_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +feature "Showing students" do + + given(:lab) { FactoryBot.create(:lab, workflow_state: 'approved') } + given(:user) { FactoryBot.create(:user, first_name: "Homer", last_name: "Simpson", workflow_state: "verified") } + given(:academic) { FactoryBot.create(:academic, user: user, lab: lab) } + + scenario "as visitor" do + academic.approver = user + visit lab_url(lab) + expect(page).not_to have_content("Fab Academy Students") + end + + scenario "as a academy user" do + admin = FactoryBot.create(:user) + admin.add_role :superadmin + admin.add_role :academy + admin.verify! + sign_in admin + + academic.approver = admin + visit lab_url(lab) + + expect(page).to have_content("Fab Academy Students") + expect(page).to have_content("Academy Website") + end + +end