Sha256: a51f5d1b0fd5b6f58917d789c8d16972d82780b93b07a600158907b87603597a
Contents?: true
Size: 1.95 KB
Versions: 17
Compression:
Stored size: 1.95 KB
Contents
require 'spec_helper' describe CurationConcerns::SingleUseLinksController, type: :controller do routes { CurationConcerns::Engine.routes } let(:user) { create(:user) } let(:file) do FileSet.create do |file| file.apply_depositor_metadata(user) end end describe "logged in user with edit permission" do let(:hash) { "some-dummy-sha2-hash" } before do sign_in user allow(DateTime).to receive(:now).and_return(DateTime.now) expect(Digest::SHA2).to receive(:new).and_return(hash) end describe "GET 'download'" do it "and_return http success" do get 'new_download', id: file expect(response).to be_success expect(assigns[:link]).to eq routes.url_helpers.download_single_use_link_path(hash) end end describe "GET 'show'" do it "and_return http success" do get 'new_show', id: file expect(response).to be_success expect(assigns[:link]).to eq routes.url_helpers.show_single_use_link_path(hash) end end end describe "logged in user without edit permission" do before do @other_user = create(:user) file.read_users << @other_user file.save sign_in @other_user file.read_users << @other_user file.save end describe "GET 'download'" do it "and_return http success" do get 'new_download', id: file expect(response).not_to be_success end end describe "GET 'show'" do it "and_return http success" do get 'new_show', id: file expect(response).not_to be_success end end end describe "unknown user" do describe "GET 'download'" do it "and_return http failure" do get 'new_download', id: file expect(response).not_to be_success end end describe "GET 'show'" do it "and_return http failure" do get 'new_show', id: file expect(response).not_to be_success end end end end
Version data entries
17 entries across 17 versions & 1 rubygems