Skip to content

Commit

Permalink
Adding a test for the automatic mediaflux session reconnect (#711)
Browse files Browse the repository at this point in the history
* Adding a test for the automatic mediaflux session reconnect
This code is int he application controller, so it will work for all controller actions

* Update mediaflux_session_spec.rb

---------

Co-authored-by: Bess Sadler <[email protected]>
  • Loading branch information
carolyncole and bess authored May 10, 2024
1 parent 9ef0ce8 commit 9f9b1ee
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions spec/system/mediaflux_session_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# frozen_string_literal: true

require "rails_helper"

# Makes sure the Application Controller handles Mediaflux::Http::SessionExpired in a test from the user's perspective
#
RSpec.describe "Mediaflux Sessions", type: :system do
let(:sponsor_user) { FactoryBot.create(:project_sponsor, uid: "pul123") }
let(:project) { FactoryBot.create(:project, mediaflux_id: "abc123") }

before do
sign_in sponsor_user
end

it "reconnects to mediaflux after the session ends", connect_to_mediaflux: true do
original_session = sponsor_user.mediaflux_session

# logout the session so we get an error and need to reset the session
Mediaflux::Http::LogoutRequest.new(session_token: original_session).resolve

expect { visit project_contents_path(project) }.not_to raise_error
expect(page).to have_content("File Count\n0")

# a new session got automatically connected for the user in the application controller
expect(sponsor_user.mediaflux_session).not_to eq(original_session)
end
end

0 comments on commit 9f9b1ee

Please sign in to comment.