require File.dirname(__FILE__) + '/../test_helper' class PluginTest < Test::Unit::TestCase fixtures :plugins, :versions def setup @basic_params = { :author => 'Testy McTest', :email => 'test@testy.com', :repository => 'http://some-repos.com' } end def test_should_require_author_to_be_created assert_invalid Plugin.new(@basic_params.except(:author)) end def test_should_require_repository_to_be_created assert_invalid Plugin.new(@basic_params.except(:repository)) end def test_should_require_email_to_be_created assert_invalid Plugin.new(@basic_params.except(:email)) end def test_should_be_creatable_with_author_email_repository_and_summary assert_valid Plugin.new(@basic_params) end def test_should_have_an_author assert_equal 'James Adam', plugins(:simple_plugin).author end def test_should_have_an_email assert_equal 'james@lazyatom.com', plugins(:simple_plugin).email end def test_should_have_a_repository assert_equal 'http://svn.lazyatom.com/public/plugins/simple_plugin', plugins(:simple_plugin).repository end def test_should_have_many_versions assert_kind_of Array, plugins(:simple_plugin).versions assert_equal 2, plugins(:simple_plugin).versions.length assert_kind_of Version, plugins(:simple_plugin).versions.first end def test_should_have_a_latest_release assert_equal versions(:simple_plugin_v2), plugins(:simple_plugin).latest_release end def test_should_create_versions_when_given_a_repository_with_tags plugin = Plugin.create(:repository => 'http://svn.rails-engines.org/engines/', :author => 'test', :email => 'test@test.com') assert_kind_of Plugin, plugin assert_equal 11, plugin.versions.length assert_equal '1.1.3', plugin.latest_release.version end def test_should_create_plugin_with_single_version_when_given_a_repository_without_tags plugin = Plugin.create(:repository => 'http://svn.rails-engines.org/plugins/engines', :author => 'test', :email => 'test@test.com') assert_kind_of Plugin, plugin assert_equal 1, plugin.versions.length assert_equal '1.1.3', plugin.latest_release.version end end