From ca66d9b22bca71f4c0a62121e6bff7c7da93d20d Mon Sep 17 00:00:00 2001 From: Louise Crow Date: Tue, 14 Apr 2015 15:29:37 +0100 Subject: Use a helper to generate the status text. This has length constraints, so we don't want to directly use InfoRequest.get_status_description (which also adds a full stop), but we want statuses that more closely correspond to get_status_description than those in the template, which are used in AskTheEU. --- spec/helpers/widget_helper_spec.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/helpers/widget_helper_spec.rb (limited to 'spec/helpers/widget_helper_spec.rb') diff --git a/spec/helpers/widget_helper_spec.rb b/spec/helpers/widget_helper_spec.rb new file mode 100644 index 000000000..b0da20c39 --- /dev/null +++ b/spec/helpers/widget_helper_spec.rb @@ -0,0 +1,31 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe WidgetHelper do + + include WidgetHelper + + describe :status_description do + + before do + @info_request = FactoryGirl.build(:info_request) + end + + it 'should return "Awaiting classification" for "waiting_classification' do + @info_request.stub!(:calculate_status).and_return("waiting_classification") + expect(status_description(@info_request)).to eq('Awaiting classification') + end + + it 'should call theme_display_status for a theme status' do + @info_request.stub!(:calculate_status).and_return("special_status") + @info_request.stub!(:theme_display_status).and_return("Special status") + expect(status_description(@info_request)).to eq('Special status') + end + + it 'should return unknown for an unknown status' do + @info_request.stub!(:calculate_status).and_return("special_status") + expect(status_description(@info_request)).to eq('Unknown') + end + + end + +end \ No newline at end of file -- cgit v1.2.3