feedback_states_spec.rb
上传用户:netsea168
上传日期:2022-07-22
资源大小:4652k
文件大小:2k
源码类别:

Ajax

开发平台:

Others

  1. require File.dirname(__FILE__) + '/../../spec_helper'
  2. describe 'FeedbackStates from Test::Unit' do
  3.   before(:each) do
  4.     @comment = contents(:article1).comments.build(:author => 'Piers',
  5.                                                   :body => 'Body')
  6.   end
  7.   it "test_ham_all_the_way" do
  8.     assert @comment.unclassified?
  9.     assert   @comment.published?
  10.     assert   @comment.just_published?
  11.     assert   @comment.just_changed_published_status?
  12.     assert   @comment.save
  13.     assert   @comment.just_changed_published_status?
  14.     assert   @comment.just_published?
  15.     @comment = Comment.find(@comment.id)
  16.     assert ! @comment.just_changed_published_status?
  17.     assert ! @comment.just_published?
  18.     @comment.confirm_classification
  19.     assert   @comment.published?
  20.     assert ! @comment.just_published?
  21.     assert ! @comment.just_changed_published_status?
  22.   end
  23.   it "test_spam_all_the_way" do
  24.     class << @comment
  25.       def classify
  26.         :spam
  27.       end
  28.     end
  29.     assert @comment.unclassified?
  30.     assert ! @comment.published?
  31.     assert ! @comment.just_published?
  32.     assert ! @comment.just_changed_published_status?
  33.     assert   @comment.save
  34.     assert ! @comment.published?
  35.     assert ! @comment.just_published?
  36.     assert ! @comment.just_changed_published_status?
  37.     @comment = Comment.find(@comment.id)
  38.     assert ! @comment.just_changed_published_status?
  39.     assert ! @comment.just_published?
  40.     @comment.confirm_classification
  41.     assert ! @comment.published?
  42.     assert ! @comment.just_published?
  43.     assert ! @comment.just_changed_published_status?
  44.   end
  45.   it "test_presumed_spam_marked_as_ham" do
  46.     @comment[:state] = 'presumed_spam'
  47.     @comment.mark_as_ham
  48.     assert @comment.published?
  49.     assert @comment.just_published?
  50.     assert @comment.just_changed_published_status?
  51.   end
  52.   it "test_presumed_ham_marked_as_spam" do
  53.     @comment[:state] = 'presumed_ham'
  54.     @comment.mark_as_spam
  55.     assert ! @comment.published?
  56.     assert ! @comment.just_published?
  57.     assert   @comment.just_changed_published_status?
  58.   end
  59. end