rom-rails 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d81f44c9999447bf6ccdc64f6529bc1fd614d19d
4
- data.tar.gz: 4114017307dfae118382f978f1433ff1869595d3
3
+ metadata.gz: c71af912d846495ada02031cada0f862e572ae3a
4
+ data.tar.gz: f4a68403dd222af657cbea87ab6531be66f27191
5
5
  SHA512:
6
- metadata.gz: 9fbf68d09cc7cd8f92460fb60eac6c54badc9200763347080f879c377de8638467ae9441be6d6095cc553d9328341c8cdb0f2e1a2f5a68973623e27bf4c5bcfe
7
- data.tar.gz: 8dc7266b70cc95434bcbf162b01d356c381f17cd8bda8defa3326eb397535f5aeb4be227e1d5d19ae896440dae57e2f8ed627dd675f8c51c491567c3758af3ab
6
+ metadata.gz: 28d19550136b0bf857f3728edfe5a374426f9612d719cb37ffbf63868f7673af93cdeb837fea2a34e70861ea532942f720a72740d0cdad680060cc475a75fff7
7
+ data.tar.gz: 12c820a8f0ffdb019fc53dba13f6f90f573e2cff9bc7a04b7361ee48ee906fd45b6d485611373dde921df2e48200bab14a5b1595576081a719ecb119b1bd4e67
data/.travis.yml CHANGED
@@ -4,15 +4,21 @@ cache: bundler
4
4
  bundler_args: --without yard guard benchmarks
5
5
  script: "RAILS_ENV=test bundle exec rake app:db:reset app:spec"
6
6
  rvm:
7
- - 2.1
8
- - 2.2
7
+ - 2.2.2
9
8
  - 2.3.1
10
9
  - rbx-2
11
10
  - jruby-9.0.5.0
12
11
  - ruby-head
12
+ env:
13
+ - RAILS_VERSION=5.0.0
14
+ - RAILS_VERSION=4.2.0
13
15
  matrix:
14
16
  allow_failures:
15
17
  - rvm: ruby-head
18
+ - rvm: rbx-2
19
+ exclude:
20
+ - rvm: rbx-2
21
+ env: RAILS_VERSION=5.0.0
16
22
  notifications:
17
23
  webhooks:
18
24
  urls:
data/CHANGELOG.md CHANGED
@@ -1,8 +1,31 @@
1
- ## v0.6.0 to-be-released
1
+ ## v0.8.0 2016-08-08
2
+ ### Changed
3
+
4
+ - Updated to work with Rails 5 (cflipse)
5
+ - Form validations are now handled entirely within form (cflipse)
6
+ - [Rails5] when applicable, parmeters are converted to unsafe hash (cflipse)
7
+
8
+ ### Deprecated
9
+ - Dropping support for ruby 2.1 and below
10
+
11
+ ## v0.7.0 2016-07-27
12
+
13
+ ### Changed
14
+ - Updated to work with rom 2.0
15
+ - Loosen Gem dependencies for Rails 4.2
16
+ - Allow multiple auto_registration paths (vbyno)
2
17
 
3
- Updated to work with new ROM configuration API.
18
+ [Compare v0.6.0...v0.7.0](https://github.com/rom-rb/rom-rails/compare/v0.6.0...v0.7.0)
19
+
20
+ ### Fixed
21
+ - Fixed generated mapper's `register_as` (duduribeiro)
22
+
23
+ ## v0.6.0 2016-01-06
24
+
25
+ ### Changed
26
+ - Updated to work with new ROM configuration API.
4
27
 
5
- [Compare v0.6.0...HEAD](https://github.com/rom-rb/rom-rails/compare/v0.6.0...HEAD)
28
+ [Compare v0.5.0...v0.6.0](https://github.com/rom-rb/rom-rails/compare/v0.5.0...v0.6.0)
6
29
 
7
30
  ## v0.5.0 2015-08-19
8
31
 
data/Gemfile CHANGED
@@ -2,15 +2,16 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- RAILS_VERSION = '~> 4.2.4'.freeze
5
+ RAILS_VERSION = ENV.fetch("RAILS_VERSION", '5.0.0').freeze
6
6
 
7
7
  %w(railties actionview actionpack activerecord).each do |name|
8
- gem name, RAILS_VERSION
8
+ gem name, "~> #{RAILS_VERSION}"
9
9
  end
10
10
 
11
11
  gem 'sqlite3', platforms: [:mri, :rbx]
12
12
  gem 'byebug', platforms: :mri
13
13
  gem 'rom-sql', '~> 0.8'
14
+ gem 'rom-model', github: 'rom-rb/rom-model', branch: 'master'
14
15
 
15
16
  platforms :jruby do
16
17
  gem 'jdbc-sqlite3'
data/README.md CHANGED
@@ -35,7 +35,7 @@ To run tests:
35
35
  You can read more about ROM and Rails on the official website:
36
36
 
37
37
  * [Introduction to ROM](http://rom-rb.org/learn/)
38
- * [Rails setup](http://rom-rb.org/learn/setup/rails/)
38
+ * [Rails setup](http://rom-rb.org/learn/getting-started/rails-setup/)
39
39
 
40
40
 
41
41
  ## Community
@@ -92,8 +92,9 @@ module ROM
92
92
 
93
93
  # @api private
94
94
  def initialize(params = {}, options = {})
95
- @params = params
96
- @model = self.class.model.new(params.merge(options.slice(*self.class.key)))
95
+ @params = params.respond_to?(:to_unsafe_hash) ?
96
+ params.to_unsafe_hash : params
97
+ @model = self.class.model.new(params.to_h.merge(options.slice(*self.class.key)))
97
98
  @result = nil
98
99
  @errors = ErrorProxy.new
99
100
  options.each { |key, value| instance_variable_set("@#{key}", value) }
@@ -114,9 +115,9 @@ module ROM
114
115
  #
115
116
  # @api public
116
117
  def save(*args)
117
- @errors.clear
118
- @result = commit!(*args)
118
+ validate!
119
119
 
120
+ @result = commit!(*args) unless @errors.present?
120
121
  @errors.set @result.error if result.respond_to? :error
121
122
 
122
123
  self
@@ -136,6 +137,7 @@ module ROM
136
137
  # @api public
137
138
  def validate!
138
139
  @errors.clear
140
+ return unless defined? self.class::Validator
139
141
  validator = self.class::Validator.new(attributes)
140
142
  validator.validate
141
143
 
@@ -428,7 +428,6 @@ module ROM
428
428
  klass = ConfigurationDSL::Command.build_class(name, rel_name, adapter: adapter)
429
429
 
430
430
  klass.result :one
431
- klass.validator @validator
432
431
 
433
432
  relation = rom.relations[rel_name]
434
433
  gateway = rom.gateways[relation.gateway]
@@ -1,5 +1,5 @@
1
1
  module ROM
2
2
  module Rails
3
- VERSION = '0.7.0'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
5
5
  end
data/rom-rails.gemspec CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency 'addressable', '~> 2.3'
25
25
  spec.add_runtime_dependency 'charlatan', '~> 0.1'
26
26
  spec.add_runtime_dependency 'virtus', '~> 1.0', '>= 1.0.5'
27
- spec.add_runtime_dependency 'railties', ['>= 3.0', '< 5.0']
27
+ spec.add_runtime_dependency 'railties', '>= 3.0', '< 6.0'
28
28
 
29
29
  spec.add_development_dependency "bundler"
30
30
  spec.add_development_dependency "rake"
@@ -0,0 +1,11 @@
1
+ class CreateTaskWithValidations < CreateTask
2
+ register_as :create_task_with_validations
3
+
4
+ class Validator
5
+ include ROM::Model::Validator
6
+
7
+ validates :title, presence: true
8
+ end
9
+
10
+ validator Validator
11
+ end
@@ -10,8 +10,6 @@ require 'rspec-rails'
10
10
 
11
11
  module Dummy
12
12
  class Application < Rails::Application
13
- config.assets.enabled = false
14
-
15
13
  require 'rom/test_adapter'
16
14
  end
17
15
  end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Form with command supplied validations' do
4
+
5
+ subject(:form) { form_class.build(params) }
6
+
7
+ let(:params) {{}}
8
+
9
+ let(:form_class) do
10
+ Class.new(ROM::Model::Form) do
11
+ inject_commands_for :tasks
12
+
13
+ input do
14
+ set_model_name 'Task'
15
+
16
+ attribute :title
17
+ end
18
+
19
+ def commit!
20
+ tasks.try { tasks.create_task_with_validations.call(attributes) }
21
+ end
22
+ end
23
+ end
24
+
25
+
26
+ it "copies validation errors from command" do
27
+ form.save
28
+
29
+ errors = form.errors
30
+ expect(errors[:title]).to be_present
31
+ end
32
+
33
+ end
@@ -187,12 +187,12 @@ describe 'Form' do
187
187
 
188
188
  describe '#save' do
189
189
  it 'commits the form without extra args' do
190
- result = form.build({}).save.result
190
+ result = form.build({email: 'jdoe@example.com'}).save.result
191
191
  expect(result).to eql('it works []')
192
192
  end
193
193
 
194
194
  it 'commits the form with extra args' do
195
- result = form.build({}).save(1, 2, 3).result
195
+ result = form.build({email: 'jdoe@example.com'}).save(1, 2, 3).result
196
196
  expect(result).to eql('it works [1, 2, 3]')
197
197
  end
198
198
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rom-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-27 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rom
@@ -123,7 +123,7 @@ dependencies:
123
123
  version: '3.0'
124
124
  - - "<"
125
125
  - !ruby/object:Gem::Version
126
- version: '5.0'
126
+ version: '6.0'
127
127
  type: :runtime
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
@@ -133,7 +133,7 @@ dependencies:
133
133
  version: '3.0'
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
- version: '5.0'
136
+ version: '6.0'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: bundler
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +192,6 @@ files:
192
192
  - LICENSE
193
193
  - README.md
194
194
  - Rakefile
195
- - db
196
195
  - lib/generators/rom.rb
197
196
  - lib/generators/rom/commands/templates/create.rb.erb
198
197
  - lib/generators/rom/commands/templates/delete.rb.erb
@@ -217,12 +216,12 @@ files:
217
216
  - lib/rom/rails/railtie.rb
218
217
  - lib/rom/rails/tasks/db.rake
219
218
  - lib/rom/rails/version.rb
220
- - log
221
219
  - rom-rails.gemspec
222
220
  - spec/dummy/.rspec
223
221
  - spec/dummy/README.rdoc
224
222
  - spec/dummy/Rakefile
225
223
  - spec/dummy/app/commands/create_task.rb
224
+ - spec/dummy/app/commands/create_task_with_validations.rb
226
225
  - spec/dummy/app/commands/delete_user.rb
227
226
  - spec/dummy/app/controllers/application_controller.rb
228
227
  - spec/dummy/app/controllers/users_controller.rb
@@ -280,6 +279,7 @@ files:
280
279
  - spec/dummy/vendor/assets/stylesheets/.keep
281
280
  - spec/features/users_spec.rb
282
281
  - spec/integration/activerecord_setup.rb
282
+ - spec/integration/form_with_command_validation_spec.rb
283
283
  - spec/integration/form_with_injected_commands_spec.rb
284
284
  - spec/integration/initializer_spec.rb
285
285
  - spec/integration/logger_spec.rb
@@ -313,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
313
313
  version: '0'
314
314
  requirements: []
315
315
  rubyforge_project:
316
- rubygems_version: 2.5.1
316
+ rubygems_version: 2.4.5.1
317
317
  signing_key:
318
318
  specification_version: 4
319
319
  summary: Integrate Ruby Object Mapper with Rails
@@ -322,6 +322,7 @@ test_files:
322
322
  - spec/dummy/README.rdoc
323
323
  - spec/dummy/Rakefile
324
324
  - spec/dummy/app/commands/create_task.rb
325
+ - spec/dummy/app/commands/create_task_with_validations.rb
325
326
  - spec/dummy/app/commands/delete_user.rb
326
327
  - spec/dummy/app/controllers/application_controller.rb
327
328
  - spec/dummy/app/controllers/users_controller.rb
@@ -379,6 +380,7 @@ test_files:
379
380
  - spec/dummy/vendor/assets/stylesheets/.keep
380
381
  - spec/features/users_spec.rb
381
382
  - spec/integration/activerecord_setup.rb
383
+ - spec/integration/form_with_command_validation_spec.rb
382
384
  - spec/integration/form_with_injected_commands_spec.rb
383
385
  - spec/integration/initializer_spec.rb
384
386
  - spec/integration/logger_spec.rb
data/db DELETED
@@ -1 +0,0 @@
1
- spec/dummy/db
data/log DELETED
@@ -1 +0,0 @@
1
- spec/dummy/log