diff options
author | lizconlan <liz@mysociety.org> | 2014-07-11 17:46:49 +0100 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2014-09-22 12:39:01 +0100 |
commit | 6186bc07c36abb1ebe153fb4eb9967d8ece5e414 (patch) | |
tree | fa8842b414a18dab04341ba67d62fdb79518072d /spec/models | |
parent | b44fe3aba891e4e7de26a1ca237d04eba8329760 (diff) |
Replace existing PublicBodyCategories functionality with db models PublicBodyCategory and PublicBodyHeading
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/public_body_category_spec.rb | 53 | ||||
-rw-r--r-- | spec/models/public_body_heading_spec.rb | 13 |
2 files changed, 66 insertions, 0 deletions
diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb new file mode 100644 index 000000000..9d1105084 --- /dev/null +++ b/spec/models/public_body_category_spec.rb @@ -0,0 +1,53 @@ +# == Schema Information +# +# Table name: public_body_categories +# +# id :integer not null, primary key +# locale :string +# title :text not null +# category_tag :text not null +# description :text not null +# + +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe PublicBodyCategory do + + before do + load_test_categories + end + + describe 'when asked for categories with headings' do + + it 'should return a list of headings as plain strings, each followed by n tag specifications as + lists in the form: + ["tag_to_use_as_category", "Sub category title", "Instance description"]' do + expected_categories = ["Local and regional", ["local_council", + "Local councils", + "a local council"], + "Miscellaneous", ["other", + "Miscellaneous", + "miscellaneous"]] + PublicBodyCategory::get().with_headings().should == expected_categories + end + + end + + describe 'when asked for headings' do + + it 'should return a list of headings' do + PublicBodyCategory::get().headings().should == ['Local and regional', 'Miscellaneous'] + end + + end + + describe 'when asked for tags by headings' do + + it 'should return a hash of tags keyed by heading' do + PublicBodyCategory::get().by_heading().should == {'Local and regional' => ['local_council'], + 'Miscellaneous' => ['other']} + end + + end + +end
\ No newline at end of file diff --git a/spec/models/public_body_heading_spec.rb b/spec/models/public_body_heading_spec.rb new file mode 100644 index 000000000..73b5167fb --- /dev/null +++ b/spec/models/public_body_heading_spec.rb @@ -0,0 +1,13 @@ +# == Schema Information +# +# Table name: public_body_headings +# +# id :integer not null, primary key +# locale :string +# name :text not null +# + +require 'spec_helper' + +describe PublicBodyHeading do +end |