diff --git a/test/fixtures/glossary_categories.yml b/test/fixtures/glossary_categories.yml new file mode 100644 index 0000000..417b425 --- /dev/null +++ b/test/fixtures/glossary_categories.yml @@ -0,0 +1,10 @@ +color: + id: 1 + name: Color + project_id: 1 + +shape: + id: 2 + name: Shape + project_id: 1 + diff --git a/test/test_helper.rb b/test/test_helper.rb index 54685d3..4193874 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,2 +1,29 @@ # Load the Redmine helper require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper') + +module Redmine + module PluginFixturesLoader + def self.included(base) + base.class_eval do + def self.plugin_fixtures(*symbols) + ActiveRecord::FixtureSet.create_fixtures(File.dirname(__FILE__) + '/fixtures/', symbols) + end + end + end + end +end + +## functional test +unless ActionController::TestCase.included_modules.include?(Redmine::PluginFixturesLoader) + ActionController::TestCase.send :include, Redmine::PluginFixturesLoader +end + +## unit test +unless ActiveSupport::TestCase.included_modules.include?(Redmine::PluginFixturesLoader) + ActiveSupport::TestCase.send :include, Redmine::PluginFixturesLoader +end + +## integration test +unless Redmine::IntegrationTest.included_modules.include?(Redmine::PluginFixturesLoader) + Redmine::IntegrationTest.send :include, Redmine::PluginFixturesLoader +end diff --git a/test/unit/glossary_category_test.rb b/test/unit/glossary_category_test.rb index 9e8e198..dc07cf2 100644 --- a/test/unit/glossary_category_test.rb +++ b/test/unit/glossary_category_test.rb @@ -1,9 +1,15 @@ +# coding: utf-8 require File.expand_path('../../test_helper', __FILE__) class GlossaryCategoryTest < ActiveSupport::TestCase + fixtures :glossary_categories + plugin_fixtures :glossary_categories - # Replace this with your real tests. - def test_truth - assert true + def setup + @category = glossary_categories('color') + end + + def test_valid + assert !@category.valid? end end