aboutsummaryrefslogtreecommitdiffstats
path: root/spec/models/info_request_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/info_request_spec.rb')
-rw-r--r--spec/models/info_request_spec.rb83
1 files changed, 60 insertions, 23 deletions
diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb
index b1d10a51d..2a738fa4c 100644
--- a/spec/models/info_request_spec.rb
+++ b/spec/models/info_request_spec.rb
@@ -401,13 +401,17 @@ describe InfoRequest do
end
- context "when applying censor rules" do
+ describe 'when applying censor rules' do
before do
- @global_rule = mock_model(CensorRule, :apply_to_text! => nil)
- @user_rule = mock_model(CensorRule, :apply_to_text! => nil)
- @request_rule = mock_model(CensorRule, :apply_to_text! => nil)
- @body_rule = mock_model(CensorRule, :apply_to_text! => nil)
+ @global_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ :apply_to_binary! => nil)
+ @user_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ :apply_to_binary! => nil)
+ @request_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ :apply_to_binary! => nil)
+ @body_rule = mock_model(CensorRule, :apply_to_text! => nil,
+ :apply_to_binary! => nil)
@user = mock_model(User, :censor_rules => [@user_rule])
@body = mock_model(PublicBody, :censor_rules => [@body_rule])
@info_request = InfoRequest.new(:prominence => 'normal',
@@ -420,29 +424,62 @@ describe InfoRequest do
CensorRule.stub!(:global).and_return(mock('global context', :all => [@global_rule]))
end
- it "should apply a global censor rule" do
- @global_rule.should_receive(:apply_to_text!).with(@text)
- @info_request.apply_censor_rules_to_text!(@text)
- end
+ context "when applying censor rules to text" do
- it 'should apply a user rule' do
- @user_rule.should_receive(:apply_to_text!).with(@text)
- @info_request.apply_censor_rules_to_text!(@text)
- end
+ it "should apply a global censor rule" do
+ @global_rule.should_receive(:apply_to_text!).with(@text)
+ @info_request.apply_censor_rules_to_text!(@text)
+ end
- it 'should not raise an error if there is no user' do
- @info_request.user_id = nil
- lambda{ @info_request.apply_censor_rules_to_text!(@text) }.should_not raise_error
- end
+ it 'should apply a user rule' do
+ @user_rule.should_receive(:apply_to_text!).with(@text)
+ @info_request.apply_censor_rules_to_text!(@text)
+ end
+
+ it 'should not raise an error if there is no user' do
+ @info_request.user_id = nil
+ lambda{ @info_request.apply_censor_rules_to_text!(@text) }.should_not raise_error
+ end
+
+ it 'should apply a rule from the body associated with the request' do
+ @body_rule.should_receive(:apply_to_text!).with(@text)
+ @info_request.apply_censor_rules_to_text!(@text)
+ end
+
+ it 'should apply a request rule' do
+ @request_rule.should_receive(:apply_to_text!).with(@text)
+ @info_request.apply_censor_rules_to_text!(@text)
+ end
- it 'should apply a rule from the body associated with the request' do
- @body_rule.should_receive(:apply_to_text!).with(@text)
- @info_request.apply_censor_rules_to_text!(@text)
end
- it 'should apply a request rule' do
- @request_rule.should_receive(:apply_to_text!).with(@text)
- @info_request.apply_censor_rules_to_text!(@text)
+ context 'when applying censor rules to binary files' do
+
+ it "should apply a global censor rule" do
+ @global_rule.should_receive(:apply_to_binary!).with(@text)
+ @info_request.apply_censor_rules_to_binary!(@text)
+ end
+
+ it 'should apply a user rule' do
+ @user_rule.should_receive(:apply_to_binary!).with(@text)
+ @info_request.apply_censor_rules_to_binary!(@text)
+ end
+
+ it 'should not raise an error if there is no user' do
+ @info_request.user_id = nil
+ lambda{ @info_request.apply_censor_rules_to_binary!(@text) }.should_not raise_error
+ end
+
+ it 'should apply a rule from the body associated with the request' do
+ @body_rule.should_receive(:apply_to_binary!).with(@text)
+ @info_request.apply_censor_rules_to_binary!(@text)
+ end
+
+ it 'should apply a request rule' do
+ @request_rule.should_receive(:apply_to_binary!).with(@text)
+ @info_request.apply_censor_rules_to_binary!(@text)
+ end
+
end
end