Kouhei Sutou
null+****@clear*****
Mon Dec 5 17:55:53 JST 2016
Kouhei Sutou 2016-12-05 17:55:53 +0900 (Mon, 05 Dec 2016) New Revision: 32f5991b8af912b9e682d3a027086089f11b49f3 https://github.com/ranguba/groonga-client-model/commit/32f5991b8af912b9e682d3a027086089f11b49f3 Message: Implement save! for factory_girl Added files: test/apps/rails5/test/factories/posts.rb Modified files: lib/groonga_client_model/record.rb test/apps/rails5/Gemfile test/apps/rails5/Gemfile.lock test/apps/rails5/test/controllers/posts_controller_test.rb test/apps/rails5/test/test_helper.rb Modified: lib/groonga_client_model/record.rb (+7 -0) =================================================================== --- lib/groonga_client_model/record.rb 2016-12-05 17:42:13 +0900 (de2a573) +++ lib/groonga_client_model/record.rb 2016-12-05 17:55:53 +0900 (e853172) @@ -110,6 +110,13 @@ module GroongaClientModel end end + def save!(validate: false) + unless save(validate: validate) + message = "Failed to save the record" + raise RecordNotSaved.new(message, self) + end + end + def update(attributes) assign_attributes(attributes) save Modified: test/apps/rails5/Gemfile (+1 -0) =================================================================== --- test/apps/rails5/Gemfile 2016-12-05 17:42:13 +0900 (fc6409f) +++ test/apps/rails5/Gemfile 2016-12-05 17:55:53 +0900 (17b88bf) @@ -31,6 +31,7 @@ gem 'jbuilder', '~> 2.5' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platform: :mri + gem 'factory_girl_rails' end group :development do Modified: test/apps/rails5/Gemfile.lock (+6 -0) =================================================================== --- test/apps/rails5/Gemfile.lock 2016-12-05 17:42:13 +0900 (25da572) +++ test/apps/rails5/Gemfile.lock 2016-12-05 17:55:53 +0900 (332c422) @@ -59,6 +59,11 @@ GEM debug_inspector (0.0.2) erubis (2.7.0) execjs (2.7.0) + factory_girl (4.5.0) + activesupport (>= 3.0.0) + factory_girl_rails (4.6.0) + factory_girl (~> 4.5.0) + railties (>= 3.0.0) ffi (1.9.14) globalid (0.3.7) activesupport (>= 4.1.0) @@ -171,6 +176,7 @@ PLATFORMS DEPENDENCIES byebug coffee-rails (~> 4.2) + factory_girl_rails groonga-client-model! jbuilder (~> 2.5) jquery-rails Modified: test/apps/rails5/test/controllers/posts_controller_test.rb (+1 -1) =================================================================== --- test/apps/rails5/test/controllers/posts_controller_test.rb 2016-12-05 17:42:13 +0900 (8cd9d5d) +++ test/apps/rails5/test/controllers/posts_controller_test.rb 2016-12-05 17:55:53 +0900 (b45c481) @@ -2,7 +2,7 @@ require 'test_helper' class PostsControllerTest < ActionDispatch::IntegrationTest setup do - @post = posts(:one) + @post = create(:post) end test "should get index" do Added: test/apps/rails5/test/factories/posts.rb (+6 -0) 100644 =================================================================== --- /dev/null +++ test/apps/rails5/test/factories/posts.rb 2016-12-05 17:55:53 +0900 (5700297) @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :post do + title "Hello" + body "World" + end +end Modified: test/apps/rails5/test/test_helper.rb (+1 -0) =================================================================== --- test/apps/rails5/test/test_helper.rb 2016-12-05 17:42:13 +0900 (3acf9ae) +++ test/apps/rails5/test/test_helper.rb 2016-12-05 17:55:53 +0900 (2d79611) @@ -4,4 +4,5 @@ require 'rails/test_help' class ActiveSupport::TestCase # Add more helper methods to be used by all tests here... + include FactoryGirl::Syntax::Methods end -------------- next part -------------- HTML����������������������������... Descargar