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