diff --git a/app/presenters/schools/users/show_presenter.rb b/app/presenters/schools/users/show_presenter.rb index 55c877ac1c..c2fa000c33 100644 --- a/app/presenters/schools/users/show_presenter.rb +++ b/app/presenters/schools/users/show_presenter.rb @@ -35,8 +35,8 @@ def courses_authored .order(name: :asc) end - def organisation_names - @organisation_names ||= user.organisation&.name + def affiliation + @affiliation ||= user.affiliation || user.organisation&.name end def current_standing diff --git a/app/views/schools/users/show.html.erb b/app/views/schools/users/show.html.erb index fc357365f6..d423ad4dac 100644 --- a/app/views/schools/users/show.html.erb +++ b/app/views/schools/users/show.html.erb @@ -40,12 +40,12 @@ <% end %> - <% if @presenter.organisation_names.present? %> + <% if @presenter.affiliation.present? %>

<%= t("schools.users.show.affiliation") %>

-

<%= @presenter.organisation_names %>

+

<%= @presenter.affiliation %>

<% end %> diff --git a/spec/system/school/users/users_show_spec.rb b/spec/system/school/users/users_show_spec.rb index de711f01fc..a20b85e134 100644 --- a/spec/system/school/users/users_show_spec.rb +++ b/spec/system/school/users/users_show_spec.rb @@ -17,6 +17,7 @@ discord_user_id: Faker::Number.number(digits: 10).to_s, organisation: organisation end + let(:user_affiliated) { create :user, affiliation: Faker::Company.name } let(:course_1) { create :course, school: school } let(:course_2) { create :course, school: school } @@ -48,6 +49,13 @@ expect(page).to have_text("The page you were looking for doesn't exist!") end + scenario "user with affiliation filled" do + sign_in_user school_admin.user, referrer: school_user_path(user_affiliated) + + expect(page).not_to have_text(organisation.name) + expect(page).to have_text(user_affiliated.affiliation) + end + scenario "admin access user of same school" do sign_in_user school_admin.user, referrer: school_user_path(user)