record_collection 1.0.0 → 1.0.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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/record_collection/version.rb +1 -1
  3. metadata +3 -220
  4. data/.gitignore +0 -24
  5. data/.rspec +0 -1
  6. data/.travis.yml +0 -15
  7. data/CHANGELOG.md +0 -88
  8. data/Gemfile +0 -15
  9. data/LICENSE.txt +0 -22
  10. data/app/assets/images/record_collection/.keep +0 -0
  11. data/bin/rails +0 -13
  12. data/gemfiles/Gemfile.rails-4.2.x +0 -10
  13. data/gemfiles/Gemfile.rails-5.0.x +0 -10
  14. data/gemfiles/Gemfile.rails-master +0 -13
  15. data/record_collection.gemspec +0 -50
  16. data/spec/base/accessors_spec.rb +0 -20
  17. data/spec/base/after_record_update_no_arity_spec.rb +0 -15
  18. data/spec/base/after_record_update_spec.rb +0 -22
  19. data/spec/base/before_record_update_no_arity_spec.rb +0 -15
  20. data/spec/base/before_record_update_spec.rb +0 -22
  21. data/spec/base/behaviour_spec.rb +0 -39
  22. data/spec/base/finding_records_spec.rb +0 -98
  23. data/spec/base/inheritance_spec.rb +0 -15
  24. data/spec/base/refine_relation_spec.rb +0 -10
  25. data/spec/base/validations_spec.rb +0 -26
  26. data/spec/dummy/README.rdoc +0 -28
  27. data/spec/dummy/Rakefile +0 -6
  28. data/spec/dummy/app/assets/config/manifest.js +0 -3
  29. data/spec/dummy/app/assets/images/.keep +0 -0
  30. data/spec/dummy/app/assets/javascripts/application.js.coffee +0 -23
  31. data/spec/dummy/app/assets/javascripts/foundation.min.js +0 -6081
  32. data/spec/dummy/app/assets/javascripts/modernizr.js +0 -8
  33. data/spec/dummy/app/assets/stylesheets/application.sass +0 -3
  34. data/spec/dummy/app/assets/stylesheets/components/_forms.sass +0 -4
  35. data/spec/dummy/app/assets/stylesheets/components/_structure.sass +0 -9
  36. data/spec/dummy/app/assets/stylesheets/foundation.css +0 -6201
  37. data/spec/dummy/app/assets/stylesheets/normalize.css +0 -427
  38. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  39. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  40. data/spec/dummy/app/controllers/dashboard_controller.rb +0 -4
  41. data/spec/dummy/app/controllers/employees_controller.rb +0 -73
  42. data/spec/dummy/app/controllers/projects_controller.rb +0 -73
  43. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  44. data/spec/dummy/app/mailers/.keep +0 -0
  45. data/spec/dummy/app/models/.keep +0 -0
  46. data/spec/dummy/app/models/concerns/.keep +0 -0
  47. data/spec/dummy/app/models/employee/collection.rb +0 -6
  48. data/spec/dummy/app/models/employee.rb +0 -3
  49. data/spec/dummy/app/models/project/collection.rb +0 -6
  50. data/spec/dummy/app/models/project.rb +0 -3
  51. data/spec/dummy/app/views/application/_form_errors.html.slim +0 -8
  52. data/spec/dummy/app/views/dashboard/home.html.slim +0 -1
  53. data/spec/dummy/app/views/employees/_form.html.erb +0 -25
  54. data/spec/dummy/app/views/employees/collection_edit.html.slim +0 -11
  55. data/spec/dummy/app/views/employees/edit.html.erb +0 -6
  56. data/spec/dummy/app/views/employees/index.html.slim +0 -28
  57. data/spec/dummy/app/views/employees/new.html.erb +0 -5
  58. data/spec/dummy/app/views/employees/show.html.erb +0 -14
  59. data/spec/dummy/app/views/layouts/application.html.slim +0 -30
  60. data/spec/dummy/app/views/projects/_form.html.erb +0 -21
  61. data/spec/dummy/app/views/projects/collection_edit.html.slim +0 -11
  62. data/spec/dummy/app/views/projects/edit.html.erb +0 -6
  63. data/spec/dummy/app/views/projects/index.html.slim +0 -20
  64. data/spec/dummy/app/views/projects/new.html.erb +0 -5
  65. data/spec/dummy/app/views/projects/show.html.erb +0 -14
  66. data/spec/dummy/bin/bundle +0 -3
  67. data/spec/dummy/bin/rails +0 -4
  68. data/spec/dummy/bin/rake +0 -4
  69. data/spec/dummy/bin/setup +0 -29
  70. data/spec/dummy/config/application.rb +0 -26
  71. data/spec/dummy/config/boot.rb +0 -5
  72. data/spec/dummy/config/database.yml +0 -25
  73. data/spec/dummy/config/environment.rb +0 -5
  74. data/spec/dummy/config/environments/development.rb +0 -41
  75. data/spec/dummy/config/environments/production.rb +0 -79
  76. data/spec/dummy/config/environments/test.rb +0 -48
  77. data/spec/dummy/config/initializers/assets.rb +0 -11
  78. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  79. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  80. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  81. data/spec/dummy/config/initializers/inflections.rb +0 -16
  82. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  83. data/spec/dummy/config/initializers/session_store.rb +0 -3
  84. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  85. data/spec/dummy/config/locales/record_collection.en.yml +0 -28
  86. data/spec/dummy/config/routes.rb +0 -5
  87. data/spec/dummy/config/secrets.yml +0 -22
  88. data/spec/dummy/config.ru +0 -4
  89. data/spec/dummy/db/migrate/20150203124634_create_employees.rb +0 -10
  90. data/spec/dummy/db/migrate/20150204103712_add_vegan_to_employees.rb +0 -5
  91. data/spec/dummy/db/migrate/20150204103925_add_admin_to_employees.rb +0 -5
  92. data/spec/dummy/db/migrate/20150204125014_create_projects.rb +0 -11
  93. data/spec/dummy/db/migrate/20150721122805_add_description_to_projects.rb +0 -5
  94. data/spec/dummy/db/migrate/20151215123553_add_project_id_to_employees.rb +0 -5
  95. data/spec/dummy/db/migrate/20151225113902_add_start_date_to_projects.rb +0 -5
  96. data/spec/dummy/db/migrate/20151226083300_add_hint_visible_to_projects.rb +0 -5
  97. data/spec/dummy/db/schema.rb +0 -37
  98. data/spec/dummy/lib/assets/.keep +0 -0
  99. data/spec/dummy/log/.keep +0 -0
  100. data/spec/dummy/public/404.html +0 -67
  101. data/spec/dummy/public/422.html +0 -67
  102. data/spec/dummy/public/500.html +0 -66
  103. data/spec/dummy/public/favicon.ico +0 -0
  104. data/spec/features/disabled_boolean_spec.rb +0 -19
  105. data/spec/features/multi_select_spec.rb +0 -24
  106. data/spec/features/optional_boolean_hint_and_append_text_spec.rb +0 -12
  107. data/spec/features/optional_boolean_with_normal_resource_spec.rb +0 -20
  108. data/spec/features/optional_date_field_all_nil_spec.rb +0 -10
  109. data/spec/features/optional_text_field_with_normal_resource_spec.rb +0 -16
  110. data/spec/features/optionals_with_one_record_spec.rb +0 -16
  111. data/spec/features/translations_spec.rb +0 -9
  112. data/spec/fixtures/collections.rb +0 -0
  113. data/spec/rails/form_builder_spec.rb +0 -113
  114. data/spec/rails/form_for_spec.rb +0 -58
  115. data/spec/record_selection/base_spec.rb +0 -157
  116. data/spec/record_selection/name_spec.rb +0 -10
  117. data/spec/spec_helper.rb +0 -32
@@ -1,157 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class ActiveCollectionTest < RecordCollection::Base
4
- attribute :check1, type: Boolean
5
- attribute :check2, type: Boolean
6
- attribute :notes
7
- self.record_class = Project
8
- end
9
-
10
- RSpec.describe RecordCollection::Base do
11
- subject { described_class.new }
12
-
13
- describe '#one?' do
14
- it 'is false without a collection' do
15
- subject.one?.should be false
16
- end
17
-
18
- it 'is true with exactly one record' do
19
- described_class.new([Object.new]).should be_one
20
- end
21
-
22
- it 'is false with more than one records' do
23
- described_class.new([Object.new, Object.new]).should_not be_one
24
- end
25
- end
26
-
27
- describe '#first and #last' do
28
- it 'returns the first and last object of the collection' do
29
- o1 = Object.new
30
- o2 = Object.new
31
- described_class.new([o1, o2]).first.should be o1
32
- described_class.new([o1, o2]).last.should be o2
33
- end
34
- end
35
-
36
- describe 'form representation' do
37
- it 'has prefix collection for all types in forms' do
38
- ActiveCollectionTest.model_name.param_key.should eq 'collection'
39
- end
40
- end
41
-
42
- describe '.record_class' do
43
- it 'Returns the base class inferred based on namespace' do
44
- Employee::Collection.record_class.should eq Employee
45
- end
46
-
47
- it 'returns a specified class when explicitly set on class level' do
48
- ActiveCollectionTest.record_class.should eq Project
49
- end
50
- end
51
-
52
- describe '#update_collection_attributes!' do
53
- it 'Changes only attributes given by params of the collection and defined in the collection' do
54
- record = Employee.new(name: 'Ben', section: 'ABC', admin: true, vegan: false)
55
- collection = Employee::Collection.new([record], name: 'Harry', section: '', vegan: true)
56
- collection.update_collection_attributes!
57
- record.name.should eq "Ben" # not a collection attribute
58
- record.section.should eq "" # Blank strings are set, only nil values not
59
- record.admin.should be true # not given as argument to collection
60
- record.vegan.should be true # this one should be changed
61
- end
62
- end
63
-
64
- describe '#mixed_values_for_attribute?' do
65
- context "TestCollection" do
66
- let(:collection_class){ ActiveCollectionTest }
67
- describe 'boolean attribute' do
68
- let(:record) { Struct.new(:check1) }
69
-
70
- it 'returns true for mixed falsy boolean values' do
71
- expect( collection_class.new([record.new, record.new(false)]).mixed_values_for_attribute?(:check1)).to be true
72
- end
73
-
74
- it 'returns false for all truthy values' do
75
- expect( collection_class.new([record.new(true), record.new(true)]).mixed_values_for_attribute?(:check1)).to be false
76
- end
77
- end
78
-
79
- describe 'untyped attribute' do
80
- let(:record) { Struct.new(:notes) }
81
- it 'returns true for mixed values truthy and falsy' do
82
- collection = collection_class.new([record.new, record.new('NOTE2')])
83
- expect( collection.mixed_values_for_attribute? :notes ).to be true
84
- end
85
-
86
- it 'returns true for mixed truthy values' do
87
- collection = collection_class.new([record.new('NOTE1'), record.new('NOTE2')])
88
- expect( collection.mixed_values_for_attribute? :notes ).to be true
89
- end
90
-
91
- it 'returns the value for all the same values, and sets the value if set_if_nil is given' do
92
- collection = collection_class.new([record.new('NOTE2'), record.new('NOTE2')])
93
- expect( collection.mixed_values_for_attribute? :notes, set_if_nil: true ).to be false
94
- expect( collection.notes ).to eq 'NOTE2'
95
- end
96
-
97
- it "does not set value if there are mixed values" do
98
- collection = collection_class.new([record.new('NOTE1'), record.new('NOTE2')])
99
- expect( collection.mixed_values_for_attribute? :notes, set_if_nil: true ).to be true
100
- collection.notes.should be_nil
101
- end
102
- end
103
- end
104
- end
105
-
106
- describe '#uniform_collection_value' do
107
- context "TestCollection" do
108
- let(:collection_class){ ActiveCollectionTest }
109
- describe 'boolean attribute' do
110
- let(:record) { Struct.new(:check1) }
111
-
112
- it 'returns false for mixed falsy boolean values' do
113
- expect( collection_class.new([record.new, record.new(false)]).uniform_collection_value(:check1)).to be false
114
- end
115
-
116
- it 'returns nil for mixes boolean values' do
117
- expect( collection_class.new([record.new, record.new(true)]).uniform_collection_value(:check1)).to be nil
118
- end
119
-
120
- it 'returns true for all truthy values' do
121
- expect( collection_class.new([record.new(true), record.new(true)]).uniform_collection_value(:check1)).to be true
122
- end
123
- end
124
-
125
- describe 'untyped attribute' do
126
- let(:record) { Struct.new(:notes) }
127
- it 'returns nil for mixed values truthy and falsy' do
128
- collection = collection_class.new([record.new, record.new('NOTE2')])
129
- expect( collection.uniform_collection_value :notes ).to be nil
130
- end
131
-
132
- it 'returns nil for mixed truthy values' do
133
- collection = collection_class.new([record.new('NOTE1'), record.new('NOTE2')])
134
- expect( collection.uniform_collection_value :notes ).to be nil
135
- end
136
-
137
- it 'returns the value for all the same values, but does not set the value' do
138
- collection = collection_class.new([record.new('NOTE2'), record.new('NOTE2')])
139
- expect( collection.uniform_collection_value :notes ).to eq 'NOTE2'
140
- expect( collection.notes ).to be nil
141
- end
142
-
143
- it 'returns the value for all the same values, and sets the value if set_if_nil is given' do
144
- collection = collection_class.new([record.new('NOTE2'), record.new('NOTE2')])
145
- expect( collection.uniform_collection_value :notes, set_if_nil: true ).to eq 'NOTE2'
146
- expect( collection.notes ).to eq 'NOTE2'
147
- end
148
-
149
- it 'returns the value for all the same values, and does not set the value if set_if_nil is given, but already set (eg: by invalid form)' do
150
- collection = collection_class.new([record.new('NOTE2'), record.new('NOTE2')], notes: 'Invalid set form value')
151
- expect( collection.uniform_collection_value :notes, set_if_nil: true ).to eq 'NOTE2'
152
- expect( collection.notes ).to eq 'Invalid set form value'
153
- end
154
- end
155
- end
156
- end
157
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RecordCollection::Name do
4
- let(:employee){ Employee.create section: 'SE1' }
5
- subject{ Employee::Collection.new([employee]).model_name }
6
-
7
- its(:singular_route_key){ should eq 'employee' }
8
- its(:route_key){ should eq 'employees' }
9
- its(:human){ should eq 'Employees collection' }
10
- end
data/spec/spec_helper.rb DELETED
@@ -1,32 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- #require 'simplecov'
3
- #SimpleCov.start
4
-
5
- require 'pry'
6
- require File.expand_path("../../spec/dummy/config/environment.rb", __FILE__)
7
- ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../spec/dummy/db/migrate", __FILE__)]
8
-
9
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
10
-
11
- require 'rspec/rails'
12
- require 'record_collection'
13
- require 'database_cleaner'
14
- require 'capybara/rails'
15
- require 'capybara/rspec'
16
- #require 'capybara/poltergeist'
17
-
18
- Capybara.javascript_driver = :selenium
19
- DatabaseCleaner.clean_with :truncation
20
- RSpec.configure do |config|
21
- config.mock_with :rspec
22
- config.include Dummy::Application.routes.url_helpers, type: :feature
23
- config.include RSpecHtmlMatchers
24
-
25
- config.before :each do
26
- Employee.delete_all
27
- end
28
-
29
- config.expect_with :rspec do |c|
30
- c.syntax = [:should, :expect]
31
- end
32
- end