feedback_states_test.rb

来自「用ruby on rails写的一个博客程序,还不错..ruby on rail」· RB 代码 · 共 72 行

RB
72
字号
require File.dirname(__FILE__) + '/../../test_helper'class FeedbackStatesTest < Test::Unit::TestCase  fixtures :blogs, :contents, :articles_tags, :tags, :resources,    :categories, :categorizations, :users, :notifications, :text_filters  def setup    @comment = Article.find(:first).comments.build(:author => 'Piers',                                                   :body => 'Body')  end  def test_ham_all_the_way    assert_state ContentState::Unclassified    assert   @comment.published?    assert   @comment.just_published?    assert   @comment.just_changed_published_status?    assert   @comment.save    assert   @comment.just_changed_published_status?    assert   @comment.just_published?    @comment.reload    assert ! @comment.just_changed_published_status?    assert ! @comment.just_published?    @comment.confirm_classification    assert   @comment.published?    assert ! @comment.just_published?    assert ! @comment.just_changed_published_status?  end  def test_spam_all_the_way    class << @comment      def classify        :spam      end    end    assert_state ContentState::Unclassified    assert ! @comment.published?    assert ! @comment.just_published?    assert ! @comment.just_changed_published_status?    assert   @comment.save    assert ! @comment.published?    assert ! @comment.just_published?    assert ! @comment.just_changed_published_status?    @comment.reload    assert ! @comment.just_changed_published_status?    assert ! @comment.just_published?    @comment.confirm_classification    assert ! @comment.published?    assert ! @comment.just_published?    assert ! @comment.just_changed_published_status?  end  def test_presumed_spam_marked_as_ham    @comment.state = ContentState::PresumedSpam.instance    @comment.mark_as_ham    assert @comment.published?    assert @comment.just_published?    assert @comment.just_changed_published_status?  end  def test_presumed_ham_marked_as_spam    @comment.state = ContentState::PresumedHam.instance    @comment.mark_as_spam    assert ! @comment.published?    assert ! @comment.just_published?    assert   @comment.just_changed_published_status?  end  def assert_state(state)    assert_instance_of state, @comment.state  endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?