2010-12-13 22:28:59 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2010-12-15 22:34:19 +00:00
|
|
|
describe Shoulda::Matchers::ActionController::FilterParamMatcher do
|
2012-12-20 05:04:27 +00:00
|
|
|
it 'accepts filtering a filtered parameter' do
|
|
|
|
filter(:secret)
|
2010-12-13 22:28:59 +00:00
|
|
|
|
2012-12-20 05:04:27 +00:00
|
|
|
nil.should filter_param(:secret)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'rejects filtering an unfiltered parameter' do
|
|
|
|
filter(:secret)
|
|
|
|
matcher = filter_param(:other)
|
|
|
|
|
|
|
|
matcher.matches?(nil).should be_false
|
|
|
|
|
2013-12-24 11:24:27 +00:00
|
|
|
matcher.failure_message.should =~ /Expected other to be filtered.*secret/
|
2012-12-20 05:04:27 +00:00
|
|
|
end
|
2010-12-13 22:28:59 +00:00
|
|
|
|
2012-12-20 05:04:27 +00:00
|
|
|
def filter(param)
|
|
|
|
Rails.application.config.filter_parameters = [param]
|
2010-12-13 22:28:59 +00:00
|
|
|
end
|
|
|
|
end
|