2016-10-06 09:59:22 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe UserUrlConstrainer, lib: true do
|
2016-11-14 09:55:31 -05:00
|
|
|
let!(:user) { create(:user, username: 'dz') }
|
2016-10-06 09:59:22 -04:00
|
|
|
|
2016-11-07 08:16:04 -05:00
|
|
|
describe '#matches?' do
|
2016-11-14 09:55:31 -05:00
|
|
|
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
|
2016-11-07 08:16:04 -05:00
|
|
|
end
|
|
|
|
|
2016-11-14 09:55:31 -05:00
|
|
|
def build_request(username)
|
|
|
|
double(:request, params: { username: username })
|
2016-10-06 09:59:22 -04:00
|
|
|
end
|
|
|
|
end
|