Sha256: 83e6cb97340c67fb04938f4376673633add6e422a45e660aea619cefc47e1ac2

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

require 'test_helper'

class NewsArticleTest < ActiveSupport::TestCase
  test "news_article#route_name" do 
    assert_equal 'news_articles_dummy_news_article', NewsArticle.new(caption: "Dummy News Article").route_name
  end
  
  test "NewsArticle controller_action" do 
    assert_equal 'news_article#show', NewsArticle.flowmor_news_articles_router_class.controller_action
  end

  test "news_article#path" do
    assert_raise FlowmorRouter::UnroutableRecord do
      NewsArticle.new(caption: nil).path
    end
    assert_raise FlowmorRouter::UnroutableRecord do
      NewsArticle.create(caption: nil).path
    end
    real_article = NewsArticle.create(caption: "Real News Article")
    assert_equal '/news_articles/real-news-article', Rails.application.routes.url_helpers.news_articles_real_news_article_path
    assert_equal '/news_articles/real-news-article', real_article.path
  end
  
  test "news_article#url" do 
    assert_raise FlowmorRouter::UnroutableRecord do
      NewsArticle.new(caption: nil).url
    end
    assert_raise FlowmorRouter::UnroutableRecord do
      NewsArticle.create(caption: nil).url
    end

    real_article = NewsArticle.create(caption: "Real News Article")
    Thread.current[:host] = "localhost"
    Thread.current[:port] = "3000"
    assert_equal 'http://localhost:3000/news_articles/real-news-article', real_article.url
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
flowmor_router-0.2.6 test/dummy/test/models/news_article_test.rb
flowmor_router-0.2.5 test/dummy/test/models/news_article_test.rb
flowmor_router-0.2.4 test/dummy/test/models/news_article_test.rb
flowmor_router-0.2.3 test/dummy/test/models/news_article_test.rb
flowmor_router-0.2.2 test/dummy/test/models/news_article_test.rb
flowmor_router-0.2.1 test/dummy/test/models/news_article_test.rb