aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/censor_rule_spec.rb
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2015-05-12 16:48:44 +0100
committerGareth Rees <gareth@mysociety.org>2015-05-12 16:48:44 +0100
commit8f9984b66c7ce5d38b07bb6dfef28e914894a92c (patch)
tree1874b9165028b6969f6274303878bd2ce6b510d0 /spec/models/censor_rule_spec.rb
parent7d9de8a5ffe67e6bc49271a082c1d8e43dbb0f03 (diff)
parent9329b7f06d8a36ecb901d2172836ab8f5b2cdf3b (diff)
Merge branch 'initial_request_text-2' into rails-3-develop
Diffstat (limited to 'spec/models/censor_rule_spec.rb')
-rw-r--r--spec/models/censor_rule_spec.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/models/censor_rule_spec.rb b/spec/models/censor_rule_spec.rb
index 4ecd2d3e1..77b8cd07a 100644
--- a/spec/models/censor_rule_spec.rb
+++ b/spec/models/censor_rule_spec.rb
@@ -17,6 +17,42 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+describe CensorRule do
+
+ describe :apply_to_text do
+
+ it 'applies the rule to the text' do
+ rule = FactoryGirl.build(:censor_rule, :text => 'secret')
+ text = 'Some secret text'
+ expect(rule.apply_to_text(text)).to eq('Some [REDACTED] text')
+ end
+
+ it 'does not mutate the input' do
+ rule = FactoryGirl.build(:censor_rule, :text => 'secret')
+ text = 'Some secret text'
+ rule.apply_to_text(text)
+ expect(text).to eq('Some secret text')
+ end
+
+ it 'returns the text if the rule is unmatched' do
+ rule = FactoryGirl.build(:censor_rule, :text => 'secret')
+ text = 'Some text'
+ expect(rule.apply_to_text(text)).to eq('Some text')
+ end
+ end
+
+ describe :apply_to_text! do
+
+ it 'mutates the input' do
+ rule = FactoryGirl.build(:censor_rule, :text => 'secret')
+ text = 'Some secret text'
+ rule.apply_to_text!(text)
+ expect(text).to eq('Some [REDACTED] text')
+ end
+
+ end
+end
+
describe CensorRule, "substituting things" do
describe 'when using a text rule' do