From shino at rubyforge.org Mon Nov 26 22:00:06 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 26 Nov 2007 22:00:06 -0500 (EST) Subject: [ap4r-devel] [343] trunk/samples/HelloWorld: Initialize rspec and add some generated files. Message-ID: <20071127030006.108BF18585E4@rubyforge.org> Revision: 343 Author: shino Date: 2007-11-26 22:00:05 -0500 (Mon, 26 Nov 2007) Log Message: ----------- Initialize rspec and add some generated files. Added Paths: ----------- trunk/samples/HelloWorld/script/spec trunk/samples/HelloWorld/script/spec_server trunk/samples/HelloWorld/spec/ trunk/samples/HelloWorld/spec/spec.opts trunk/samples/HelloWorld/spec/spec_helper.rb Property Changed: ---------------- trunk/samples/HelloWorld/ Property changes on: trunk/samples/HelloWorld ___________________________________________________________________ Name: svn:ignore - uuid.state pkg pkg/* + uuid.state pkg pkg/* previous_failures.txt Added: trunk/samples/HelloWorld/script/spec =================================================================== --- trunk/samples/HelloWorld/script/spec (rev 0) +++ trunk/samples/HelloWorld/script/spec 2007-11-27 03:00:05 UTC (rev 343) @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib")) +require 'spec' +::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true) Property changes on: trunk/samples/HelloWorld/script/spec ___________________________________________________________________ Name: svn:executable + * Added: trunk/samples/HelloWorld/script/spec_server =================================================================== --- trunk/samples/HelloWorld/script/spec_server (rev 0) +++ trunk/samples/HelloWorld/script/spec_server 2007-11-27 03:00:05 UTC (rev 343) @@ -0,0 +1,86 @@ +#!/usr/bin/env ruby +$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn +$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin +require 'rubygems' +require 'drb/drb' +require 'rbconfig' +require 'spec' +require 'optparse' +specmate = ENV['HOME'] + "/Library/Application\ Support/TextMate/Bundles/RSpec.tmbundle/Support/lib" +if File.directory?(specmate) + $LOAD_PATH.unshift(specmate) + require 'text_mate_formatter' +end + +# This is based on Florian Weber's TDDMate + +module Spec + module Runner + class RailsSpecServer + def run(args, stderr, stdout) + $stdout = stdout + $stderr = stderr + + ::Dispatcher.reset_application! + ::Dependencies.mechanism = :load + require_dependency('application.rb') unless Object.const_defined?(:ApplicationController) + load File.dirname(__FILE__) + '/../spec/spec_helper.rb' + + ::Spec::Runner::CommandLine.run(args, stderr, stdout, false, true) + end + end + end +end +puts "Loading Rails environment" + +ENV["RAILS_ENV"] = "test" +require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require 'dispatcher' + +def restart_test_server + puts "restarting" + config = ::Config::CONFIG + ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT'] + command_line = [ruby, $0, ARGV].flatten.join(' ') + exec(command_line) +end + +def daemonize(pid_file = nil) + return yield if $DEBUG + pid = Process.fork{ + Process.setsid + Dir.chdir(RAILS_ROOT) + trap("SIGINT"){ exit! 0 } + trap("SIGTERM"){ exit! 0 } + trap("SIGHUP"){ restart_test_server } + File.open("/dev/null"){|f| + STDERR.reopen f + STDIN.reopen f + STDOUT.reopen f + } + yield + } + puts "spec_server launched. (PID: %d)" % pid + File.open(pid_file,"w"){|f| f.puts pid } if pid_file + exit! 0 +end + +options = Hash.new +opts = OptionParser.new +opts.on("-d", "--daemon"){|v| options[:daemon] = true } +opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v } +opts.parse!(ARGV) + +puts "Ready" +exec_server = lambda { + trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2") + DRb.start_service("druby://localhost:8989", Spec::Runner::RailsSpecServer.new) + DRb.thread.join +} + +if options[:daemon] + daemonize(options[:pid], &exec_server) +else + exec_server.call +end + Property changes on: trunk/samples/HelloWorld/script/spec_server ___________________________________________________________________ Name: svn:executable + * Added: trunk/samples/HelloWorld/spec/spec.opts =================================================================== --- trunk/samples/HelloWorld/spec/spec.opts (rev 0) +++ trunk/samples/HelloWorld/spec/spec.opts 2007-11-27 03:00:05 UTC (rev 343) @@ -0,0 +1,6 @@ +--colour +--format +progress +--loadby +mtime +--reverse Added: trunk/samples/HelloWorld/spec/spec_helper.rb =================================================================== --- trunk/samples/HelloWorld/spec/spec_helper.rb (rev 0) +++ trunk/samples/HelloWorld/spec/spec_helper.rb 2007-11-27 03:00:05 UTC (rev 343) @@ -0,0 +1,23 @@ +# This file is copied to ~/spec when you run 'ruby script/generate rspec' +# from the project root directory. +ENV["RAILS_ENV"] = "test" +require File.expand_path(File.dirname(__FILE__) + "/../config/environment") +require 'spec/rails' + +Spec::Runner.configure do |config| + config.use_transactional_fixtures = true + config.use_instantiated_fixtures = false + config.fixture_path = RAILS_ROOT + '/spec/fixtures' + + # You can declare fixtures for each behaviour like this: + # describe "...." do + # fixtures :table_a, :table_b + # + # Alternatively, if you prefer to declare them only once, you can + # do so here, like so ... + # + # config.global_fixtures = :table_a, :table_b + # + # If you declare global fixtures, be aware that they will be declared + # for all of your examples, even those that don't use them. +end From shinohara.shunichi at future.co.jp Mon Nov 26 21:59:11 2007 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Tue, 27 Nov 2007 11:59:11 +0900 Subject: [ap4r-devel] FW: ap4r-devel post from shino@rubyforge.org requires approval Message-ID: <14CE73B79D552644B7CBEF0428763DF603A06C5B@045MAIL.future.co.jp> I added the rspec and its rails plugin to the HelloWorld sample application. Commit log is a little large and not delivered to the list. The log message is as follows: # oops I made a type s/stabel/stable/ ------------------------------------------------------------------------ r342 | shino | 2007-11-27 11:48:39 +0900 (Tue, 27 Nov 2007) | 3 lines add rspec and its rails plugin. The version is 1.0.8 (latest stabel). Regards, shino From shino at rubyforge.org Mon Nov 26 22:06:28 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 26 Nov 2007 22:06:28 -0500 (EST) Subject: [ap4r-devel] [344] trunk/samples/HelloWorld: Add model Order and its migration file. Message-ID: <20071127030628.2455318585DD@rubyforge.org> Revision: 344 Author: shino Date: 2007-11-26 22:06:27 -0500 (Mon, 26 Nov 2007) Log Message: ----------- Add model Order and its migration file. This class is ported from gihyo.jp tags but remove its has_one relation to payment. Because I have not ported the Payment model yet (for simplicity). Added Paths: ----------- trunk/samples/HelloWorld/app/models/order.rb trunk/samples/HelloWorld/db/migrate/002_create_orders.rb Added: trunk/samples/HelloWorld/app/models/order.rb =================================================================== --- trunk/samples/HelloWorld/app/models/order.rb (rev 0) +++ trunk/samples/HelloWorld/app/models/order.rb 2007-11-27 03:06:27 UTC (rev 344) @@ -0,0 +1,2 @@ +class Order < ActiveRecord::Base +end Added: trunk/samples/HelloWorld/db/migrate/002_create_orders.rb =================================================================== --- trunk/samples/HelloWorld/db/migrate/002_create_orders.rb (rev 0) +++ trunk/samples/HelloWorld/db/migrate/002_create_orders.rb 2007-11-27 03:06:27 UTC (rev 344) @@ -0,0 +1,12 @@ +class CreateOrders < ActiveRecord::Migration + def self.up + create_table :orders do |t| + t.column :item, :string + t.column :created_at, :datetime + end + end + + def self.down + drop_table :orders + end +end From shinohara.shunichi at future.co.jp Mon Nov 26 22:09:48 2007 From: shinohara.shunichi at future.co.jp (shinohara.shunichi at future.co.jp) Date: Tue, 27 Nov 2007 12:09:48 +0900 Subject: [ap4r-devel] [343] trunk/samples/HelloWorld: Initialize rspec and add some generated files. In-Reply-To: <20071127030006.108BF18585E4@rubyforge.org> References: <20071127030006.108BF18585E4@rubyforge.org> Message-ID: <14CE73B79D552644B7CBEF0428763DF603A06C60@045MAIL.future.co.jp> When I initialize the rspec by 'ruby script/generate rspec', a empty file named "previous_failures.txt" was generated at Rails root directory. I did not check in this file because it seems to be personal/local memo. HTH Regards, shino > -----Original Message----- > From: ap4r-devel-bounces at rubyforge.org > [mailto:ap4r-devel-bounces at rubyforge.org] On Behalf Of > shino at rubyforge.org > Sent: Tuesday, November 27, 2007 12:00 PM > To: ap4r-devel at rubyforge.org > Subject: [ap4r-devel] [343] trunk/samples/HelloWorld: Initialize rspec > and add some generated files. > > Revision: 343 > Author: shino > Date: 2007-11-26 22:00:05 -0500 (Mon, 26 Nov 2007) > > Log Message: > ----------- > Initialize rspec and add some generated files. > > Added Paths: > ----------- > trunk/samples/HelloWorld/script/spec > trunk/samples/HelloWorld/script/spec_server > trunk/samples/HelloWorld/spec/ > trunk/samples/HelloWorld/spec/spec.opts > trunk/samples/HelloWorld/spec/spec_helper.rb > > Property Changed: > ---------------- > trunk/samples/HelloWorld/ > > > Property changes on: trunk/samples/HelloWorld > ___________________________________________________________________ > Name: svn:ignore > - uuid.state > pkg > pkg/* > > > + uuid.state > pkg > pkg/* > previous_failures.txt > > > > > Added: trunk/samples/HelloWorld/script/spec > =================================================================== > --- trunk/samples/HelloWorld/script/spec > (rev 0) > +++ trunk/samples/HelloWorld/script/spec 2007-11-27 03:00:05 UTC > (rev 343) > @@ -0,0 +1,4 @@ > +#!/usr/bin/env ruby > +$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + > "/../vendor/plugins/rspec/lib")) > +require 'spec' > +::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true) > > > Property changes on: trunk/samples/HelloWorld/script/spec > ___________________________________________________________________ > Name: svn:executable > + * > > Added: trunk/samples/HelloWorld/script/spec_server > =================================================================== > --- trunk/samples/HelloWorld/script/spec_server > (rev 0) > +++ trunk/samples/HelloWorld/script/spec_server 2007-11-27 03:00:05 UTC > (rev 343) > @@ -0,0 +1,86 @@ > +#!/usr/bin/env ruby > +$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn > +$LOAD_PATH.unshift File.dirname(__FILE__) + > '/../vendor/plugins/rspec/lib' # For rspec installed as plugin > +require 'rubygems' > +require 'drb/drb' > +require 'rbconfig' > +require 'spec' > +require 'optparse' > +specmate = ENV['HOME'] + > "/Library/Application\ Support/TextMate/Bundles/RSpec.tmbundle/Support > /lib" > +if File.directory?(specmate) > + $LOAD_PATH.unshift(specmate) > + require 'text_mate_formatter' > +end > + > +# This is based on Florian Weber's TDDMate > + > +module Spec > + module Runner > + class RailsSpecServer > + def run(args, stderr, stdout) > + $stdout = stdout > + $stderr = stderr > + > + ::Dispatcher.reset_application! > + ::Dependencies.mechanism = :load > + require_dependency('application.rb') unless > Object.const_defined?(:ApplicationController) > + load File.dirname(__FILE__) + '/../spec/spec_helper.rb' > + > + ::Spec::Runner::CommandLine.run(args, stderr, stdout, false, > true) > + end > + end > + end > +end > +puts "Loading Rails environment" > + > +ENV["RAILS_ENV"] = "test" > +require File.expand_path(File.dirname(__FILE__) + > "/../config/environment") > +require 'dispatcher' > + > +def restart_test_server > + puts "restarting" > + config = ::Config::CONFIG > + ruby = File::join(config['bindir'], > config['ruby_install_name']) + config['EXEEXT'] > + command_line = [ruby, $0, ARGV].flatten.join(' ') > + exec(command_line) > +end > + > +def daemonize(pid_file = nil) > + return yield if $DEBUG > + pid = Process.fork{ > + Process.setsid > + Dir.chdir(RAILS_ROOT) > + trap("SIGINT"){ exit! 0 } > + trap("SIGTERM"){ exit! 0 } > + trap("SIGHUP"){ restart_test_server } > + File.open("/dev/null"){|f| > + STDERR.reopen f > + STDIN.reopen f > + STDOUT.reopen f > + } > + yield > + } > + puts "spec_server launched. (PID: %d)" % pid > + File.open(pid_file,"w"){|f| f.puts pid } if pid_file > + exit! 0 > +end > + > +options = Hash.new > +opts = OptionParser.new > +opts.on("-d", "--daemon"){|v| options[:daemon] = true } > +opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v } > +opts.parse!(ARGV) > + > +puts "Ready" > +exec_server = lambda { > + trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2") > + DRb.start_service("druby://localhost:8989", > Spec::Runner::RailsSpecServer.new) > + DRb.thread.join > +} > + > +if options[:daemon] > + daemonize(options[:pid], &exec_server) > +else > + exec_server.call > +end > + > > > Property changes on: trunk/samples/HelloWorld/script/spec_server > ___________________________________________________________________ > Name: svn:executable > + * > > Added: trunk/samples/HelloWorld/spec/spec.opts > =================================================================== > --- trunk/samples/HelloWorld/spec/spec.opts > (rev 0) > +++ trunk/samples/HelloWorld/spec/spec.opts 2007-11-27 03:00:05 UTC > (rev 343) > @@ -0,0 +1,6 @@ > +--colour > +--format > +progress > +--loadby > +mtime > +--reverse > > Added: trunk/samples/HelloWorld/spec/spec_helper.rb > =================================================================== > --- trunk/samples/HelloWorld/spec/spec_helper.rb > (rev 0) > +++ trunk/samples/HelloWorld/spec/spec_helper.rb 2007-11-27 > 03:00:05 UTC (rev 343) > @@ -0,0 +1,23 @@ > +# This file is copied to ~/spec when you run 'ruby script/generate rspec' > +# from the project root directory. > +ENV["RAILS_ENV"] = "test" > +require File.expand_path(File.dirname(__FILE__) + > "/../config/environment") > +require 'spec/rails' > + > +Spec::Runner.configure do |config| > + config.use_transactional_fixtures = true > + config.use_instantiated_fixtures = false > + config.fixture_path = RAILS_ROOT + '/spec/fixtures' > + > + # You can declare fixtures for each behaviour like this: > + # describe "...." do > + # fixtures :table_a, :table_b > + # > + # Alternatively, if you prefer to declare them only once, you can > + # do so here, like so ... > + # > + # config.global_fixtures = :table_a, :table_b > + # > + # If you declare global fixtures, be aware that they will be declared > + # for all of your examples, even those that don't use them. > +end > > > _______________________________________________ > ap4r-devel mailing list > ap4r-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/ap4r-devel From shino at rubyforge.org Mon Nov 26 22:44:33 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 26 Nov 2007 22:44:33 -0500 (EST) Subject: [ap4r-devel] [345] trunk/samples/HelloWorld/vendor/plugins/rspec: modify version.rb\' s in rspec and rspec_on_rails. Message-ID: <20071127034433.3859318585E1@rubyforge.org> Revision: 345 Author: shino Date: 2007-11-26 22:44:32 -0500 (Mon, 26 Nov 2007) Log Message: ----------- modify version.rb\'s in rspec and rspec_on_rails. Because it causes exception(nil#[]). The number 2338 is the last revision of 1.0.8, in r2339 1.0.8's tag is made (see rspec's svn history for detail).' Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/rspec/lib/spec/version.rb trunk/samples/HelloWorld/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb Modified: trunk/samples/HelloWorld/vendor/plugins/rspec/lib/spec/version.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/rspec/lib/spec/version.rb 2007-11-27 03:06:27 UTC (rev 344) +++ trunk/samples/HelloWorld/vendor/plugins/rspec/lib/spec/version.rb 2007-11-27 03:44:32 UTC (rev 345) @@ -7,15 +7,15 @@ RELEASE_CANDIDATE = nil # RANDOM_TOKEN: 0.510454315029681 - REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1] + REV = "$LastChangedRevision: 2338$".match(/LastChangedRevision: (\d+)/)[1] STRING = [MAJOR, MINOR, TINY].join('.') TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_') FULL_VERSION = "#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('.')} (r#{REV})" NAME = "RSpec" - URL = "http://rspec.rubyforge.org/" - + URL = "http://rspec.rubyforge.org/" + DESCRIPTION = "#{NAME}-#{FULL_VERSION} - BDD for Ruby\n#{URL}" end end Modified: trunk/samples/HelloWorld/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb 2007-11-27 03:06:27 UTC (rev 344) +++ trunk/samples/HelloWorld/vendor/plugins/rspec_on_rails/lib/spec/rails/version.rb 2007-11-27 03:44:32 UTC (rev 345) @@ -3,7 +3,7 @@ module VERSION #:nodoc: unless defined?(REV) # RANDOM_TOKEN: 0.510454315029681 - REV = "$LastChangedRevision$".match(/LastChangedRevision: (\d+)/)[1] + REV = "$LastChangedRevision: 2338$".match(/LastChangedRevision: (\d+)/)[1] end end end From shino at rubyforge.org Mon Nov 26 22:48:42 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 26 Nov 2007 22:48:42 -0500 (EST) Subject: [ap4r-devel] [346] trunk/samples/HelloWorld/spec: Add a fixture for Order. Message-ID: <20071127034842.79EA518585E5@rubyforge.org> Revision: 346 Author: shino Date: 2007-11-26 22:48:41 -0500 (Mon, 26 Nov 2007) Log Message: ----------- Add a fixture for Order. Add a trivial rspec example for the model order. Added Paths: ----------- trunk/samples/HelloWorld/spec/fixtures/ trunk/samples/HelloWorld/spec/fixtures/orders.yml trunk/samples/HelloWorld/spec/models/ trunk/samples/HelloWorld/spec/models/order_spec.rb Added: trunk/samples/HelloWorld/spec/fixtures/orders.yml =================================================================== --- trunk/samples/HelloWorld/spec/fixtures/orders.yml (rev 0) +++ trunk/samples/HelloWorld/spec/fixtures/orders.yml 2007-11-27 03:48:41 UTC (rev 346) @@ -0,0 +1,6 @@ +# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html +AP4R_Book: + id: 1 + item: "Introduction to AP4R" + + Added: trunk/samples/HelloWorld/spec/models/order_spec.rb =================================================================== --- trunk/samples/HelloWorld/spec/models/order_spec.rb (rev 0) +++ trunk/samples/HelloWorld/spec/models/order_spec.rb 2007-11-27 03:48:41 UTC (rev 346) @@ -0,0 +1,11 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Order do + before(:each) do + @order = Order.new + end + + it "should be valid" do + @order.should be_valid + end +end From shino at rubyforge.org Mon Nov 26 23:09:00 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Mon, 26 Nov 2007 23:09:00 -0500 (EST) Subject: [ap4r-devel] [347] trunk/samples/HelloWorld/spec/models/stored_message_spec.rb: Add rspec examples for StoredMessage. Message-ID: <20071127040901.091BE18585E8@rubyforge.org> Revision: 347 Author: shino Date: 2007-11-26 23:08:59 -0500 (Mon, 26 Nov 2007) Log Message: ----------- Add rspec examples for StoredMessage. Two examples are defined in case that an exception will be thrown. In both, Order and Ap4r::StoredMessage are created and raise exception. If Order is created AFTER Ap4r::StoredMessage, the example goes well. But Order is created IN ADVANCE, it fails because of AP4R bugs. So one example is now marked as PENDING. Added Paths: ----------- trunk/samples/HelloWorld/spec/models/stored_message_spec.rb Added: trunk/samples/HelloWorld/spec/models/stored_message_spec.rb =================================================================== --- trunk/samples/HelloWorld/spec/models/stored_message_spec.rb (rev 0) +++ trunk/samples/HelloWorld/spec/models/stored_message_spec.rb 2007-11-27 04:08:59 UTC (rev 347) @@ -0,0 +1,35 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Ap4r::StoredMessage, "with an exception throwed in transaction block" do + + it "should be rolled back along with Order (Order is created in advance)" do + pending "Not work now for the AP4R's bug" + # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino + lambda { + Ap4r::StoredMessage.transaction do + Order.create({ :item => "item name"}) + Ap4r::StoredMessage.store("dummy_queue", "dummy_message") + raise "dummy exception" + end + }.should raise_error + + Ap4r::StoredMessage.should have(:no).records + Order.should have(:no).records + + end + + it "should be rolled back along with Order (Order is created afterward" do + # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino + lambda { + Ap4r::StoredMessage.transaction do + Ap4r::StoredMessage.store("dummy_queue", "dummy_message") + Order.create({ :item => "item name"}) + raise "dummy exception" + end + }.should raise_error + + Ap4r::StoredMessage.should have(:no).records + Order.should have(:no).records + + end +end From shino at rubyforge.org Tue Nov 27 01:44:02 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 27 Nov 2007 01:44:02 -0500 (EST) Subject: [ap4r-devel] [348] trunk/samples/HelloWorld/spec: Add examples about StoredMessage with transaction Message-ID: <20071127064402.F400A18585DD@rubyforge.org> Revision: 348 Author: shino Date: 2007-11-27 01:44:02 -0500 (Tue, 27 Nov 2007) Log Message: ----------- Add examples about StoredMessage with transaction Modified Paths: -------------- trunk/samples/HelloWorld/spec/models/stored_message_spec.rb trunk/samples/HelloWorld/spec/spec_helper.rb Modified: trunk/samples/HelloWorld/spec/models/stored_message_spec.rb =================================================================== --- trunk/samples/HelloWorld/spec/models/stored_message_spec.rb 2007-11-27 04:08:59 UTC (rev 347) +++ trunk/samples/HelloWorld/spec/models/stored_message_spec.rb 2007-11-27 06:44:02 UTC (rev 348) @@ -2,11 +2,22 @@ describe Ap4r::StoredMessage, "with an exception throwed in transaction block" do - it "should be rolled back along with Order (Order is created in advance)" do - pending "Not work now for the AP4R's bug" + it "should be rolled back" do # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino lambda { Ap4r::StoredMessage.transaction do + Ap4r::StoredMessage.store("dummy_queue", "dummy_message") + raise "dummy exception" + end + }.should raise_error + + Ap4r::StoredMessage.should have(:no).records + end + + it "should be rolled back (Order is created in advance)" do + # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino + lambda { + Ap4r::StoredMessage.transaction do Order.create({ :item => "item name"}) Ap4r::StoredMessage.store("dummy_queue", "dummy_message") raise "dummy exception" @@ -14,11 +25,9 @@ }.should raise_error Ap4r::StoredMessage.should have(:no).records - Order.should have(:no).records - end - it "should be rolled back along with Order (Order is created afterward" do + it "should be rolled back (Order is created afterwards)" do # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino lambda { Ap4r::StoredMessage.transaction do @@ -29,7 +38,31 @@ }.should raise_error Ap4r::StoredMessage.should have(:no).records + end + + it "should be rolled back as well as Order (Order is created in advance)" do + # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino + lambda { + Ap4r::StoredMessage.transaction do + Order.create({ :item => "item name"}) + Ap4r::StoredMessage.store("dummy_queue", "dummy_message") + raise "dummy exception" + end + }.should raise_error + Order.should have(:no).records + end + it "should be rolled back as well as Order (Order is created afterward" do + # TODO: NOT purely the model's example because the Order model is included 2007/11/27 by shino + lambda { + Ap4r::StoredMessage.transaction do + Ap4r::StoredMessage.store("dummy_queue", "dummy_message") + Order.create({ :item => "item name"}) + raise "dummy exception" + end + }.should raise_error + + Order.should have(:no).records end end Modified: trunk/samples/HelloWorld/spec/spec_helper.rb =================================================================== --- trunk/samples/HelloWorld/spec/spec_helper.rb 2007-11-27 04:08:59 UTC (rev 347) +++ trunk/samples/HelloWorld/spec/spec_helper.rb 2007-11-27 06:44:02 UTC (rev 348) @@ -5,7 +5,7 @@ require 'spec/rails' Spec::Runner.configure do |config| - config.use_transactional_fixtures = true + config.use_transactional_fixtures = false config.use_instantiated_fixtures = false config.fixture_path = RAILS_ROOT + '/spec/fixtures' From shino at rubyforge.org Tue Nov 27 02:16:44 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 27 Nov 2007 02:16:44 -0500 (EST) Subject: [ap4r-devel] [349] trunk/ap4r/lib/ap4r/stored_message.rb: Fix: change the logic to determine whether postgreslq or not. Message-ID: <20071127071644.74BAB18585E8@rubyforge.org> Revision: 349 Author: shino Date: 2007-11-27 02:16:44 -0500 (Tue, 27 Nov 2007) Log Message: ----------- Fix: change the logic to determine whether postgreslq or not. ActiveRecord::Base.establish_connection will create NEW connection. So just to check the database adapter, should use other APIs without side effects. Now I used ActiveRecord::Base.connection which returns the database adapter, also create the adapter(connection) if it does not exist. The adapter object have adapter_name which returns the name in String. Modified Paths: -------------- trunk/ap4r/lib/ap4r/stored_message.rb Modified: trunk/ap4r/lib/ap4r/stored_message.rb =================================================================== --- trunk/ap4r/lib/ap4r/stored_message.rb 2007-11-27 06:44:02 UTC (rev 348) +++ trunk/ap4r/lib/ap4r/stored_message.rb 2007-11-27 07:16:44 UTC (rev 349) @@ -31,7 +31,7 @@ def dumped_headers # The warning occurs when putting backslash into binaly type in PostgreSQL. - if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + if postgresql? self.headers else Marshal::dump(self.headers) @@ -40,7 +40,7 @@ def dumped_object # The warning occurs when putting backslash into binaly type in PostgreSQL. - if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + if postgresql? self.object else Marshal::dump(self.object) @@ -63,7 +63,7 @@ s.status = STATUS_STORED # The warning occurs when putting backslash into binaly type in PostgreSQL. - if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + if postgresql? s.object = YAML.dump(queue_message) s.headers = YAML.dump(rm_options) else @@ -98,6 +98,10 @@ result.destroy_or_update(options) end + def self.postgresql? + "PostgreSQL" == Ap4r::StoredMessage.connection.adapter_name + end + def destroy_or_update(options = {:delete_mode => PHYSICAL}) case options[:delete_mode] when PHYSICAL @@ -184,7 +188,7 @@ queue_name = self.queue # The warning occurs when putting backslash into binaly type in PostgreSQL. - if "postgresql" == Ap4r::StoredMessage.establish_connection.config[:adapter] + if self.class.postgresql? queue_headers = YAML.load(self.headers) queue_messages = YAML.load(self.object) else From shino at rubyforge.org Tue Nov 27 02:38:13 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 27 Nov 2007 02:38:13 -0500 (EST) Subject: [ap4r-devel] [350] trunk/samples/HelloWorld/vendor/plugins/ap4r/lib: Fix: Bug when : controller is not passed to ap4r.async_to . Message-ID: <20071127073813.17A3818585E1@rubyforge.org> Revision: 350 Author: shino Date: 2007-11-27 02:38:12 -0500 (Tue, 27 Nov 2007) Log Message: ----------- Fix: Bug when :controller is not passed to ap4r.async_to . Some refactoring needed: to separate general ap4r clinet and one that works only in Rails. Modified Paths: -------------- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb 2007-11-27 07:16:44 UTC (rev 349) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/ap4r_client.rb 2007-11-27 07:38:12 UTC (rev 350) @@ -30,7 +30,7 @@ @controller = controller end - def_delegators :@controller, :logger, :url_for + def_delegators :@controller, :logger, :url_for, :controller_path # Queue a message for next asynchronous logic. Some options are supported. # Modified: trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb =================================================================== --- trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-11-27 07:16:44 UTC (rev 349) +++ trunk/samples/HelloWorld/vendor/plugins/ap4r/lib/async_helper.rb 2007-11-27 07:38:12 UTC (rev 350) @@ -193,7 +193,7 @@ super @url_options ||= {} - @url_options[:controller] ||= @controller.controller_path.gsub("/", ".") + @url_options[:controller] ||= @url_for_handler.controller_path.gsub("/", ".") @url_options[:url] ||= {:controller => url_options[:controller], :action => url_options[:action]} @url_options[:url][:controller] ||= url_options[:controller] if url_options[:url].kind_of?(Hash) end From shino at rubyforge.org Tue Nov 27 02:39:53 2007 From: shino at rubyforge.org (shino at rubyforge.org) Date: Tue, 27 Nov 2007 02:39:53 -0500 (EST) Subject: [ap4r-devel] [351] trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb: Refactor: remove comments in Japanese. Message-ID: <20071127073953.5184418585E1@rubyforge.org> Revision: 351 Author: shino Date: 2007-11-27 02:39:52 -0500 (Tue, 27 Nov 2007) Log Message: ----------- Refactor: remove comments in Japanese. Add: the action which uses SAF Add: params handling to raise a dummy exception Modified Paths: -------------- trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb Modified: trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb =================================================================== --- trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb 2007-11-27 07:38:12 UTC (rev 350) +++ trunk/samples/HelloWorld/app/controllers/async_shop_controller.rb 2007-11-27 07:39:52 UTC (rev 351) @@ -1,15 +1,19 @@ class AsyncShopController < ApplicationController def order -# ap4r.transaction do - # ???? - # ... + ap4r.transaction do + do_order + end - # ???? (??????????????) - ap4r.async_to({:action => 'account'}, - {:sleep_time => params[id]}) -# end + render :text => 'Order completed successfully.' + end + def order_with_saf + ap4r.transaction do + do_order + raise "dummy exception to verify whethrer SAF works well" if params[:raise] + end + render :text => 'Order completed successfully.' end @@ -19,4 +23,12 @@ render :text => 'true' end + private + def do_order + Order.create(:item => params[:item] || "Introduction to AP4R") + ap4r.async_to({:action => 'account'}, + {:sleep_time => params[id] || 1}) + end + + end From kato-k at rubyforge.org Thu Nov 29 05:20:13 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 29 Nov 2007 05:20:13 -0500 (EST) Subject: [ap4r-devel] [352] trunk/ap4r/lib/ap4r/version.rb: Changed version. Message-ID: <20071129102014.238161858623@rubyforge.org> Revision: 352 Author: kato-k Date: 2007-11-29 05:20:11 -0500 (Thu, 29 Nov 2007) Log Message: ----------- Changed version. Modified Paths: -------------- trunk/ap4r/lib/ap4r/version.rb Modified: trunk/ap4r/lib/ap4r/version.rb =================================================================== --- trunk/ap4r/lib/ap4r/version.rb 2007-11-27 07:39:52 UTC (rev 351) +++ trunk/ap4r/lib/ap4r/version.rb 2007-11-29 10:20:11 UTC (rev 352) @@ -3,12 +3,12 @@ # Licence:: MIT Licence module Ap4r - # Defines version number contants, and provides + # Defines version number contants, and provides # its string expression. module VERSION #:nodoc: MAJOR = 0 MINOR = 3 - TINY = 4 + TINY = 5 STRING = [MAJOR, MINOR, TINY].join('.') end From kato-k at rubyforge.org Thu Nov 29 05:21:23 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 29 Nov 2007 05:21:23 -0500 (EST) Subject: [ap4r-devel] [353] trunk/ap4r/History.txt: Added comment. Message-ID: <20071129102123.93E7F1858636@rubyforge.org> Revision: 353 Author: kato-k Date: 2007-11-29 05:21:22 -0500 (Thu, 29 Nov 2007) Log Message: ----------- Added comment. Modified Paths: -------------- trunk/ap4r/History.txt Modified: trunk/ap4r/History.txt =================================================================== --- trunk/ap4r/History.txt 2007-11-29 10:20:11 UTC (rev 352) +++ trunk/ap4r/History.txt 2007-11-29 10:21:22 UTC (rev 353) @@ -1,5 +1,9 @@ == 0.3.x +=== 0.3.5 (November 29, 2007) +* Fixed: bug that SAF transaction is NOT guaranteed when some models are created/updated + before using of ap4r.async_to API in ap4r.transaction block. + === 0.3.4 (October 31, 2007) * Added: Support ActiveRecord as reliable RDBMS persistence. * Added: Capistrano recipes. @@ -17,10 +21,10 @@ * Changed: Argument order of async_dispatch has changed, backward INCOMPATIBLE. * Added: Dynamic configuration with ERb. * Added: Script to run AP4R on Mongrel. -* Changed: How to plugin and main API names have changed. -* Added: Support of several Content-type on asynchronous call. +* Changed: How to plugin and main API names have changed. +* Added: Support of several Content-type on asynchronous call. * Added: Block style for async_to. -* Added: Url rewrite filter. +* Added: Url rewrite filter. === 0.3.1 (April 24th, 2007) From kato-k at rubyforge.org Thu Nov 29 06:03:19 2007 From: kato-k at rubyforge.org (kato-k at rubyforge.org) Date: Thu, 29 Nov 2007 06:03:19 -0500 (EST) Subject: [ap4r-devel] [354] tags/ap4r-0.3.5/: tag 0.3.5 Message-ID: <20071129110319.E0125185865E@rubyforge.org> Revision: 354 Author: kato-k Date: 2007-11-29 06:03:19 -0500 (Thu, 29 Nov 2007) Log Message: ----------- tag 0.3.5 Added Paths: ----------- tags/ap4r-0.3.5/ Copied: tags/ap4r-0.3.5 (from rev 353, trunk)