simple_form-polymorphic_associations 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/concerns/simple_form_polymorphic_associations/controller/autocomplete_concern.rb +1 -1
- data/app/concerns/simple_form_polymorphic_associations/model/autocomplete_concern.rb +2 -1
- data/lib/simple_form-polymorphic_associations/spec_helpers/system.rb +39 -0
- data/lib/simple_form-polymorphic_associations/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21eb301ad8e23b16a046addbe1317cd2186e56f3bfe84a55efc776aea4a80a53
|
4
|
+
data.tar.gz: 7dcd29e3e8f196de9b864e7078aa4c5b54c4cb33a84caa8ce25cd85936924bba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ba11da6f2849eb955a1a4c6d4bcc44c32f277af6f0c839462e4f4d5e2436c8089a728c02cc41123b3eeaf3ebddf288a61fd2bd40763ea2bdebcc3aa6e803837
|
7
|
+
data.tar.gz: ff11030145dd42a9708eac2ebe875873c1a50254d8adfd07c009cb0406c2ff30b0ceb28d931f297263ef7d24b30b779085986a2b1a18f9de7f5530096f42f843
|
@@ -4,7 +4,7 @@ module SimpleFormPolymorphicAssociations
|
|
4
4
|
#
|
5
5
|
# # app/controllers/people_controller.rb
|
6
6
|
# class PeopleController < ApplicationController
|
7
|
-
# include SimpleFormPolymorphicAssociations::AutocompleteConcern
|
7
|
+
# include SimpleFormPolymorphicAssociations::Controller::AutocompleteConcern
|
8
8
|
# end
|
9
9
|
#
|
10
10
|
module AutocompleteConcern
|
@@ -4,7 +4,8 @@ module SimpleFormPolymorphicAssociations
|
|
4
4
|
#
|
5
5
|
# # app/models/person.rb
|
6
6
|
# class Person < ActiveRecord::Base
|
7
|
-
# include SimpleFormPolymorphicAssociations::AutocompleteConcern
|
7
|
+
# include SimpleFormPolymorphicAssociations::Model::AutocompleteConcern
|
8
|
+
#
|
8
9
|
# autocomplete scope: ->(matcher) { where("people.firstname LIKE :term", term: "%#{matcher.downcase}%") }, id_method: :id, text_method: :human
|
9
10
|
# end
|
10
11
|
#
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module SimpleFormPolymorphicAssociations
|
2
|
+
module SpecHelpers
|
3
|
+
# Usage:
|
4
|
+
#
|
5
|
+
# # spec/support/simple_form-polymorphic_associations.rb
|
6
|
+
# require "simple_form-polymorphic_associations/spec_helpers/system"
|
7
|
+
#
|
8
|
+
# RSpec.configure do |config|
|
9
|
+
# config.include SimpleFormPolymorphicAssociations::SpecHelpers::System, type: :system
|
10
|
+
# end
|
11
|
+
#
|
12
|
+
module System
|
13
|
+
# Usage:
|
14
|
+
#
|
15
|
+
# # spec/system/projects_spec.rb
|
16
|
+
# require "rails_helper"
|
17
|
+
#
|
18
|
+
# RSpec.describe "Projects", type: :system, js: true do
|
19
|
+
# let(:user) { create(:user) }
|
20
|
+
#
|
21
|
+
# before(:each) { user }
|
22
|
+
#
|
23
|
+
# it do
|
24
|
+
# visit "/projects/new"
|
25
|
+
# polymorphic_select(user, :name, from: "project[owner_id]")
|
26
|
+
# find("input[type='submit']").click
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
def polymorphic_select(record, label_method, options)
|
31
|
+
select record.class.model_name.human, from: options[:from].gsub(/_id]$/, "_type]")
|
32
|
+
first(".select2-container", minimum: 1).click
|
33
|
+
find(".select2-search--dropdown input.select2-search__field").send_keys(user.send(label_method))
|
34
|
+
sleep(1)
|
35
|
+
find(".select2-search--dropdown input.select2-search__field").send_keys(:enter)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form-polymorphic_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- config/initializers/assets.rb
|
43
43
|
- lib/simple_form-polymorphic_associations.rb
|
44
44
|
- lib/simple_form-polymorphic_associations/engine.rb
|
45
|
+
- lib/simple_form-polymorphic_associations/spec_helpers/system.rb
|
45
46
|
- lib/simple_form-polymorphic_associations/version.rb
|
46
47
|
homepage:
|
47
48
|
licenses:
|
@@ -62,8 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
63
|
- !ruby/object:Gem::Version
|
63
64
|
version: '0'
|
64
65
|
requirements: []
|
65
|
-
|
66
|
-
rubygems_version: 2.7.8
|
66
|
+
rubygems_version: 3.4.21
|
67
67
|
signing_key:
|
68
68
|
specification_version: 4
|
69
69
|
summary: Simple Form polymorphic associations.
|