Sha256: 8977886ccc2145f2c49427fdc26f915e588437f25b4528e5ffdeac132549ce40
Contents?: true
Size: 1.03 KB
Versions: 26
Compression:
Stored size: 1.03 KB
Contents
require File.join(File.dirname(__FILE__), 'test_helper') require 'couchtiny' require 'couchtiny/document' require 'workflow' class User < CouchTiny::Document include Workflow workflow do state :submitted do event :activate_via_link, :transitions_to => :proved_email end state :proved_email end def load_workflow_state self[:workflow_state] end def persist_workflow_state(new_value) self[:workflow_state] = new_value save! end end class CouchtinyExample < Test::Unit::TestCase def setup db = CouchTiny::Database.url("http://127.0.0.1:5984/test-workflow") db.delete_database! rescue nil db.create_database! User.use_database db end test 'CouchDB persistence' do user = User.new :email => 'manya@example.com' user.save! assert user.submitted? user.activate_via_link! assert user.proved_email? reloaded_user = User.get user.id puts reloaded_user.inspect assert reloaded_user.proved_email?, 'Reloaded user should have the desired workflow state' end end
Version data entries
26 entries across 26 versions & 6 rubygems