Sha256: 1cf0c7e51c6165087df0ff3a10f31893f70abac7dfa866be08d5769820d52634

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

describe DownloadsController do
  describe '#show' do
    let(:user) { FactoryGirl.create(:user) }
    let(:another_user) { FactoryGirl.create(:user) }
    let(:visibility) { AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE }
    let(:generic_file) {
      FactoryGirl.create_generic_file(:mock_curation_concern, user) {|g|
        g.visibility = visibility
      }
    }

    it "raise not_found if the object does not exist" do
      expect {
        get :show, id: '8675309'
      }.to raise_rescue_response_type(:not_found)
    end

    it "responds :unauthorized if user doesn't have access" do
      generic_file
      sign_in another_user
      expect {
        get :show, id: generic_file.to_param
      }.to raise_rescue_response_type(:unauthorized)
    end

    it "responds :unauthorized if you aren't logged in" do
      generic_file
      expect {
        get :show, id: generic_file.to_param
      }.to raise_rescue_response_type(:unauthorized)
    end

    it 'sends the file if the user has access' do
      generic_file
      sign_in user
      get :show, id: generic_file.to_param
      response.body.should == generic_file.content.content
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
curate-0.3.2 spec/controllers/downloads_controller_spec.rb
curate-0.3.1 spec/controllers/downloads_controller_spec.rb
curate-0.2.0 spec/controllers/downloads_controller_spec.rb
curate-0.1.3 spec/controllers/downloads_controller_spec.rb
curate-0.1.2 spec/controllers/downloads_controller_spec.rb
curate-0.1.1 spec/controllers/downloads_controller_spec.rb
curate-0.1.0 spec/controllers/downloads_controller_spec.rb