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-13.0.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-12.1.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-12.0.2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-11.0.7 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-12.0.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-11.0.6 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-12.0.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-11.0.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-11.0.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-11.0.0.rc2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.7.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.6.2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.6.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.6.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.5.1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-11.0.0.rc1 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.5.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.4.0 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.4.0.rc2 spec/unit/ip_base_ability_spec.rb
hydra-access-controls-10.4.0.rc1 spec/unit/ip_base_ability_spec.rb