linker 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/README.md +15 -12
- data/lib/linker/forms/attributes.rb +20 -15
- data/lib/linker/forms/configuration_methods.rb +1 -1
- data/lib/linker/forms/params.rb +13 -5
- data/lib/linker/version.rb +1 -1
- data/spec/cars_form_spec.rb +32 -4
- data/spec/fake_app/active_record/models.rb +32 -3
- data/spec/fake_app/forms/cars_form.rb +4 -2
- data/spec/fake_app/forms/issue_form.rb +5 -0
- data/spec/fake_app/rails_app.rb +2 -1
- data/spec/issue_form_spec.rb +37 -0
- data/spec/spec_helper.rb +6 -1
- data/spec/users_form_spec.rb +18 -18
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60d42e098225ca9705b7b56aab2eb39efc69f97a
|
4
|
+
data.tar.gz: e55847169da1cdaf8c342be11cf93d52eec4279f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 919e2f2cdc8bc5dbefd04856f046018cf3545a34fa7328ebfd5617e4049fa930af6785bf68835f573f60325fad996060bd00d6d14befa522c1c70783712000cb
|
7
|
+
data.tar.gz: 31c914abfdde1e38a63f0581e3b11b7ccb5a506bfe5750d02378c5775dbeaf7a66020ac6201d38b05703e02c4b4ac7ab7f255113282cf40e17ac334e2cd5fbba
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Next (unreleased)
|
4
|
+
* Your contribution here.
|
5
|
+
|
6
|
+
## 0.0.14 (2017-01-11)
|
7
|
+
* Add support for models which have polymorphic associations.
|
8
|
+
* Inferring main model (`main_model` is no more required).
|
9
|
+
* Add _list for `has_and_belongs_to_many` associations.
|
10
|
+
|
11
|
+
## 0.0.13 (2016-12-07)
|
12
|
+
* Wrap `save` method in a database transaction.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Supported versions
|
22
22
|
- Ruby 2.0+
|
23
|
-
- Rails 3.1+ (including 4
|
23
|
+
- Rails 3.1+ (including 4 and 5)
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
@@ -32,7 +32,7 @@ class User < ActiveRecord::Base
|
|
32
32
|
|
33
33
|
has_one :address, dependent: :destroy
|
34
34
|
has_one :profile
|
35
|
-
|
35
|
+
|
36
36
|
has_many :dependent_users, dependent: :destroy
|
37
37
|
has_many :tasks, dependent: :destroy
|
38
38
|
end
|
@@ -42,10 +42,11 @@ Create a form class through `rails g form whatever` or manually (it should inclu
|
|
42
42
|
```ruby
|
43
43
|
class UserForm
|
44
44
|
include Linker
|
45
|
-
|
46
|
-
main_model User # or :user or 'User'
|
47
45
|
|
48
|
-
#
|
46
|
+
# we infer the main model through the form's class name, but you can set manually like:
|
47
|
+
main_model User # or :user or 'User' ====> this line is optional
|
48
|
+
|
49
|
+
# Use relationship's name followed by "__" plus attribute's name
|
49
50
|
# to validate has_one and belongs_to associations
|
50
51
|
validates :name, :address__street, :company__name, presence: true
|
51
52
|
end
|
@@ -82,7 +83,7 @@ Finally, you can use `fields_for` in order to create/edit associated fields and
|
|
82
83
|
```erb
|
83
84
|
<%= form_for @user_form do |f| %>
|
84
85
|
<%= f.text_field :name %>
|
85
|
-
|
86
|
+
|
86
87
|
<%= f.fields_for :tasks do |ta| %>
|
87
88
|
<%= ta.hidden_field :id %>
|
88
89
|
<%= ta.text_field :name %>
|
@@ -99,9 +100,9 @@ Finally, you can use `fields_for` in order to create/edit associated fields and
|
|
99
100
|
|
100
101
|
## How it works
|
101
102
|
|
102
|
-
Linker will
|
103
|
+
Linker will create delegators for all attributes of main model and its associations (`has_one`, `has_many` and `belongs_to`, except for polymorphic ones) and let it ready to use.
|
103
104
|
|
104
|
-
Internally, it will include `ActiveModel::Model` if on Rails 4 or `ActiveModel::Validations` if on Rails < 4.
|
105
|
+
Internally, it will include `ActiveModel::Model` if on Rails 4+ or `ActiveModel::Validations` if on Rails < 4.
|
105
106
|
|
106
107
|
It will also create `params=` and `save` methods responsible to set new objects and save them. You can override these methods to get a custom behavior without worrying with delegations.
|
107
108
|
|
@@ -123,11 +124,9 @@ class CarsForm
|
|
123
124
|
include Linker
|
124
125
|
attr_accessor :before_save_checked
|
125
126
|
|
126
|
-
main_model :car
|
127
|
-
|
128
127
|
validates :name, presence: true
|
129
128
|
|
130
|
-
def before_set_params
|
129
|
+
def before_set_params(params)
|
131
130
|
params['name'] = "#{params['name']} 2000"
|
132
131
|
end
|
133
132
|
|
@@ -141,6 +140,10 @@ class CarsForm
|
|
141
140
|
end
|
142
141
|
```
|
143
142
|
|
143
|
+
## Roadmap
|
144
|
+
- [ ] Create delegators only for specified associations (not all as now). For ie: `main_model :car, only_associations: [:customer]`
|
145
|
+
- [ ] Rename this gem? Maybe.
|
146
|
+
|
144
147
|
## Contributing
|
145
148
|
|
146
149
|
1. Fork it
|
@@ -151,4 +154,4 @@ end
|
|
151
154
|
|
152
155
|
## License
|
153
156
|
|
154
|
-
This projected is licensed under the terms of the MIT license.
|
157
|
+
This projected is licensed under the terms of the MIT license.
|
@@ -18,7 +18,8 @@ module Linker
|
|
18
18
|
set_fields_for_methods(map_has_many_associations)
|
19
19
|
set_fields_for_methods(map_belongs_to_associations, true)
|
20
20
|
set_fields_for_methods(map_has_one_associations, true)
|
21
|
-
|
21
|
+
create_list_accessors_for(map_has_one_associations)
|
22
|
+
create_list_accessors_for(map_has_and_belongs_to_many_associations)
|
22
23
|
set_remove_accessor(map_has_many_associations)
|
23
24
|
end
|
24
25
|
|
@@ -35,6 +36,7 @@ module Linker
|
|
35
36
|
|
36
37
|
[map_has_one_associations, map_belongs_to_associations].each do |rgroup|
|
37
38
|
rgroup.each do |c|
|
39
|
+
return unless c[:columns]
|
38
40
|
c[:columns].each do |cc|
|
39
41
|
# ap "delegating #{cc} and #{cc}= for #{c[:name]}__#{cc}"
|
40
42
|
self.class.__send__(:delegate, cc, "#{cc}=", to: c[:name].underscore.to_sym, prefix: "#{c[:name]}_")
|
@@ -57,9 +59,13 @@ module Linker
|
|
57
59
|
@bt_assoc ||= @main_model.reflect_on_all_associations(:belongs_to)
|
58
60
|
end
|
59
61
|
|
62
|
+
def get_has_and_belongs_to_many_associations
|
63
|
+
@habtm_assoc ||= @main_model.reflect_on_all_associations(:has_and_belongs_to_many)
|
64
|
+
end
|
65
|
+
|
60
66
|
def filter_columns(model)
|
61
67
|
f = model.columns.map(&:name)
|
62
|
-
.delete_if{ |cn| USELESS_COLUMNS_REGEX.match(cn) }
|
68
|
+
.delete_if { |cn| USELESS_COLUMNS_REGEX.match(cn) }
|
63
69
|
# Get Paperclip attachments
|
64
70
|
begin
|
65
71
|
f = Paperclip::AttachmentRegistry.names_for(model).inject(f) do |t, c|
|
@@ -98,14 +104,9 @@ module Linker
|
|
98
104
|
end
|
99
105
|
end
|
100
106
|
|
101
|
-
def
|
107
|
+
def create_list_accessors_for(assoc_set)
|
102
108
|
assoc_set.each do |c|
|
103
|
-
|
104
|
-
self.class.send(:define_method, "#{c[:name]}_list") do
|
105
|
-
assoc = instance_variable_get("@#{get_main_model.to_s.underscore}")
|
106
|
-
.send(c[:name])
|
107
|
-
assoc.present? && assoc.id || nil
|
108
|
-
end
|
109
|
+
self.class.__send__(:attr_accessor, "#{c[:name]}_list")
|
109
110
|
end
|
110
111
|
end
|
111
112
|
|
@@ -120,29 +121,33 @@ module Linker
|
|
120
121
|
assoc.inject([]) do |t, c|
|
121
122
|
t << {
|
122
123
|
name: c.name.to_s,
|
123
|
-
klass: c.klass.name,
|
124
|
-
# delete_if remove useless attrs
|
125
|
-
columns: filter_columns(c.klass)
|
126
124
|
}
|
125
|
+
unless c.options[:polymorphic]
|
126
|
+
t.last[:columns] = filter_columns(c.klass)
|
127
|
+
t.last[:klass] = c.klass.name
|
128
|
+
end
|
129
|
+
t
|
127
130
|
end
|
128
131
|
end
|
129
132
|
|
130
133
|
def map_has_many_associations
|
131
134
|
# Create an array with associated classes names and attrs
|
132
135
|
@mapped_hm_assoc ||= map_associations(get_has_many_associations)
|
133
|
-
@mapped_hm_assoc
|
134
136
|
end
|
135
137
|
|
136
138
|
def map_belongs_to_associations
|
137
139
|
# Create an array with associated classes names and attrs
|
138
140
|
@mapped_bt_assoc ||= map_associations(get_belongs_to_associations)
|
139
|
-
@mapped_bt_assoc
|
140
141
|
end
|
141
142
|
|
142
143
|
def map_has_one_associations
|
143
144
|
# Create an array with associated classes names and attrs
|
144
145
|
@mapped_ho_assoc ||= map_associations(get_has_one_associations)
|
145
|
-
|
146
|
+
end
|
147
|
+
|
148
|
+
def map_has_and_belongs_to_many_associations
|
149
|
+
# Create an array with associated classes names and attrs
|
150
|
+
@mapped_habtm_assoc ||= map_associations(get_has_and_belongs_to_many_associations)
|
146
151
|
end
|
147
152
|
end
|
148
153
|
end
|
data/lib/linker/forms/params.rb
CHANGED
@@ -45,10 +45,13 @@ module Linker
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
elsif param.match(/_list$/)
|
48
|
-
assoc = param.gsub(/_list$/, '')
|
49
|
-
if r = search_has_one(assoc)
|
50
|
-
|
51
|
-
|
48
|
+
assoc = param.to_s.gsub(/_list$/, '')
|
49
|
+
if r = search_has_one(assoc) || r = search_has_and_belongs_to_many(assoc)
|
50
|
+
clean_value = value.is_a?(Array) ? value.reject(&:blank?) : value
|
51
|
+
# fill attr_accessor
|
52
|
+
self.send("#{param}=", clean_value)
|
53
|
+
final = clean_value.present? ? r[:klass].constantize.send(:find, clean_value) : nil
|
54
|
+
_get_main_model.send("#{assoc}=", final) if final.present?
|
52
55
|
end
|
53
56
|
else
|
54
57
|
self.send("#{param}=", value)
|
@@ -97,7 +100,7 @@ module Linker
|
|
97
100
|
private
|
98
101
|
|
99
102
|
def _get_main_model
|
100
|
-
|
103
|
+
@_get_main_model ||= self.send(self.class._main_model.underscore)
|
101
104
|
end
|
102
105
|
|
103
106
|
def search_has_one(name)
|
@@ -105,6 +108,11 @@ module Linker
|
|
105
108
|
s.present? && s
|
106
109
|
end
|
107
110
|
|
111
|
+
def search_has_and_belongs_to_many(name)
|
112
|
+
s = @mapped_habtm_assoc.detect { |c| c[:name] == name }
|
113
|
+
s.present? && s
|
114
|
+
end
|
115
|
+
|
108
116
|
def search_has_many(name)
|
109
117
|
s = @mapped_hm_assoc.detect { |c| c[:name] == name }
|
110
118
|
s.present? && s
|
data/lib/linker/version.rb
CHANGED
data/spec/cars_form_spec.rb
CHANGED
@@ -1,22 +1,50 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CarsForm do
|
4
|
-
let(:cars_form) {
|
4
|
+
let(:cars_form) { described_class.new(Car.new) }
|
5
|
+
let!(:car_part1) { CarPart.create(name: "Part 1") }
|
6
|
+
let!(:car_part2) { CarPart.create(name: "Part 2") }
|
7
|
+
|
8
|
+
it { expect(cars_form.car_parts_list).to eq(nil) }
|
5
9
|
|
6
10
|
context 'after_init callback' do
|
7
11
|
it { expect(cars_form.name).to eq('default car name') }
|
8
12
|
end
|
9
13
|
|
10
|
-
context 'callbacks' do
|
14
|
+
context 'callbacks and habtm _list' do
|
11
15
|
before do
|
12
16
|
cars_form.params = {
|
13
|
-
'name' => "Uno"
|
17
|
+
'name' => "Uno",
|
18
|
+
'car_parts_list' => [1, 2, ""]
|
14
19
|
}
|
15
20
|
cars_form.save
|
16
21
|
end
|
17
22
|
|
18
23
|
it { expect(cars_form.car.name).to eq('Uno 2000') }
|
24
|
+
if Rails.version.start_with?("3")
|
25
|
+
it { expect(cars_form.car.car_parts.map(&:id)).to eq([1,2]) }
|
26
|
+
else
|
27
|
+
it { expect(cars_form.car.car_parts.ids).to eq([1,2]) }
|
28
|
+
end
|
19
29
|
it { expect(cars_form.before_save_checked).to eq(true) }
|
20
30
|
it { expect(cars_form.after_save_checked).to eq(true) }
|
21
31
|
end
|
22
|
-
|
32
|
+
|
33
|
+
context 'validates empty habtm _list' do
|
34
|
+
before do
|
35
|
+
cars_form.params = {
|
36
|
+
'name' => "Uno",
|
37
|
+
'car_parts_list' => [""]
|
38
|
+
}
|
39
|
+
cars_form.save
|
40
|
+
end
|
41
|
+
|
42
|
+
it { expect(cars_form.car.name).to eq('Uno 2000') }
|
43
|
+
if Rails.version.start_with?("3")
|
44
|
+
it { expect(cars_form.car.car_parts.map(&:id)).to eq([]) }
|
45
|
+
else
|
46
|
+
it { expect(cars_form.car.car_parts.ids).to eq([]) }
|
47
|
+
end
|
48
|
+
it { expect(cars_form.errors.messages).to include(:car_parts_list) }
|
49
|
+
end
|
50
|
+
end
|
@@ -10,6 +10,8 @@ class User < ActiveRecord::Base
|
|
10
10
|
has_many :dependent_users, dependent: :destroy
|
11
11
|
has_many :my_tasks, dependent: :destroy, class_name: 'Task'
|
12
12
|
|
13
|
+
has_many :issues, as: :owner
|
14
|
+
|
13
15
|
#has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
|
14
16
|
#validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
|
15
17
|
end
|
@@ -20,6 +22,10 @@ end
|
|
20
22
|
class Pet < ActiveRecord::Base
|
21
23
|
end
|
22
24
|
|
25
|
+
class Issue < ActiveRecord::Base
|
26
|
+
belongs_to :owner, polymorphic: true
|
27
|
+
end
|
28
|
+
|
23
29
|
class Company < ActiveRecord::Base
|
24
30
|
has_many :users
|
25
31
|
end
|
@@ -42,6 +48,10 @@ class Phone < ActiveRecord::Base
|
|
42
48
|
end
|
43
49
|
|
44
50
|
class Car < ActiveRecord::Base
|
51
|
+
has_and_belongs_to_many :car_parts
|
52
|
+
end
|
53
|
+
|
54
|
+
class CarPart < ActiveRecord::Base
|
45
55
|
end
|
46
56
|
|
47
57
|
#migrations
|
@@ -88,7 +98,7 @@ class CreateAllTables < ActiveRecord::Migration
|
|
88
98
|
t.string :district
|
89
99
|
|
90
100
|
t.references :user, index: true
|
91
|
-
|
101
|
+
|
92
102
|
t.timestamps
|
93
103
|
end
|
94
104
|
|
@@ -96,7 +106,7 @@ class CreateAllTables < ActiveRecord::Migration
|
|
96
106
|
t.string :name
|
97
107
|
|
98
108
|
t.references :user, index: true
|
99
|
-
|
109
|
+
|
100
110
|
t.timestamps
|
101
111
|
end
|
102
112
|
|
@@ -120,6 +130,25 @@ class CreateAllTables < ActiveRecord::Migration
|
|
120
130
|
t.timestamps
|
121
131
|
end
|
122
132
|
|
133
|
+
create_table :car_parts do |t|
|
134
|
+
t.string :name
|
135
|
+
|
136
|
+
t.timestamps
|
137
|
+
end
|
138
|
+
|
139
|
+
# join table
|
140
|
+
create_table :car_parts_cars, id: false do |t|
|
141
|
+
t.integer :car_id
|
142
|
+
t.integer :car_part_id
|
143
|
+
end
|
144
|
+
add_index :car_parts_cars, [:car_id, :car_part_id]
|
145
|
+
|
146
|
+
create_table :issues do |t|
|
147
|
+
t.string :name
|
148
|
+
t.integer :owner_id
|
149
|
+
t.string :owner_type
|
150
|
+
end
|
151
|
+
|
123
152
|
end
|
124
153
|
end
|
125
154
|
ActiveRecord::Migration.verbose = false
|
@@ -138,4 +167,4 @@ bar = User.create(name: 'Bar')
|
|
138
167
|
bar.my_tasks << Task.create(name: 'Task 1')
|
139
168
|
bar.little_pet = Pet.create(name: 'Stuart')
|
140
169
|
bar.profile = Profile.first
|
141
|
-
bar.dependent_users << DependentUser.create(name: 'John', date_birth: Date.new(1990, 2, 1))
|
170
|
+
bar.dependent_users << DependentUser.create(name: 'John', date_birth: Date.new(1990, 2, 1))
|
@@ -8,11 +8,13 @@ class CarsForm
|
|
8
8
|
|
9
9
|
validates :name, presence: true
|
10
10
|
|
11
|
+
validates :car_parts_list, presence: true
|
12
|
+
|
11
13
|
def after_init
|
12
14
|
self.name = 'default car name'
|
13
15
|
end
|
14
16
|
|
15
|
-
def before_set_params
|
17
|
+
def before_set_params(params)
|
16
18
|
params['name'] = "#{params['name']} 2000"
|
17
19
|
end
|
18
20
|
|
@@ -23,4 +25,4 @@ class CarsForm
|
|
23
25
|
def after_save
|
24
26
|
@after_save_checked = true
|
25
27
|
end
|
26
|
-
end
|
28
|
+
end
|
data/spec/fake_app/rails_app.rb
CHANGED
@@ -18,6 +18,7 @@ require_relative 'active_record/models'
|
|
18
18
|
require_relative 'forms/dependent_user_form'
|
19
19
|
require_relative 'forms/users_form'
|
20
20
|
require_relative 'forms/cars_form'
|
21
|
+
require_relative 'forms/issue_form'
|
21
22
|
# controllers
|
22
23
|
# class ApplicationController < ActionController::Base; end
|
23
24
|
|
@@ -25,4 +26,4 @@ require_relative 'forms/cars_form'
|
|
25
26
|
# def new
|
26
27
|
# @users_form = UserForm.new(User.new)
|
27
28
|
# end
|
28
|
-
# end
|
29
|
+
# end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe IssueForm do
|
4
|
+
let(:issue_form) { described_class.new(Issue.new) }
|
5
|
+
|
6
|
+
it { expect(described_class._main_model).to eq('Issue') }
|
7
|
+
|
8
|
+
describe "attributes" do
|
9
|
+
subject { issue_form.issue }
|
10
|
+
it { expect(subject).to be_an(Issue) }
|
11
|
+
it { expect(subject.name).to eq(nil) }
|
12
|
+
it { expect(subject.owner_id).to eq(nil) }
|
13
|
+
it { expect(subject.owner_type).to eq(nil) }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "save" do
|
17
|
+
let(:user) { User.create(name: "John") }
|
18
|
+
let(:params) do
|
19
|
+
{
|
20
|
+
name: "Bla",
|
21
|
+
owner_id: user.id,
|
22
|
+
owner_type: user.class.name
|
23
|
+
}
|
24
|
+
end
|
25
|
+
before do
|
26
|
+
issue_form.params = params
|
27
|
+
issue_form.save
|
28
|
+
end
|
29
|
+
|
30
|
+
it { expect(Issue.count).to eq(1) }
|
31
|
+
|
32
|
+
subject { Issue.last }
|
33
|
+
it { expect(subject.name).to eq("Bla") }
|
34
|
+
it { expect(subject.owner_id).to eq(user.id) }
|
35
|
+
it { expect(subject.owner_type).to eq("User") }
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/users_form_spec.rb
CHANGED
@@ -16,7 +16,7 @@ describe UsersForm do
|
|
16
16
|
|
17
17
|
it { expect(users_form).to respond_to(:user) }
|
18
18
|
subject(:user) { users_form.user }
|
19
|
-
it { expect(user).to be_an(User) }
|
19
|
+
it { expect(user).to be_an(User) }
|
20
20
|
|
21
21
|
it { expect(users_form).to respond_to(:params=) }
|
22
22
|
it { expect(users_form).to respond_to(:save) }
|
@@ -75,30 +75,30 @@ describe UsersForm do
|
|
75
75
|
it { expect(family).to be_an(Family) }
|
76
76
|
|
77
77
|
context 'new' do
|
78
|
-
it { expect(user.persisted?).to eq(false) }
|
79
|
-
|
78
|
+
it { expect(user.persisted?).to eq(false) }
|
79
|
+
|
80
80
|
it { expect(users_form.save).to eq(false) }
|
81
81
|
it { expect(users_form).not_to be_valid }
|
82
82
|
it do
|
83
83
|
users_form.save
|
84
|
-
expect(users_form.errors.full_messages).to include("Name can't be blank")
|
84
|
+
expect(users_form.errors.full_messages).to include("Name can't be blank")
|
85
85
|
end
|
86
86
|
|
87
|
-
it { expect(dependent_users_sample.persisted?).to eq(false) }
|
87
|
+
it { expect(dependent_users_sample.persisted?).to eq(false) }
|
88
88
|
|
89
|
-
it { expect(tasks_sample.persisted?).to eq(false) }
|
89
|
+
it { expect(tasks_sample.persisted?).to eq(false) }
|
90
90
|
|
91
|
-
it { expect(address.persisted?).to eq(false) }
|
91
|
+
it { expect(address.persisted?).to eq(false) }
|
92
92
|
|
93
93
|
it { expect(profile_list).to eq(nil) }
|
94
94
|
|
95
95
|
it { expect(my_phone_list).to eq(nil) }
|
96
96
|
|
97
|
-
it { expect(pet.persisted?).to eq(false) }
|
97
|
+
it { expect(pet.persisted?).to eq(false) }
|
98
98
|
|
99
|
-
it { expect(company.persisted?).to eq(false) }
|
99
|
+
it { expect(company.persisted?).to eq(false) }
|
100
100
|
|
101
|
-
it { expect(family.persisted?).to eq(false) }
|
101
|
+
it { expect(family.persisted?).to eq(false) }
|
102
102
|
end
|
103
103
|
|
104
104
|
context 'create' do
|
@@ -129,9 +129,9 @@ describe UsersForm do
|
|
129
129
|
|
130
130
|
it { expect(dependent_users_sample.persisted?).to eq(true) }
|
131
131
|
it { expect(dependent_users_sample.name).to eq('') }
|
132
|
-
|
133
|
-
it { expect(profile_list).to eq(1) }
|
134
|
-
it { expect(my_phone_list).to eq(2) }
|
132
|
+
|
133
|
+
it { expect(profile_list).to eq('1') }
|
134
|
+
it { expect(my_phone_list).to eq('2') }
|
135
135
|
|
136
136
|
it { expect(pet).to be_a(Pet)}
|
137
137
|
it { expect(pet.persisted?).to be(true)}
|
@@ -197,16 +197,16 @@ describe UsersForm do
|
|
197
197
|
|
198
198
|
it { expect(users_form_existing_user_user.persisted?).to eq(true)}
|
199
199
|
it { expect(users_form_existing_user_user.name).to eq('Bar')}
|
200
|
-
|
200
|
+
|
201
201
|
it { expect(users_form_existing_user_company.persisted?).to be(true) }
|
202
202
|
it { expect(users_form_existing_user_company.name).to eq('My Company') }
|
203
203
|
it { expect(users_form_existing_user_company.website).to eq('mycompany.com') }
|
204
204
|
|
205
205
|
it { expect(users_form_existing_user_family.persisted?).to be(true) }
|
206
206
|
it { expect(users_form_existing_user_family.last_name).to eq('Milan') }
|
207
|
-
|
208
|
-
it { expect(users_form_existing_user.profile_list).to
|
209
|
-
it { expect(users_form_existing_user.my_phone_list).to
|
207
|
+
|
208
|
+
it { expect(users_form_existing_user.profile_list).to eq('') }
|
209
|
+
it { expect(users_form_existing_user.my_phone_list).to eq('') }
|
210
210
|
|
211
211
|
it { expect(users_form_existing_user_pet).to be_a(Pet) }
|
212
212
|
it { expect(users_form_existing_user_pet.persisted?).to be(true) }
|
@@ -217,4 +217,4 @@ describe UsersForm do
|
|
217
217
|
it { expect(users_form_existing_user_address.street).to eq('') }
|
218
218
|
it { expect(users_form_existing_user_address.district).to eq('') }
|
219
219
|
end
|
220
|
-
end
|
220
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glauco Custódio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".gitignore"
|
133
133
|
- ".rspec"
|
134
134
|
- ".travis.yml"
|
135
|
+
- CHANGELOG.md
|
135
136
|
- Gemfile
|
136
137
|
- LICENSE
|
137
138
|
- README.md
|
@@ -154,8 +155,10 @@ files:
|
|
154
155
|
- spec/fake_app/config/database.yml
|
155
156
|
- spec/fake_app/forms/cars_form.rb
|
156
157
|
- spec/fake_app/forms/dependent_user_form.rb
|
158
|
+
- spec/fake_app/forms/issue_form.rb
|
157
159
|
- spec/fake_app/forms/users_form.rb
|
158
160
|
- spec/fake_app/rails_app.rb
|
161
|
+
- spec/issue_form_spec.rb
|
159
162
|
- spec/spec_helper.rb
|
160
163
|
- spec/users_form_spec.rb
|
161
164
|
homepage: https://github.com/glaucocustodio/linker
|
@@ -178,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
178
181
|
version: '0'
|
179
182
|
requirements: []
|
180
183
|
rubyforge_project:
|
181
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.6.6
|
182
185
|
signing_key:
|
183
186
|
specification_version: 4
|
184
187
|
summary: A wrapper to form objects in ActiveRecord. Forget accepts_nested_attributes_for.
|
@@ -189,7 +192,10 @@ test_files:
|
|
189
192
|
- spec/fake_app/config/database.yml
|
190
193
|
- spec/fake_app/forms/cars_form.rb
|
191
194
|
- spec/fake_app/forms/dependent_user_form.rb
|
195
|
+
- spec/fake_app/forms/issue_form.rb
|
192
196
|
- spec/fake_app/forms/users_form.rb
|
193
197
|
- spec/fake_app/rails_app.rb
|
198
|
+
- spec/issue_form_spec.rb
|
194
199
|
- spec/spec_helper.rb
|
195
200
|
- spec/users_form_spec.rb
|
201
|
+
has_rdoc:
|