Permalink
Browse files

Fix to only load tags of type section in edit form

Previously all tag types were appearing in the dropdowns for sections in
the edit from.  Non-section tags would cause an error on save.
  • Loading branch information...
1 parent 790784e commit b2b41836f6e9b9b235de94343e2cd011fe440869 @alext alext committed Aug 21, 2012
Showing with 14 additions and 1 deletion.
  1. +1 −1 app/controllers/artefacts_controller.rb
  2. +13 −0 test/functional/artefacts_controller_test.rb
@@ -85,7 +85,7 @@ def destroy
private
def tag_collection
- @tag_collection = TagRepository.load_all(:type => 'section').asc(:title).to_a
+ @tag_collection = TagRepository.load_all(:tag_type => 'section').asc(:title).to_a
title_counts = Hash.new(0)
@tag_collection.each do |tag|
@@ -157,6 +157,19 @@ class ArtefactsControllerTest < ActionController::TestCase
assert_equal ["update", "create"], actions.map(&:action_type)
assert_equal [false, true], actions.map(&:initial?)
end
+
+ should "assign list of sections" do
+ FactoryGirl.create(:tag, :tag_type => 'section', :tag_id => 'kablooey', :title => 'Kablooey')
+ FactoryGirl.create(:tag, :tag_type => 'section', :tag_id => 'fooey', :title => 'Fooey')
+ FactoryGirl.create(:tag, :tag_type => 'section', :tag_id => 'gooey', :title => 'Gooey')
+ FactoryGirl.create(:tag, :tag_type => 'legacy_source', :tag_id => 'businesslink', :title => 'Business Link')
+
+ artefact = FactoryGirl.create(:artefact)
+
+ get :edit, id: artefact.id, format: :html
+
+ assert_equal ['fooey', 'gooey', 'kablooey'], assigns["tag_collection"].map(&:tag_id)
+ end
end
end

0 comments on commit b2b4183

Please sign in to comment.