|
54 | 54 | clear_enqueued_jobs |
55 | 55 | end |
56 | 56 |
|
| 57 | + describe "GET /show" do |
| 58 | + it "renders the organization as plain text and the creator as a link (non-admin)" do |
| 59 | + person = create(:person, user: user) |
| 60 | + create(:affiliation, person: person, organization: organization) |
| 61 | + workshop_log = create(:workshop_log, created_by: user, organization: organization, |
| 62 | + workshop: workshop, windows_type: windows_type, workshop_held_on: 1.day.ago) |
| 63 | + |
| 64 | + get workshop_log_path(workshop_log) |
| 65 | + |
| 66 | + page = Capybara.string(response.body) |
| 67 | + expect(page).to have_text(organization.name) |
| 68 | + expect(page).not_to have_link(organization.name) |
| 69 | + expect(page).to have_link(user.name, href: person_path(person)) |
| 70 | + end |
| 71 | + |
| 72 | + it "renders the creator as plain text when they have no person record" do |
| 73 | + workshop_log = create(:workshop_log, created_by: user, organization: organization, |
| 74 | + workshop: workshop, windows_type: windows_type, workshop_held_on: 1.day.ago) |
| 75 | + |
| 76 | + get workshop_log_path(workshop_log) |
| 77 | + |
| 78 | + page = Capybara.string(response.body) |
| 79 | + expect(page).to have_text(user.name) |
| 80 | + expect(page).not_to have_link(user.name) |
| 81 | + end |
| 82 | + |
| 83 | + it "shows the external title in the heading and beside the Workshop label when there is no workshop" do |
| 84 | + workshop_log = create(:workshop_log, created_by: user, organization: organization, |
| 85 | + workshop: nil, windows_type: windows_type, |
| 86 | + external_workshop_title: "Community Mural Project", workshop_held_on: 1.day.ago) |
| 87 | + |
| 88 | + get workshop_log_path(workshop_log) |
| 89 | + |
| 90 | + page = Capybara.string(response.body) |
| 91 | + expect(page).to have_css("h1", text: "Community Mural Project") |
| 92 | + workshop_div = page.find("span", text: "Workshop:").ancestor("div", match: :first) |
| 93 | + expect(workshop_div).to have_text("Community Mural Project") |
| 94 | + end |
| 95 | + |
| 96 | + it "shows the workshop name in the heading and both the workshop and external title when both are present" do |
| 97 | + titled_workshop = create(:workshop, :published, title: "Healing Through Art", windows_type: windows_type) |
| 98 | + workshop_log = create(:workshop_log, created_by: user, organization: organization, |
| 99 | + workshop: titled_workshop, windows_type: windows_type, |
| 100 | + external_workshop_title: "Guest-led Session", workshop_held_on: 1.day.ago) |
| 101 | + |
| 102 | + get workshop_log_path(workshop_log) |
| 103 | + |
| 104 | + page = Capybara.string(response.body) |
| 105 | + expect(page).to have_css("h1", text: "Healing Through Art") |
| 106 | + workshop_div = page.find("span", text: "Workshop:").ancestor("div", match: :first) |
| 107 | + expect(workshop_div).to have_text("Healing Through Art") |
| 108 | + expect(workshop_div).to have_text("Guest-led Session") |
| 109 | + end |
| 110 | + |
| 111 | + context "as an admin" do |
| 112 | + let(:admin) { create(:user, :admin) } |
| 113 | + before { sign_in admin } |
| 114 | + |
| 115 | + it "renders the organization and creator as links" do |
| 116 | + person = create(:person, user: user) |
| 117 | + create(:affiliation, person: person, organization: organization) |
| 118 | + workshop_log = create(:workshop_log, created_by: user, organization: organization, |
| 119 | + workshop: workshop, windows_type: windows_type, workshop_held_on: 1.day.ago) |
| 120 | + |
| 121 | + get workshop_log_path(workshop_log) |
| 122 | + |
| 123 | + page = Capybara.string(response.body) |
| 124 | + expect(page).to have_link(organization.name, href: organization_path(organization)) |
| 125 | + expect(page).to have_link(user.name, href: person_path(person)) |
| 126 | + end |
| 127 | + end |
| 128 | + end |
| 129 | + |
57 | 130 | describe "GET /index" do |
58 | 131 | it "loads the index page successfully" do |
59 | 132 | get workshop_logs_path |
|
0 commit comments