Permalink
Browse files

Merge remote branch 'origin/remove_tag_repository'

  • Loading branch information...
2 parents c8dbf8b + 2347a07 commit 78f6e93bd6d71ebcfd2e465d89bc059ae7f920e3 @jamiecobbett jamiecobbett committed Jan 11, 2013
@@ -92,7 +92,7 @@ def admin_url_for_edition(artefact, options = {})
end
def tag_collection
- @tag_collection = TagRepository.load_all(:tag_type => 'section')
+ @tag_collection = Tag.where(:tag_type => 'section')
.asc(:title).to_a
title_counts = Hash.new(0)
@@ -2,13 +2,17 @@ class TagsController < ApplicationController
respond_to :json, :html
def index
- @tags = TagRepository.load_all(tag_type: params[:type])
+ if params[:type]
+ @tags = Tag.where(tag_type: params[:type])
+ else
+ @tags = Tag.all
+ end
respond_with(status: 'ok', total: @tags.count, from: 0, to: @tags.count - 1,
pagesize: @tags.count, results: @tags)
end
def show
- @tag = TagRepository.load(params[:id])
+ @tag = Tag.where(tag_id: params[:id]).first
if @tag
respond_with(status: 'ok', tag: @tag)
else
@@ -17,7 +21,7 @@ def show
end
def edit
- @tag = TagRepository.load(params[:id])
+ @tag = Tag.where(tag_id: params[:id]).first
respond_with @tag
end
@@ -37,7 +41,7 @@ def update
end
def categories
- @tags = TagRepository.load_all({:tag_type => 'section'}).order_by([:tag_id, :asc])
+ @tags = Tag.where(tag_type: 'section').order_by([:tag_id, :asc])
respond_with @tags
end
end
@@ -6,7 +6,7 @@ module SectionsHelper
# To force a tag to be excluded pass in the +options+ hash with a
# key of :except
def all_sections(options = {})
- section_tags = TagRepository.load_all(:type => 'section')
+ section_tags = Tag.where(:tag_type => 'section')
sections = options_for_sections(section_tags)
View
@@ -1,31 +0,0 @@
-#######
-#
-# This file will be run on every deploy, so make sure the changes here are non-destructive
-#
-#######
-
-TagRepository.put(:tag_id => 'businesslink', :title => 'Business Link', :tag_type => 'legacy_source')
-TagRepository.put(:tag_id => 'directgov', :title => 'Directgov', :tag_type => 'legacy_source')
-
-old_tag_id = 'births-deaths-marriages/registry-offices'
-new_tag_id = 'births-deaths-marriages/register-offices'
-
-old_registry_office_tag = Tag.where(:tag_id => old_tag_id).first
-if old_registry_office_tag
- old_registry_office_tag.tag_id = new_tag_id
- old_registry_office_tag.save!
-end
-
-new_registry_office_tag = Tag.where(:tag_id => new_tag_id).first
-
-Artefact.all.any_in(:tag_ids => [old_tag_id]).each do |artefact|
- artefact.tag_ids = artefact.tag_ids.map do |tag_id|
- if tag_id == old_tag_id
- new_registry_office_tag.tag_id
- else
- tag_id
- end
- end
-
- artefact.save!
-end
@@ -1,20 +1,23 @@
+require 'govuk_content_models/test_helpers/factories'
+
def create_section
- TagRepository.put(
+ FactoryGirl.create(
+ :tag,
tag_id: "crime",
tag_type: "section",
title: "Crime"
)
- return TagRepository.load "crime"
end
def create_sections
create_section
- TagRepository.put(
+ FactoryGirl.create(
+ :tag,
tag_id: "crime/batman",
tag_type: "section",
title: "Batman"
)
- return ["crime", "crime/batman"].map { |tag_id| TagRepository.load tag_id }
+ return ["crime", "crime/batman"].map { |tag_id| Tag.where(tag_id: tag_id, tag_type: 'section').first }
end
def select_section(section)
@@ -130,7 +130,7 @@ class ArtefactsControllerTest < ActionController::TestCase
end
should "Include section ID" do
- TagRepository.put :tag_id => 'crime', :tag_type => 'section', :title => 'Crime'
+ FactoryGirl.create(:tag, :tag_id => 'crime', :tag_type => 'section', :title => 'Crime')
artefact = Artefact.create! :slug => 'whatever', :kind => 'guide', :owning_app => 'publisher', :name => 'Whatever', :need_id => 1
artefact.sections = ['crime']
artefact.save!
@@ -141,8 +141,8 @@ class ArtefactsControllerTest < ActionController::TestCase
end
should "Include tag_ids" do
- TagRepository.put :tag_id => 'crime', :tag_type => 'section', :title => 'Crime'
- TagRepository.put :tag_id => 'businesslink', :tag_type => 'legacy_source', :title => 'Business Link'
+ FactoryGirl.create(:tag, :tag_id => 'crime', :tag_type => 'section', :title => 'Crime')
+ FactoryGirl.create(:tag, :tag_id => 'businesslink', :tag_type => 'legacy_source', :title => 'Business Link')
artefact = Artefact.create! :slug => 'whatever', :kind => 'guide', :owning_app => 'publisher', :name => 'Whatever', :need_id => 1
artefact.sections = ['crime']
artefact.legacy_sources = ['businesslink']
@@ -3,9 +3,9 @@
class TagsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
- TagRepository.put(tag_id: "crime", title: "Crime", tag_type: "section",
+ FactoryGirl.create(:tag, tag_id: "crime", title: "Crime", tag_type: "section",
short_description: "Legal processes, courts and the police")
- TagRepository.put(tag_id: "crime/the-police", title: "The Police", tag_type: "section")
+ FactoryGirl.create(:tag, tag_id: "crime/the-police", title: "The Police", tag_type: "section")
@tag_count = 2
end
@@ -40,7 +40,7 @@ class TagsControllerTest < ActionController::TestCase
context "GET /tags?type=X" do
should "return only tags of a particular type" do
- TagRepository.put(tag_id: "minister-of-silly", title: "Minister of Silly", tag_type: "role")
+ FactoryGirl.create(:tag, tag_id: "minister-of-silly", title: "Minister of Silly", tag_type: "role")
get :index, format: "json", type: "section"
parsed = JSON.parse(response.body)
assert_equal 2, parsed["results"].count
@@ -3,8 +3,8 @@
class RummageableArtefactTest < ActiveSupport::TestCase
setup do
- TagRepository.put tag_type: "section", tag_id: "crime", title: "Crime"
- TagRepository.put tag_type: "section", tag_id: "crime/batman", title: "Batman", parent_id: "crime"
+ FactoryGirl.create(:tag, tag_type: "section", tag_id: "crime", title: "Crime")
+ FactoryGirl.create(:tag, tag_type: "section", tag_id: "crime/batman", title: "Batman", parent_id: "crime")
end
test "should extract artefact attributes" do

0 comments on commit 78f6e93

Please sign in to comment.