Sha256: fd6d8f7feba05c5c3b503ad10c629f00ebe4697acdd192c3d9fd480fcb0d5af1

Contents?: true

Size: 1.14 KB

Versions: 7

Compression:

Stored size: 1.14 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class TestGoalocA < Test::Unit::TestCase
  def clean_app!
    if defined?(@app)
      @app.models.values.each do |m|
        Object.send(:remove_const, m.to_s.to_sym)
      end
    end
    @app = App.new
  end

  context "that routes a nested route" do
    setup { clean_app!; @app.route([:posts, :comments])}
    
    should "define a nested route" do
      assert @app.routes.member?([:posts, :comments])
    end
    
    should "define Post and Comment"do
      assert defined?(Post)
      assert defined?(Comment)
    end
    
    should "define a simple Post route" do
      assert_equal Post.routes, [[Post]]
    end
    
    should "define a nested Comment route" do
      assert_equal Comment.routes, [[Post, Comment]]
    end
    
    should "make an association from Post to Comment" do
      assert_equal "comments", Post.associations.keys.first
    end
    
    should "make an association from Comment to Post" do
      assert_equal "post", Comment.associations.keys.first
    end
    
    should "set a foreign key on comment" do
      assert_equal "post_id", Comment.foreign_keys.first
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mattknox-goaloc-0.0.3 test/test_goaloc_a.rb
mattknox-goaloc-0.0.5 test/test_goaloc_a.rb
mattknox-goaloc-0.0.6 test/test_goaloc_a.rb
mattknox-goaloc-0.0.7 test/test_goaloc_a.rb
mattknox-goaloc-0.0.8 test/test_goaloc_a.rb
mattknox-goaloc-0.0.9 test/test_goaloc_a.rb
mattknox-goaloc-0.1.0 test/test_goaloc_a.rb