large_text_field 0.3.1 → 1.0.2.pre.1
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 +5 -5
- data/README.md +6 -2
- data/Rakefile +5 -3
- data/db/migrate/20110217210640_add_large_text_fields.rb +3 -2
- data/lib/large_text_field/engine.rb +2 -0
- data/lib/large_text_field/named_text_value.rb +1 -3
- data/lib/large_text_field/owner.rb +10 -6
- data/lib/large_text_field/version.rb +3 -1
- data/lib/large_text_field.rb +1 -2
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/assets/config/manifest.js +1 -0
- data/test/dummy/app/models/library.rb +2 -1
- data/test/dummy/config/application.rb +3 -1
- data/test/dummy/config/boot.rb +4 -2
- data/test/dummy/config/database.yml +13 -1
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/development.rb +2 -3
- data/test/dummy/config/environments/production.rb +2 -0
- data/test/dummy/config/environments/test.rb +2 -3
- data/test/dummy/config.ru +2 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20160217033529_create_libraries.rb +2 -0
- data/test/dummy/db/schema.rb +5 -5
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +39 -0
- data/test/dummy/log/test.log +827 -3763
- data/test/dummy/script/rails +4 -2
- data/test/large_text_field_test.rb +2 -0
- data/test/reports/TEST-LargeTextField-LibraryTest.xml +9 -0
- data/test/reports/TEST-LargeTextField-NamedTextValueTest.xml +15 -0
- data/test/reports/TEST-LargeTextField-OwnerTest.xml +53 -0
- data/test/reports/TEST-LargeTextFieldTest.xml +7 -0
- data/test/test_helper.rb +11 -2
- data/test/unit/dummy/library_test.rb +2 -0
- data/test/unit/large_text_field/name_text_value_test.rb +2 -0
- data/test/unit/large_text_field/owner_test.rb +18 -16
- metadata +35 -30
data/test/dummy/script/rails
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
5
|
|
4
|
-
APP_PATH = File.expand_path('
|
5
|
-
require File.expand_path('
|
6
|
+
APP_PATH = File.expand_path('../config/application', __dir__)
|
7
|
+
require File.expand_path('../config/boot', __dir__)
|
6
8
|
require 'rails/commands'
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites>
|
3
|
+
<testsuite name="LargeTextField::LibraryTest" filepath="/Users/tstarck/invoca/large_text_field/test/unit/dummy/library_test.rb" skipped="0" failures="0" errors="0" tests="2" assertions="2" time="0.00797699997201562">
|
4
|
+
<testcase name="test_: LargeTextField::Library should be able to construct a library. " lineno="7" classname="LargeTextField::LibraryTest" assertions="2" time="0.005172000033780932">
|
5
|
+
</testcase>
|
6
|
+
<testcase name="test_: LargeTextField::Library should be able to dup a class that has no current large text field. " lineno="20" classname="LargeTextField::LibraryTest" assertions="0" time="0.002804999938234687">
|
7
|
+
</testcase>
|
8
|
+
</testsuite>
|
9
|
+
</testsuites>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites>
|
3
|
+
<testsuite name="LargeTextField::NamedTextValueTest" filepath="/Users/tstarck/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/shoulda-context-1.2.2/lib/shoulda/context/context.rb" skipped="0" failures="0" errors="0" tests="5" assertions="9" time="0.06121000007260591">
|
4
|
+
<testcase name="test_: LargeTextField::NamedTextValue should belong to owner. " lineno="346" classname="LargeTextField::NamedTextValueTest" assertions="1" time="0.003751999931409955">
|
5
|
+
</testcase>
|
6
|
+
<testcase name="test_: LargeTextField::NamedTextValue should have field name and value attributes. " lineno="11" classname="LargeTextField::NamedTextValueTest" assertions="6" time="0.0427560000680387">
|
7
|
+
</testcase>
|
8
|
+
<testcase name="test_: LargeTextField::NamedTextValue should use large_text_fields as the table name. " lineno="7" classname="LargeTextField::NamedTextValueTest" assertions="1" time="0.0005510000046342611">
|
9
|
+
</testcase>
|
10
|
+
<testcase name="test_: unique index should allow different owners and field names. " lineno="36" classname="LargeTextField::NamedTextValueTest" assertions="0" time="0.009568999987095594">
|
11
|
+
</testcase>
|
12
|
+
<testcase name="test_: unique index should raise a unique constraint failure on the same owner, and field name. " lineno="27" classname="LargeTextField::NamedTextValueTest" assertions="1" time="0.004582000081427395">
|
13
|
+
</testcase>
|
14
|
+
</testsuite>
|
15
|
+
</testsuites>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites>
|
3
|
+
<testsuite name="LargeTextField::OwnerTest" filepath="/Users/tstarck/invoca/large_text_field/test/unit/large_text_field/owner_test.rb" skipped="0" failures="0" errors="0" tests="24" assertions="99" time="0.18328300002031028">
|
4
|
+
<testcase name="test_: a large text field should allow a custom maximum length to be provided. " lineno="135" classname="LargeTextField::OwnerTest" assertions="3" time="0.013416999951004982">
|
5
|
+
</testcase>
|
6
|
+
<testcase name="test_: a large text field should allow a single argument to be passed into reload. " lineno="301" classname="LargeTextField::OwnerTest" assertions="1" time="0.004912999924272299">
|
7
|
+
</testcase>
|
8
|
+
<testcase name="test_: a large text field should allow for concurrent sets and deletes. " lineno="84" classname="LargeTextField::OwnerTest" assertions="9" time="0.007678000023588538">
|
9
|
+
</testcase>
|
10
|
+
<testcase name="test_: a large text field should allow get and set with saves and deletes. " lineno="61" classname="LargeTextField::OwnerTest" assertions="7" time="0.014948999974876642">
|
11
|
+
</testcase>
|
12
|
+
<testcase name="test_: a large text field should be able to be eager loaded. " lineno="244" classname="LargeTextField::OwnerTest" assertions="3" time="0.01591099996585399">
|
13
|
+
</testcase>
|
14
|
+
<testcase name="test_: a large text field should be able to update deleted fields. " lineno="194" classname="LargeTextField::OwnerTest" assertions="7" time="0.008474000031128526">
|
15
|
+
</testcase>
|
16
|
+
<testcase name="test_: a large text field should be cloned with the rest of the record. " lineno="218" classname="LargeTextField::OwnerTest" assertions="9" time="0.023695999989286065">
|
17
|
+
</testcase>
|
18
|
+
<testcase name="test_: a large text field should declare the association when it is first described and other meta data when it is first defined. " lineno="35" classname="LargeTextField::OwnerTest" assertions="3" time="0.0033099999418482184">
|
19
|
+
</testcase>
|
20
|
+
<testcase name="test_: a large text field should delete fields when they are set to blank. " lineno="173" classname="LargeTextField::OwnerTest" assertions="6" time="0.009033999987877905">
|
21
|
+
</testcase>
|
22
|
+
<testcase name="test_: a large text field should delete large text fields when the owner is destroyed. " lineno="305" classname="LargeTextField::OwnerTest" assertions="4" time="0.006717000040225685">
|
23
|
+
</testcase>
|
24
|
+
<testcase name="test_: a large text field should detect changes when @text_field_hash hash is/not empty. " lineno="268" classname="LargeTextField::OwnerTest" assertions="7" time="0.005818000063300133">
|
25
|
+
</testcase>
|
26
|
+
<testcase name="test_: a large text field should forget about changes if they are not saved. " lineno="109" classname="LargeTextField::OwnerTest" assertions="3" time="0.006125000072643161">
|
27
|
+
</testcase>
|
28
|
+
<testcase name="test_: a large text field should not save fields that are set to blank. " lineno="157" classname="LargeTextField::OwnerTest" assertions="5" time="0.007122000097297132">
|
29
|
+
</testcase>
|
30
|
+
<testcase name="test_: a large text field should only validate_large_text_fields if loaded. " lineno="285" classname="LargeTextField::OwnerTest" assertions="4" time="0.00335600005928427">
|
31
|
+
</testcase>
|
32
|
+
<testcase name="test_: a large text field should prevent a custom maximum length to be provided that is not in the allowable range. " lineno="147" classname="LargeTextField::OwnerTest" assertions="3" time="0.0030239999759942293">
|
33
|
+
</testcase>
|
34
|
+
<testcase name="test_: a large text field should prevent a non-Integer to be provided for a custom maximum. " lineno="141" classname="LargeTextField::OwnerTest" assertions="2" time="0.00317799998447299">
|
35
|
+
</testcase>
|
36
|
+
<testcase name="test_: a large text field should read from a file. " lineno="41" classname="LargeTextField::OwnerTest" assertions="3" time="0.01081999996677041">
|
37
|
+
</testcase>
|
38
|
+
<testcase name="test_: a large text field should reload changes when they come from a different model. " lineno="292" classname="LargeTextField::OwnerTest" assertions="2" time="0.007147000054828823">
|
39
|
+
</testcase>
|
40
|
+
<testcase name="test_: a large text field should singularize the errors if requested. " lineno="129" classname="LargeTextField::OwnerTest" assertions="3" time="0.00828499998897314">
|
41
|
+
</testcase>
|
42
|
+
<testcase name="test_: a large text field should support strings or symbols for get/set methods. " lineno="256" classname="LargeTextField::OwnerTest" assertions="7" time="0.002863000030629337">
|
43
|
+
</testcase>
|
44
|
+
<testcase name="test_: a large text field should validate the maximum length. " lineno="123" classname="LargeTextField::OwnerTest" assertions="3" time="0.007084999931976199">
|
45
|
+
</testcase>
|
46
|
+
<testcase name="test_: updating in large_text_field_save hook should be able to assign empty string. " lineno="9" classname="LargeTextField::OwnerTest" assertions="2" time="0.004567999974824488">
|
47
|
+
</testcase>
|
48
|
+
<testcase name="test_: updating in large_text_field_save hook should be able to assign non empty string. " lineno="9" classname="LargeTextField::OwnerTest" assertions="2" time="0.004910999909043312">
|
49
|
+
</testcase>
|
50
|
+
<testcase name="test_: updating in large_text_field_save hook should raise error on saving nil value. " lineno="19" classname="LargeTextField::OwnerTest" assertions="1" time="0.0008820000803098083">
|
51
|
+
</testcase>
|
52
|
+
</testsuite>
|
53
|
+
</testsuites>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites>
|
3
|
+
<testsuite name="LargeTextFieldTest" filepath="/Users/tstarck/invoca/large_text_field/test/large_text_field_test.rb" skipped="0" failures="0" errors="0" tests="1" assertions="1" time="0.00063699996098876">
|
4
|
+
<testcase name="test_truth" lineno="6" classname="LargeTextFieldTest" assertions="1" time="0.00063699996098876">
|
5
|
+
</testcase>
|
6
|
+
</testsuite>
|
7
|
+
</testsuites>
|
data/test/test_helper.rb
CHANGED
@@ -1,11 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
ENV["RAILS_ENV"] = "test"
|
2
4
|
|
3
|
-
require File.expand_path(
|
5
|
+
require File.expand_path('dummy/config/environment.rb', __dir__)
|
4
6
|
require "rails/test_help"
|
5
|
-
require "invoca/utils"
|
6
7
|
require "rr"
|
7
8
|
require "shoulda"
|
8
9
|
require "minitest/unit"
|
10
|
+
require 'minitest/reporters'
|
11
|
+
|
12
|
+
junit_output_dir = ENV['JUNIT_OUTPUT'].presence || "test/reports"
|
13
|
+
Minitest::Reporters.use! [
|
14
|
+
Minitest::Reporters::DefaultReporter.new,
|
15
|
+
Minitest::Reporters::JUnitReporter.new(junit_output_dir)
|
16
|
+
]
|
17
|
+
|
9
18
|
require "pry"
|
10
19
|
|
11
20
|
def large_description
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_helper'
|
2
4
|
|
3
5
|
module LargeTextField
|
@@ -5,26 +7,22 @@ module LargeTextField
|
|
5
7
|
context "updating in large_text_field_save hook" do
|
6
8
|
{ 'empty string' => '', 'non empty string' => 'this is some text' }.each do |name, value|
|
7
9
|
should "be able to assign #{name}" do
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Library.default_notes = "none_set"
|
15
|
-
end
|
10
|
+
Library.default_notes = value
|
11
|
+
@library = Library.create!(name: "Smithsonian")
|
12
|
+
assert_equal value, @library.notes
|
13
|
+
assert_equal value, @library.reload.notes
|
14
|
+
ensure
|
15
|
+
Library.default_notes = "none_set"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
should "raise error on saving nil value" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
@library = Library.create!(name: "Smithsonian")
|
24
|
-
end
|
25
|
-
ensure
|
26
|
-
Library.default_notes = "none_set"
|
20
|
+
Library.default_notes = :nil
|
21
|
+
assert_raises RuntimeError do
|
22
|
+
@library = Library.create!(name: "Smithsonian")
|
27
23
|
end
|
24
|
+
ensure
|
25
|
+
Library.default_notes = "none_set"
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
@@ -300,7 +298,11 @@ module LargeTextField
|
|
300
298
|
assert_equal "The main research library of the University of Cambridge in England", @library.reload.description
|
301
299
|
end
|
302
300
|
|
303
|
-
should "
|
301
|
+
should "allow a single argument to be passed into reload" do
|
302
|
+
Library.create!(name: "Cambridge University Library", description: "in england").reload(lock: true)
|
303
|
+
end
|
304
|
+
|
305
|
+
should "delete large text fields when the owner is destroyed" do
|
304
306
|
assert_equal 0, LargeTextField::NamedTextValue.count
|
305
307
|
|
306
308
|
@library = Library.create!(name: "Cambridge University Library", description: "in england")
|
metadata
CHANGED
@@ -1,62 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: large_text_field
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- Invoca
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: invoca-utils
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.2'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '7'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
39
42
|
- !ruby/object:Gem::Version
|
40
43
|
version: '4.2'
|
41
|
-
-
|
42
|
-
name: hobo_support
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
44
|
+
- - "<"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.0'
|
46
|
+
version: '7'
|
55
47
|
description: Large text fields are kept in a central table, and polymorphically associated
|
56
|
-
with your models. Access and
|
48
|
+
with your models. Access and assignment should behave as if it was a column on
|
57
49
|
the same table.
|
58
50
|
email:
|
59
|
-
-
|
51
|
+
- development@invoca.com
|
60
52
|
executables: []
|
61
53
|
extensions: []
|
62
54
|
extra_rdoc_files: []
|
@@ -72,6 +64,7 @@ files:
|
|
72
64
|
- lib/large_text_field/version.rb
|
73
65
|
- test/dummy/README.rdoc
|
74
66
|
- test/dummy/Rakefile
|
67
|
+
- test/dummy/app/assets/config/manifest.js
|
75
68
|
- test/dummy/app/models/library.rb
|
76
69
|
- test/dummy/config.ru
|
77
70
|
- test/dummy/config/application.rb
|
@@ -81,14 +74,20 @@ files:
|
|
81
74
|
- test/dummy/config/environments/development.rb
|
82
75
|
- test/dummy/config/environments/production.rb
|
83
76
|
- test/dummy/config/environments/test.rb
|
77
|
+
- test/dummy/db/development.sqlite3
|
84
78
|
- test/dummy/db/migrate/20160217033529_create_libraries.rb
|
85
79
|
- test/dummy/db/schema.rb
|
86
80
|
- test/dummy/db/test.sqlite3
|
81
|
+
- test/dummy/log/development.log
|
87
82
|
- test/dummy/log/test.log
|
88
83
|
- test/dummy/script/rails
|
89
84
|
- test/dummy/test/fixtures/text_field_owners.yml
|
90
85
|
- test/fixtures/large_text_field/named_text_values.yml
|
91
86
|
- test/large_text_field_test.rb
|
87
|
+
- test/reports/TEST-LargeTextField-LibraryTest.xml
|
88
|
+
- test/reports/TEST-LargeTextField-NamedTextValueTest.xml
|
89
|
+
- test/reports/TEST-LargeTextField-OwnerTest.xml
|
90
|
+
- test/reports/TEST-LargeTextFieldTest.xml
|
92
91
|
- test/test_helper.rb
|
93
92
|
- test/unit/dummy/library_test.rb
|
94
93
|
- test/unit/large_text_field/name_text_value_test.rb
|
@@ -97,7 +96,7 @@ homepage: http://github.com/invoca
|
|
97
96
|
licenses: []
|
98
97
|
metadata:
|
99
98
|
allowed_push_host: https://rubygems.org
|
100
|
-
post_install_message:
|
99
|
+
post_install_message:
|
101
100
|
rdoc_options: []
|
102
101
|
require_paths:
|
103
102
|
- lib
|
@@ -108,13 +107,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
107
|
version: '0'
|
109
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
109
|
requirements:
|
111
|
-
- - "
|
110
|
+
- - ">"
|
112
111
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
112
|
+
version: 1.3.1
|
114
113
|
requirements: []
|
115
|
-
|
116
|
-
|
117
|
-
signing_key:
|
114
|
+
rubygems_version: 3.0.1
|
115
|
+
signing_key:
|
118
116
|
specification_version: 4
|
119
117
|
summary: Add large text fields to models without database migrations
|
120
118
|
test_files:
|
@@ -122,6 +120,7 @@ test_files:
|
|
122
120
|
- test/unit/large_text_field/name_text_value_test.rb
|
123
121
|
- test/unit/large_text_field/owner_test.rb
|
124
122
|
- test/dummy/app/models/library.rb
|
123
|
+
- test/dummy/app/assets/config/manifest.js
|
125
124
|
- test/dummy/test/fixtures/text_field_owners.yml
|
126
125
|
- test/dummy/config/environments/production.rb
|
127
126
|
- test/dummy/config/environments/development.rb
|
@@ -136,8 +135,14 @@ test_files:
|
|
136
135
|
- test/dummy/db/schema.rb
|
137
136
|
- test/dummy/db/test.sqlite3
|
138
137
|
- test/dummy/db/migrate/20160217033529_create_libraries.rb
|
138
|
+
- test/dummy/db/development.sqlite3
|
139
139
|
- test/dummy/log/test.log
|
140
|
+
- test/dummy/log/development.log
|
140
141
|
- test/dummy/README.rdoc
|
141
142
|
- test/large_text_field_test.rb
|
142
143
|
- test/fixtures/large_text_field/named_text_values.yml
|
143
144
|
- test/test_helper.rb
|
145
|
+
- test/reports/TEST-LargeTextField-OwnerTest.xml
|
146
|
+
- test/reports/TEST-LargeTextField-NamedTextValueTest.xml
|
147
|
+
- test/reports/TEST-LargeTextField-LibraryTest.xml
|
148
|
+
- test/reports/TEST-LargeTextFieldTest.xml
|