summaryrefslogtreecommitdiff
path: root/spec/lib/constraints/user_url_constrainer_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/constraints/user_url_constrainer_spec.rb')
-rw-r--r--spec/lib/constraints/user_url_constrainer_spec.rb21
1 files changed, 17 insertions, 4 deletions
diff --git a/spec/lib/constraints/user_url_constrainer_spec.rb b/spec/lib/constraints/user_url_constrainer_spec.rb
index 4b26692672f..207b6fe6c9e 100644
--- a/spec/lib/constraints/user_url_constrainer_spec.rb
+++ b/spec/lib/constraints/user_url_constrainer_spec.rb
@@ -1,10 +1,23 @@
require 'spec_helper'
describe UserUrlConstrainer, lib: true do
- let!(:username) { create(:user, username: 'dz') }
+ let!(:user) { create(:user, username: 'dz') }
- describe '#find_resource' do
- it { expect(!!subject.find_resource('dz')).to be_truthy }
- it { expect(!!subject.find_resource('john')).to be_falsey }
+ describe '#matches?' do
+ 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
+ end
+
+ def build_request(username)
+ double(:request, params: { username: username })
end
end