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.
- checksums.yaml +4 -4
- data/lib/record_collection/version.rb +1 -1
- metadata +3 -220
- data/.gitignore +0 -24
- data/.rspec +0 -1
- data/.travis.yml +0 -15
- data/CHANGELOG.md +0 -88
- data/Gemfile +0 -15
- data/LICENSE.txt +0 -22
- data/app/assets/images/record_collection/.keep +0 -0
- data/bin/rails +0 -13
- data/gemfiles/Gemfile.rails-4.2.x +0 -10
- data/gemfiles/Gemfile.rails-5.0.x +0 -10
- data/gemfiles/Gemfile.rails-master +0 -13
- data/record_collection.gemspec +0 -50
- data/spec/base/accessors_spec.rb +0 -20
- data/spec/base/after_record_update_no_arity_spec.rb +0 -15
- data/spec/base/after_record_update_spec.rb +0 -22
- data/spec/base/before_record_update_no_arity_spec.rb +0 -15
- data/spec/base/before_record_update_spec.rb +0 -22
- data/spec/base/behaviour_spec.rb +0 -39
- data/spec/base/finding_records_spec.rb +0 -98
- data/spec/base/inheritance_spec.rb +0 -15
- data/spec/base/refine_relation_spec.rb +0 -10
- data/spec/base/validations_spec.rb +0 -26
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/config/manifest.js +0 -3
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js.coffee +0 -23
- data/spec/dummy/app/assets/javascripts/foundation.min.js +0 -6081
- data/spec/dummy/app/assets/javascripts/modernizr.js +0 -8
- data/spec/dummy/app/assets/stylesheets/application.sass +0 -3
- data/spec/dummy/app/assets/stylesheets/components/_forms.sass +0 -4
- data/spec/dummy/app/assets/stylesheets/components/_structure.sass +0 -9
- data/spec/dummy/app/assets/stylesheets/foundation.css +0 -6201
- data/spec/dummy/app/assets/stylesheets/normalize.css +0 -427
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/controllers/dashboard_controller.rb +0 -4
- data/spec/dummy/app/controllers/employees_controller.rb +0 -73
- data/spec/dummy/app/controllers/projects_controller.rb +0 -73
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/models/employee/collection.rb +0 -6
- data/spec/dummy/app/models/employee.rb +0 -3
- data/spec/dummy/app/models/project/collection.rb +0 -6
- data/spec/dummy/app/models/project.rb +0 -3
- data/spec/dummy/app/views/application/_form_errors.html.slim +0 -8
- data/spec/dummy/app/views/dashboard/home.html.slim +0 -1
- data/spec/dummy/app/views/employees/_form.html.erb +0 -25
- data/spec/dummy/app/views/employees/collection_edit.html.slim +0 -11
- data/spec/dummy/app/views/employees/edit.html.erb +0 -6
- data/spec/dummy/app/views/employees/index.html.slim +0 -28
- data/spec/dummy/app/views/employees/new.html.erb +0 -5
- data/spec/dummy/app/views/employees/show.html.erb +0 -14
- data/spec/dummy/app/views/layouts/application.html.slim +0 -30
- data/spec/dummy/app/views/projects/_form.html.erb +0 -21
- data/spec/dummy/app/views/projects/collection_edit.html.slim +0 -11
- data/spec/dummy/app/views/projects/edit.html.erb +0 -6
- data/spec/dummy/app/views/projects/index.html.slim +0 -20
- data/spec/dummy/app/views/projects/new.html.erb +0 -5
- data/spec/dummy/app/views/projects/show.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config/application.rb +0 -26
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -48
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/record_collection.en.yml +0 -28
- data/spec/dummy/config/routes.rb +0 -5
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/20150203124634_create_employees.rb +0 -10
- data/spec/dummy/db/migrate/20150204103712_add_vegan_to_employees.rb +0 -5
- data/spec/dummy/db/migrate/20150204103925_add_admin_to_employees.rb +0 -5
- data/spec/dummy/db/migrate/20150204125014_create_projects.rb +0 -11
- data/spec/dummy/db/migrate/20150721122805_add_description_to_projects.rb +0 -5
- data/spec/dummy/db/migrate/20151215123553_add_project_id_to_employees.rb +0 -5
- data/spec/dummy/db/migrate/20151225113902_add_start_date_to_projects.rb +0 -5
- data/spec/dummy/db/migrate/20151226083300_add_hint_visible_to_projects.rb +0 -5
- data/spec/dummy/db/schema.rb +0 -37
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/features/disabled_boolean_spec.rb +0 -19
- data/spec/features/multi_select_spec.rb +0 -24
- data/spec/features/optional_boolean_hint_and_append_text_spec.rb +0 -12
- data/spec/features/optional_boolean_with_normal_resource_spec.rb +0 -20
- data/spec/features/optional_date_field_all_nil_spec.rb +0 -10
- data/spec/features/optional_text_field_with_normal_resource_spec.rb +0 -16
- data/spec/features/optionals_with_one_record_spec.rb +0 -16
- data/spec/features/translations_spec.rb +0 -9
- data/spec/fixtures/collections.rb +0 -0
- data/spec/rails/form_builder_spec.rb +0 -113
- data/spec/rails/form_for_spec.rb +0 -58
- data/spec/record_selection/base_spec.rb +0 -157
- data/spec/record_selection/name_spec.rb +0 -10
- data/spec/spec_helper.rb +0 -32
data/spec/dummy/db/schema.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# This file is auto-generated from the current state of the database. Instead
|
3
|
-
# of editing this file, please use the migrations feature of Active Record to
|
4
|
-
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
-
#
|
6
|
-
# Note that this schema.rb definition is the authoritative source for your
|
7
|
-
# database schema. If you need to create the application database on another
|
8
|
-
# system, you should be using db:schema:load, not running all the migrations
|
9
|
-
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
-
#
|
12
|
-
# It's strongly recommended that you check this file into your version control system.
|
13
|
-
|
14
|
-
ActiveRecord::Schema.define(version: 20151226083300) do
|
15
|
-
|
16
|
-
create_table "employees", force: :cascade do |t|
|
17
|
-
t.string "name"
|
18
|
-
t.string "section"
|
19
|
-
t.datetime "created_at", null: false
|
20
|
-
t.datetime "updated_at", null: false
|
21
|
-
t.boolean "vegan", default: true
|
22
|
-
t.boolean "admin", default: false
|
23
|
-
t.integer "project_id"
|
24
|
-
end
|
25
|
-
|
26
|
-
create_table "projects", force: :cascade do |t|
|
27
|
-
t.string "name"
|
28
|
-
t.boolean "finished"
|
29
|
-
t.string "state"
|
30
|
-
t.datetime "created_at", null: false
|
31
|
-
t.datetime "updated_at", null: false
|
32
|
-
t.text "description"
|
33
|
-
t.date "start_date"
|
34
|
-
t.boolean "hint_visible", default: false, null: false
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/spec/dummy/lib/assets/.keep
DELETED
File without changes
|
data/spec/dummy/log/.keep
DELETED
File without changes
|
data/spec/dummy/public/404.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/404.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
-
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/422.html
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/422.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>The change you wanted was rejected.</h1>
|
62
|
-
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
-
</div>
|
64
|
-
<p>If you are the application owner check the logs for more information.</p>
|
65
|
-
</div>
|
66
|
-
</body>
|
67
|
-
</html>
|
data/spec/dummy/public/500.html
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>We're sorry, but something went wrong (500)</title>
|
5
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
-
<style>
|
7
|
-
body {
|
8
|
-
background-color: #EFEFEF;
|
9
|
-
color: #2E2F30;
|
10
|
-
text-align: center;
|
11
|
-
font-family: arial, sans-serif;
|
12
|
-
margin: 0;
|
13
|
-
}
|
14
|
-
|
15
|
-
div.dialog {
|
16
|
-
width: 95%;
|
17
|
-
max-width: 33em;
|
18
|
-
margin: 4em auto 0;
|
19
|
-
}
|
20
|
-
|
21
|
-
div.dialog > div {
|
22
|
-
border: 1px solid #CCC;
|
23
|
-
border-right-color: #999;
|
24
|
-
border-left-color: #999;
|
25
|
-
border-bottom-color: #BBB;
|
26
|
-
border-top: #B00100 solid 4px;
|
27
|
-
border-top-left-radius: 9px;
|
28
|
-
border-top-right-radius: 9px;
|
29
|
-
background-color: white;
|
30
|
-
padding: 7px 12% 0;
|
31
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
-
}
|
33
|
-
|
34
|
-
h1 {
|
35
|
-
font-size: 100%;
|
36
|
-
color: #730E15;
|
37
|
-
line-height: 1.5em;
|
38
|
-
}
|
39
|
-
|
40
|
-
div.dialog > p {
|
41
|
-
margin: 0 0 1em;
|
42
|
-
padding: 1em;
|
43
|
-
background-color: #F7F7F7;
|
44
|
-
border: 1px solid #CCC;
|
45
|
-
border-right-color: #999;
|
46
|
-
border-left-color: #999;
|
47
|
-
border-bottom-color: #999;
|
48
|
-
border-bottom-left-radius: 4px;
|
49
|
-
border-bottom-right-radius: 4px;
|
50
|
-
border-top-color: #DADADA;
|
51
|
-
color: #666;
|
52
|
-
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
-
}
|
54
|
-
</style>
|
55
|
-
</head>
|
56
|
-
|
57
|
-
<body>
|
58
|
-
<!-- This file lives in public/500.html -->
|
59
|
-
<div class="dialog">
|
60
|
-
<div>
|
61
|
-
<h1>We're sorry, but something went wrong.</h1>
|
62
|
-
</div>
|
63
|
-
<p>If you are the application owner check the logs for more information.</p>
|
64
|
-
</div>
|
65
|
-
</body>
|
66
|
-
</html>
|
File without changes
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Disabled booleans", type: :feature do
|
4
|
-
scenario "Selecting all", js: true do
|
5
|
-
project = Project.create name: 'P1', finished: true
|
6
|
-
visit collection_edit_projects_path(ids: [project.id])
|
7
|
-
|
8
|
-
toggle = find('.optional-attribute-container.finished .optional-boolean-toggle')
|
9
|
-
toggle['class'].should include 'active'
|
10
|
-
toggle.click
|
11
|
-
find('[name="commit"]').click
|
12
|
-
|
13
|
-
project.reload
|
14
|
-
|
15
|
-
# Should not be changed by the click
|
16
|
-
project.finished.should be true
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Multi select", type: :feature do
|
4
|
-
scenario "Selecting all", js: true do
|
5
|
-
Employee.create name: 'E1', section: 'ABC', admin: true, vegan: false
|
6
|
-
Employee.create name: 'E2', section: 'QNP', admin: false, vegan: false
|
7
|
-
visit employees_path
|
8
|
-
find('.selection-toggle-all').click
|
9
|
-
find('.actions-button').click
|
10
|
-
|
11
|
-
page.should have_selector ".optional-input-activator-container.section.inactive"
|
12
|
-
page.should_not have_selector ".optional-attribute-container.section" # hidden
|
13
|
-
page.should have_selector ".optional-attribute-container.admin.inactive"
|
14
|
-
page.should have_selector ".optional-attribute-container.vegan.active"
|
15
|
-
|
16
|
-
# Activate admin, and see that they all become false
|
17
|
-
find('.admin .optional-boolean-activator-toggle').click
|
18
|
-
find('[name="commit"]').click
|
19
|
-
|
20
|
-
Employee.pluck(:admin).should be_none
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Hint with optional boolean", type: :feature do
|
4
|
-
scenario "Seeing the hint", js: true do
|
5
|
-
project = Project.create name: 'P1', finished: true
|
6
|
-
visit collection_edit_projects_path(ids: [project.id])
|
7
|
-
|
8
|
-
page.should have_selector '.optional-attribute-container.hint_visible .optional-attribute-hint'
|
9
|
-
page.should have_selector '.optional-attribute-container.hint_visible .optional-attribute-append'
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Optional text_field with normal record", type: :feature do
|
4
|
-
scenario "Selecting all", js: true do
|
5
|
-
employee = Employee.create name: 'E1', admin: true, vegan: false
|
6
|
-
visit collection_edit_employees_path(ids: [employee.id])
|
7
|
-
|
8
|
-
find('#collection_section').set 'SEC' # this is an optional
|
9
|
-
toggle = find('.optional-attribute-container.vegan .optional-boolean-toggle')
|
10
|
-
toggle.click
|
11
|
-
find('[name="commit"]').click
|
12
|
-
|
13
|
-
employee.reload
|
14
|
-
|
15
|
-
employee.section.should == 'SEC'
|
16
|
-
employee.admin.should be true
|
17
|
-
employee.vegan.should be true
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Optional date field with multiple default nil values", type: :feature do
|
4
|
-
scenario "Immediately setting the date when none of the collection is set", js: true do
|
5
|
-
project_1 = Project.create name: "P1", start_date: nil
|
6
|
-
project_2 = Project.create name: "P2", start_date: nil
|
7
|
-
visit collection_edit_projects_path(ids: "#{project_1.id}~#{project_2.id}")
|
8
|
-
page.should have_selector '.collection_start_date'
|
9
|
-
end
|
10
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Optional text_field with normal record", type: :feature do
|
4
|
-
scenario "Selecting all", js: true do
|
5
|
-
employee = Employee.create name: 'E1', admin: true, vegan: false
|
6
|
-
visit edit_employee_path(employee.id)
|
7
|
-
|
8
|
-
find('#employee_section').set 'SEC' # this is an optional
|
9
|
-
find('[name="commit"]').click
|
10
|
-
|
11
|
-
employee.reload
|
12
|
-
|
13
|
-
employee.section.should == 'SEC'
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Optionals with one record", type: :feature do
|
4
|
-
scenario "Selecting all", js: true do
|
5
|
-
employee = Employee.create name: 'E1', admin: true, vegan: false
|
6
|
-
visit collection_edit_employees_path(ids: [employee.id])
|
7
|
-
|
8
|
-
find('#collection_section').set 'SEC'
|
9
|
-
find('[name="commit"]').click
|
10
|
-
|
11
|
-
employee.reload
|
12
|
-
|
13
|
-
employee.section.should == 'SEC'
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.feature "Multi select", type: :feature do
|
4
|
-
scenario "Selecting all", js: true do
|
5
|
-
employee = Employee.create name: 'E1', section: 'ABC', admin: true, vegan: false
|
6
|
-
visit collection_edit_employees_path(ids: [employee.id])
|
7
|
-
find('[name="commit"]').value.should eq "Update Employees collection"
|
8
|
-
end
|
9
|
-
end
|
File without changes
|
@@ -1,113 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe ActionView::Helpers::FormBuilder do
|
4
|
-
let(:employee_1){ Employee.create section: 'SE1' }
|
5
|
-
let(:employee_2){ Employee.create section: 'SE1' }
|
6
|
-
let(:collection_class) { Employee::Collection }
|
7
|
-
let(:arguments){ {form_object: collection_class.new([employee_1, employee_2])} }
|
8
|
-
subject{ described_class.new :collection, arguments[:form_object], @template, {}}
|
9
|
-
before do
|
10
|
-
# http://pivotallabs.com/testing-custom-form-builder/
|
11
|
-
@template = Object.new
|
12
|
-
@template.extend ActionView::Helpers::FormTagHelper
|
13
|
-
@template.extend ActionView::Helpers::FormOptionsHelper
|
14
|
-
@template.extend ActionView::Helpers::FormHelper
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.collection_ids' do
|
18
|
-
it 'returns the collection ids as hidden fields' do
|
19
|
-
#subject.collection_ids.should eq %|<input type="hidden" name="ids" value="#{employee_1.id}~#{employee_2.id}" />|
|
20
|
-
subject.collection_ids.should have_tag :input, with: {
|
21
|
-
type: 'hidden',
|
22
|
-
name: 'ids',
|
23
|
-
value: "#{employee_1.id}~#{employee_2.id}"
|
24
|
-
}
|
25
|
-
end
|
26
|
-
|
27
|
-
it "does not raise when the object is not a collection object" do
|
28
|
-
arguments[:form_object] = employee_1
|
29
|
-
expect{ subject.collection_ids }.not_to raise_error
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#optional_input simple_form support' do
|
34
|
-
it "generates proper output" do
|
35
|
-
expect( subject ).to receive(:input).and_return "<simple-form-content>Simple Form Content</simple-form-content>".html_safe
|
36
|
-
html = subject.optional_input(:section)
|
37
|
-
|
38
|
-
html.should have_tag :input, with: {name: 'ids', value: "#{employee_1.id}~#{employee_2.id}"}
|
39
|
-
html.should have_tag :div, with: {
|
40
|
-
class: 'optional-input optional-attribute-container section active',
|
41
|
-
'data-attribute' => 'section',
|
42
|
-
'data-one' => false
|
43
|
-
}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#get_optional_classes' do
|
48
|
-
|
49
|
-
describe 'active/inactive' do
|
50
|
-
it "does not include active when one record has no value and the other one has" do
|
51
|
-
employee_1.section = nil
|
52
|
-
subject.get_optional_classes(:section).should_not include'active'
|
53
|
-
subject.get_optional_classes(:section).should include'inactive'
|
54
|
-
end
|
55
|
-
|
56
|
-
it "includes active when collection has an empty value" do
|
57
|
-
subject.object.section = ''
|
58
|
-
subject.get_optional_classes(:section).should include'active'
|
59
|
-
subject.get_optional_classes(:section).should_not include'inactive'
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'includes active when two records have the same value' do
|
63
|
-
subject.get_optional_classes(:section).should include'active'
|
64
|
-
subject.get_optional_classes(:section).should_not include'inactive'
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'does not include active when two records have different values' do
|
68
|
-
employee_2.section = 'SE2' # = Employee.create section: 'SE2'
|
69
|
-
subject.get_optional_classes(:section).should_not include'active'
|
70
|
-
subject.get_optional_classes(:section).should include'inactive'
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe 'one' do
|
75
|
-
it "includes one if only one record is present" do
|
76
|
-
arguments[:form_object] = collection_class.new([employee_1])
|
77
|
-
subject.get_optional_classes(:section).should include'one'
|
78
|
-
end
|
79
|
-
|
80
|
-
it "includes one if the form record is not a collection but a normal record" do
|
81
|
-
arguments[:form_object] = employee_1
|
82
|
-
subject.get_optional_classes(:section).should include'one'
|
83
|
-
end
|
84
|
-
|
85
|
-
it "does not include one for a collection having more than one records" do
|
86
|
-
subject.get_optional_classes(:section).should_not include'one'
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe 'error' do
|
91
|
-
it "has no error class without any arguments set" do
|
92
|
-
subject.get_optional_classes(:section).should_not include'error'
|
93
|
-
end
|
94
|
-
|
95
|
-
it "has no error class with valid argument set" do
|
96
|
-
arguments[:form_object].update(section: 'Se9').should be_truthy
|
97
|
-
subject.get_optional_classes(:section).should_not include'error'
|
98
|
-
end
|
99
|
-
|
100
|
-
it "has error class with invalid argument set" do
|
101
|
-
arguments[:form_object].update(section: 'INVALID NAME').should be false
|
102
|
-
subject.get_optional_classes(:section).should include'error'
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe 'disabled' do
|
107
|
-
it "adds disabled when given as option" do
|
108
|
-
subject.get_optional_classes(:section, disabled: true).should include'disabled'
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
data/spec/rails/form_for_spec.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'form_for', type: :helper do
|
4
|
-
let(:form_html){ helper.form_for(subject){|f| f.text_field :section} }
|
5
|
-
let(:doc){ Nokogiri::HTML form_html }
|
6
|
-
let(:form){ doc.css('form').first }
|
7
|
-
let(:rails_form_method){ doc.css('[name="_method"]').first.try(:[], 'value') }
|
8
|
-
context 'record' do
|
9
|
-
context 'persisted' do
|
10
|
-
subject { Employee.create section: "SE1" }
|
11
|
-
it 'generates a proper route for a normal record' do
|
12
|
-
form['method'].should eq 'post'
|
13
|
-
form['action'].should eq "/employees/#{subject.id}"
|
14
|
-
rails_form_method.should eq 'patch'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'new record' do
|
19
|
-
subject { Employee.new section: "SE1" }
|
20
|
-
it 'generates a proper route for a normal record' do
|
21
|
-
form['method'].should eq 'post'
|
22
|
-
form['action'].should eq "/employees"
|
23
|
-
rails_form_method.should_not be_present
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context 'collection' do
|
29
|
-
subject{ Employee::Collection.new([], section: 'SE9') }
|
30
|
-
it 'generates a proper form for a collection record' do
|
31
|
-
form['method'].should eq 'post'
|
32
|
-
form['action'].should eq "/employees/collection_update"
|
33
|
-
rails_form_method.should_not be_present
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with format option" do
|
37
|
-
let(:form_html){ helper.form_for(subject, format: :json){|f| f.text_field :section } }
|
38
|
-
it "generates an action including format" do
|
39
|
-
form['method'].should eq 'post'
|
40
|
-
form['action'].should eq "/employees/collection_update.json"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with custom as: my_collection option" do
|
45
|
-
let(:form_html){ helper.form_for(subject, as: 'my_collection'){|f| f.text_field :section } }
|
46
|
-
it 'generates a proper form for a collection record with as param set' do
|
47
|
-
form['method'].should eq 'post'
|
48
|
-
form['action'].should eq "/employees/collection_update"
|
49
|
-
rails_form_method.should_not be_present
|
50
|
-
form['id'].should eq "collection_update_my_collection"
|
51
|
-
form['class'].should eq "collection_update_my_collection"
|
52
|
-
|
53
|
-
# Check field naming
|
54
|
-
doc.css('[name="my_collection[section]"]').first['value'].should eq 'SE9'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|