BigW Consortium Gitlab

user_url_constrainer_spec.rb 541 Bytes
Newer Older
1 2 3
require 'spec_helper'

describe UserUrlConstrainer, lib: true do
4
  let!(:user) { create(:user, username: 'dz') }
5

6
  describe '#matches?' do
7 8 9 10 11 12 13 14 15 16 17
    context 'valid request' do
      let(:request) { build_request(user.username) }

      it { expect(subject.matches?(request)).to be_truthy }
    end

    context 'invalid request' do
      let(:request) { build_request('foo') }

      it { expect(subject.matches?(request)).to be_falsey }
    end
18 19
  end

20 21
  def build_request(username)
    double(:request, params: { username: username })
22 23
  end
end