Sha256: d55090d14afae72015d2b7c75fd5cb650476ef9da7229e695cce4102a4325532

Contents?: true

Size: 1.64 KB

Versions: 13

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

describe Curate::DepositorsController do
  let (:person) { FactoryGirl.create(:person_with_user) }
  let (:grantee) { FactoryGirl.create(:person_with_user) }

  describe "as a logged in user" do
    before do
      sign_in person.user
    end

    describe "create" do
      it "should be successful" do
        expect { post :create, person_id: person.id, grantee_id: grantee.id, format: 'json' }.to change{ Curate::ProxyDepositRights.count }.by(1)
        response.should be_success
      end

      it "should not add current user" do
        expect { post :create, person_id: person.id, grantee_id: person.id, format: 'json' }.to change{ Curate::ProxyDepositRights.count }.by(0)
        response.should be_success
        response.body.should == "{}"
      end

    end
    describe "destroy" do
      before do
        person.user.can_receive_deposits_from << grantee.user
      end
      it "should be successful" do
        expect { delete :destroy, person_id: person.id, id: grantee.id, format: 'json' }.to change{ Curate::ProxyDepositRights.count }.by(-1)
      end
    end
  end

  describe "as a user without access" do
    before do
      sign_in FactoryGirl.create(:user)
    end
    describe "create" do
      it "should be successful" do
        post :create, person_id: person, grantee_id: grantee, format: 'json'
        expect(response.body).to eq "{\"status\":\"ERROR\",\"code\":401}"
      end
    end
    describe "destroy" do
      it "should be successful" do
        delete :destroy, person_id: person, id: grantee, format: 'json'
        expect(response.body).to eq "{\"status\":\"ERROR\",\"code\":401}"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
curate-0.6.6 spec/controllers/curate/depositors_controller_spec.rb
curate-0.6.5 spec/controllers/curate/depositors_controller_spec.rb
curate-0.6.4 spec/controllers/curate/depositors_controller_spec.rb
curate-0.6.3 spec/controllers/curate/depositors_controller_spec.rb
curate-0.6.1 spec/controllers/curate/depositors_controller_spec.rb
curate-0.6.0 spec/controllers/curate/depositors_controller_spec.rb
curate-0.5.6 spec/controllers/curate/depositors_controller_spec.rb
curate-0.5.5 spec/controllers/curate/depositors_controller_spec.rb
curate-0.5.4 spec/controllers/curate/depositors_controller_spec.rb
curate-0.5.2 spec/controllers/curate/depositors_controller_spec.rb
curate-0.5.1 spec/controllers/curate/depositors_controller_spec.rb
curate-0.5.0 spec/controllers/curate/depositors_controller_spec.rb
curate-0.4.2 spec/controllers/curate/depositors_controller_spec.rb