Sha256: 407f83c1572c3b865cb41b43c7900925c411b898b78f30d5c88a4142f8427b29

Contents?: true

Size: 882 Bytes

Versions: 43

Compression:

Stored size: 882 Bytes

Contents

require 'spec_helper'

describe Hydra::IpBasedAbility do
  before do
    class TestAbility < Ability
      include Hydra::IpBasedAbility
    end
  end

  let(:user) { double(groups: ['one', 'two'], new_record?: false) }
  let(:ability) { TestAbility.new(user, args) }
  let(:args) { {} }

  describe "#user_groups" do
    subject { ability.user_groups }
    context "when no ip is passed" do
      it { is_expected.to eq ['public', 'one', 'two', 'registered'] }
    end

    context "when ip is passed" do
      context "and it is in range" do
        let(:args) { { remote_ip: '10.0.1.12' } }
        it { is_expected.to eq ['public', 'one', 'two', 'registered', 'on-campus'] }
      end

      context "and it is out of range" do
        let(:args) { { remote_ip: '10.0.4.12' } }
        it { is_expected.to eq ['public', 'one', 'two', 'registered'] }
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
hydra-access-controls-10.3.4 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.3.3 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.3.2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.3.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.2.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.1.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.0.beta4 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.0.beta3 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.0.beta2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.0.0.beta1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.10.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.9.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.8.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.8.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.7.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.7.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-9.6.0 spec/unit/ip_base_ability_spec.rb