aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/public_body_category.rb2
-rw-r--r--doc/CHANGES.md2
-rwxr-xr-xscript/migrate-public-body-categories4
-rw-r--r--spec/models/public_body_category_spec.rb10
4 files changed, 5 insertions, 13 deletions
diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb
index e594d08e7..8eaecd596 100644
--- a/app/models/public_body_category.rb
+++ b/app/models/public_body_category.rb
@@ -24,8 +24,6 @@ class PublicBodyCategory < ActiveRecord::Base
validates_presence_of :category_tag, :message => N_("Tag can't be blank")
def self.get
- # migrate from file-based public body categories
- CategoryAndHeadingMigrator.migrate_categories_and_headings if count < 1
locale = I18n.locale.to_s || default_locale.to_s || ""
categories = CategoryCollection.new
I18n.with_locale(locale) do
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index 32c1724b8..df74000bd 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -8,7 +8,7 @@
rather than only as a database constraint. If you have added a `CensorRule` in
your theme, you will now have to satisfy the additional validations on the
`:replacement`, `:last_edit_comment` and `:last_edit_editor` attributes.
-* Public body categories will now be stored in the database rather than being read directly from the `lib/public_body_categories_LOCALE` files - on first run, the contents of the files will be automatically imported into the database and all further changes will need to be made via the administrative interface.
+* Public body categories will now be stored in the database rather than being read directly from the `lib/public_body_categories_LOCALE` files. Once you have upgraded, run `script/migrate-public-body-categories`to import the contents of the files into the database. All further changes will then need to be made via the administrative interface.
# Version 0.19
diff --git a/script/migrate-public-body-categories b/script/migrate-public-body-categories
new file mode 100755
index 000000000..23abe4648
--- /dev/null
+++ b/script/migrate-public-body-categories
@@ -0,0 +1,4 @@
+#!/bin/bash
+TOP_DIR="$(dirname "$BASH_SOURCE")/.."
+cd "$TOP_DIR"
+bundle exec rails runner 'CategoryAndHeadingMigrator.migrate_categories_and_headings'
diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb
index f27c4838b..189d1654b 100644
--- a/spec/models/public_body_category_spec.rb
+++ b/spec/models/public_body_category_spec.rb
@@ -43,16 +43,6 @@ describe PublicBodyCategory do
end
end
- context "requesting data" do
-
- it 'should migrate categories if categories are not already loaded' do
- PublicBodyCategory.stub!(:count).and_return(0)
- CategoryAndHeadingMigrator.should_receive(:migrate_categories_and_headings)
- PublicBodyCategory::get()
- end
-
- end
-
context 'when validating' do
it 'should require a title' do