Sha256: e7627379e65041e3f455595615c69a79d1f6fac9b4727f82f06ea9f1eeb921fe

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'test_helper'

class ArticleControllerTest < ActionController::TestCase

  context "for logged in user" do

    setup do
      activate_authlogic
      UserSession.create(@user = User.make)
    end

    context "on GET to show" do
      setup { get :show, :id => Article.make }
      should_respond_with :success
      should "have article value set" do
        assert_not_nil assigns(:article)
      end
      should_render_template :show
    end

    context "on GET to search" do
      setup do
        Sunspot.remove_all!
        2.times { Article.make }
        (Article::per_page + 1).times { Article.make(:accent_in_body) }
        Sunspot.commit
        get :search, :q => Sham.accented_word
      end
      should_respond_with :success
      should "have articles value set" do
        articles = assigns(:articles)
        assert_not_nil assigns(:articles)
        assert_equal 1, articles.current_page
        assert_equal Article::per_page + 1, articles.total_entries
      end
      should_render_template :search
    end
    #TODO should be tested for cases when the user is not logged in
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solarsearch-0.0.9 test/functional/article_controller_test.rb
solarsearch-0.0.6 test/functional/article_controller_test.rb