simple_table_for 0.2.0 → 0.3.0
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/README.md +31 -22
- data/lib/simple_table_for/helpers.rb +15 -10
- data/lib/simple_table_for/version.rb +1 -1
- data/test/dummy/app/views/posts/defaults.html.erb +1 -1
- data/test/dummy/app/views/posts/empty.html.erb +7 -0
- data/test/dummy/app/views/posts/render.html.erb +1 -1
- data/test/dummy/config/locales/en.yml +5 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +280 -0
- data/test/dummy/test/controllers/posts_controller_test.rb +14 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db5493bc8ee8100c8bd4118c60682816cbb2fd9b
|
4
|
+
data.tar.gz: 0078013530968c090263bf5c30d6a6a9b2a8d55a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad299a14b40c1363a9b456c1fa24b84e2872af1d9e4706d2ff3bbb6724a2662ad17e476f44593f5aaf871b4f18decfdaee63ea6d1a7a4b1da15dd1cd84b6385d
|
7
|
+
data.tar.gz: a0a5b4348d773e0ed0363b70e3850c48e745dd3dd2e2fa1432f9fd6860765e4c9f04b6521dbed874a888d7c330da9c38ef1ecf1b631315d2f5ae0067e674f26b
|
data/README.md
CHANGED
@@ -1,46 +1,55 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
Simple Table For helper
|
2
|
+
=======================
|
3
3
|
|
4
|
-
|
4
|
+
Generate HTML tables in a simple and clean way.
|
5
5
|
|
6
|
-
|
6
|
+
## Installation
|
7
7
|
|
8
8
|
```ruby
|
9
|
-
gem 'simple_table_for'
|
9
|
+
gem 'simple_table_for', '~> 0.3.0'
|
10
10
|
```
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
```ruby
|
15
|
-
table_for(collection, headers, options, &block)
|
16
|
-
```
|
17
|
-
|
18
|
-
Usage:
|
12
|
+
## Usage
|
19
13
|
|
20
14
|
```erb
|
21
|
-
<%= table_for @
|
22
|
-
<%= field
|
23
|
-
<%= field
|
24
|
-
<%= field
|
25
|
-
<%= field
|
26
|
-
<%= field link_to('View',
|
15
|
+
<%= table_for @users, [:name, :email, 'Registration date', 'Comments count', '-'], model: User do |user| %>
|
16
|
+
<%= field user.name %>
|
17
|
+
<%= field user.email %>
|
18
|
+
<%= field user.created_at %>
|
19
|
+
<%= field user.comments.count %>
|
20
|
+
<%= field link_to('View', user) %>
|
27
21
|
<% end %>
|
28
22
|
```
|
29
23
|
|
24
|
+
The above will generate a table like:
|
25
|
+
|
26
|
+
| First name | Email | Registration date | Comments count | - |
|
27
|
+
| ---------- | ------------- | ----------------- | --------------- | --------- |
|
28
|
+
| John | john@john.com | 01/01/2015 | 15 | [View](#) |
|
29
|
+
| Mark | mark@mark.com | 02/02/2015 | 34 | [View](#) |
|
30
|
+
|
31
|
+
The second parameter is a array of headers. For a Symbol header, the helper
|
32
|
+
will get the localizated name in `config/locales` folder. The `model` option
|
33
|
+
should be informed in this case. For a String header, the helper will just
|
34
|
+
print it as is.
|
35
|
+
|
30
36
|
You can optionally add an id or classes to tables and fields:
|
31
37
|
|
32
38
|
```erb
|
33
|
-
<%= table_for @
|
34
|
-
<%= field
|
35
|
-
<%= field link_to('View',
|
39
|
+
<%= table_for @users, [:name, '-'], model: User, id: 'users-table', class: 'table' do |user| %>
|
40
|
+
<%= field user.name, class: 'user-name' %>
|
41
|
+
<%= field link_to('View', user), class: 'user-link' %>
|
36
42
|
<% end %>
|
37
43
|
```
|
38
44
|
|
39
|
-
|
45
|
+
## Setting default options
|
46
|
+
|
47
|
+
You can also set a default class for tables:
|
40
48
|
|
41
49
|
```ruby
|
42
50
|
# application.rb
|
43
51
|
class Application < Rails:Application
|
52
|
+
# for a Bootstrap table
|
44
53
|
config.simple_table_for.defaults = {
|
45
54
|
class: 'table table-condensed table-striped table-bordered'
|
46
55
|
}
|
@@ -1,19 +1,19 @@
|
|
1
1
|
module SimpleTableFor
|
2
2
|
module Helpers
|
3
|
-
#
|
4
|
-
# See table_for for details
|
3
|
+
# Generates a table field.
|
4
|
+
# See table_for for details.
|
5
5
|
def field(content, options = {})
|
6
6
|
content_tag :td, content, options
|
7
7
|
end
|
8
8
|
|
9
|
-
#
|
9
|
+
# Generates a table.
|
10
10
|
# Usage:
|
11
|
-
# <%= table_for @
|
12
|
-
# <%= field
|
13
|
-
# <%= field
|
14
|
-
# <%= field
|
15
|
-
# <%= field
|
16
|
-
# <%= field link_to('View',
|
11
|
+
# <%= table_for @users, [:name, :email, 'Registration Date', 'Comments count', '-'], model: User, id: 'table-id', class: 'table-class' do |user| %>
|
12
|
+
# <%= field user.name %>
|
13
|
+
# <%= field user.email %>
|
14
|
+
# <%= field user.created_at %>
|
15
|
+
# <%= field user.comments.count %>
|
16
|
+
# <%= field link_to('View', user) %>
|
17
17
|
# <% end %>
|
18
18
|
def table_for(collection, headers, options = {})
|
19
19
|
options = Defaults.get.merge options
|
@@ -22,7 +22,12 @@ module SimpleTableFor
|
|
22
22
|
concat (content_tag :thead do
|
23
23
|
content_tag :tr do
|
24
24
|
headers.map do |header|
|
25
|
-
|
25
|
+
case header
|
26
|
+
when String
|
27
|
+
concat(content_tag :th, header)
|
28
|
+
when Symbol
|
29
|
+
concat(content_tag :th, options[:model].human_attribute_name(header))
|
30
|
+
end
|
26
31
|
end
|
27
32
|
end
|
28
33
|
end)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= table_for @posts,
|
1
|
+
<%= table_for @posts, [:title, :text, 'View Link'], model: Post, id: 'the-id', class: 'the-class' do |p| %>
|
2
2
|
<%= field p.title, class: 'title' %>
|
3
3
|
<%= field p.text, class: 'text' %>
|
4
4
|
<%= field link_to('View', p), class: 'link' %>
|
data/test/dummy/db/test.sqlite3
CHANGED
Binary file
|
data/test/dummy/log/test.log
CHANGED
@@ -997,3 +997,283 @@ Processing by PostsController#index as HTML
|
|
997
997
|
Rendered posts/defaults.html.erb within layouts/application (3.4ms)
|
998
998
|
Completed 200 OK in 25ms (Views: 23.1ms | ActiveRecord: 1.6ms)
|
999
999
|
[1m[35m (0.1ms)[0m rollback transaction
|
1000
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1001
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1002
|
+
[1m[36mFixture Delete (2.6ms)[0m [1mDELETE FROM "posts"[0m
|
1003
|
+
[1m[35mFixture Insert (0.5ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:41:25', '2015-06-08 18:41:25', 980190962)
|
1004
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:41:25', '2015-06-08 18:41:25', 298486374)[0m
|
1005
|
+
[1m[35m (3.3ms)[0m commit transaction
|
1006
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1007
|
+
-----------------------------------------------------------------------------------
|
1008
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1009
|
+
-----------------------------------------------------------------------------------
|
1010
|
+
Processing by PostsController#index as HTML
|
1011
|
+
Parameters: {"template"=>"defaults"}
|
1012
|
+
Rendered posts/defaults.html.erb within layouts/application (1.0ms)
|
1013
|
+
Completed 500 Internal Server Error in 84ms (ActiveRecord: 0.0ms)
|
1014
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1015
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1016
|
+
---------------------------------------------
|
1017
|
+
PostsControllerTest: test_should_render_table
|
1018
|
+
---------------------------------------------
|
1019
|
+
Processing by PostsController#index as HTML
|
1020
|
+
Parameters: {"template"=>"render"}
|
1021
|
+
Rendered posts/render.html.erb within layouts/application (0.7ms)
|
1022
|
+
Completed 500 Internal Server Error in 18ms (ActiveRecord: 0.0ms)
|
1023
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1024
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1025
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1026
|
+
[1m[36mFixture Delete (2.6ms)[0m [1mDELETE FROM "posts"[0m
|
1027
|
+
[1m[35mFixture Insert (0.6ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:42:03', '2015-06-08 18:42:03', 980190962)
|
1028
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:42:03', '2015-06-08 18:42:03', 298486374)[0m
|
1029
|
+
[1m[35m (2.9ms)[0m commit transaction
|
1030
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1031
|
+
---------------------------------------------
|
1032
|
+
PostsControllerTest: test_should_render_table
|
1033
|
+
---------------------------------------------
|
1034
|
+
Processing by PostsController#index as HTML
|
1035
|
+
Parameters: {"template"=>"render"}
|
1036
|
+
[1m[35mPost Load (1.5ms)[0m SELECT "posts".* FROM "posts"
|
1037
|
+
Rendered posts/render.html.erb within layouts/application (13.1ms)
|
1038
|
+
Completed 200 OK in 189ms (Views: 186.7ms | ActiveRecord: 1.5ms)
|
1039
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1040
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1041
|
+
-----------------------------------------------------------------------------------
|
1042
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1043
|
+
-----------------------------------------------------------------------------------
|
1044
|
+
Processing by PostsController#index as HTML
|
1045
|
+
Parameters: {"template"=>"defaults"}
|
1046
|
+
[1m[36mPost Load (1.6ms)[0m [1mSELECT "posts".* FROM "posts"[0m
|
1047
|
+
Rendered posts/defaults.html.erb within layouts/application (3.4ms)
|
1048
|
+
Completed 200 OK in 22ms (Views: 19.7ms | ActiveRecord: 1.6ms)
|
1049
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1050
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1051
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1052
|
+
[1m[36mFixture Delete (3.2ms)[0m [1mDELETE FROM "posts"[0m
|
1053
|
+
[1m[35mFixture Insert (0.8ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:43:36', '2015-06-08 18:43:36', 980190962)
|
1054
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:43:36', '2015-06-08 18:43:36', 298486374)[0m
|
1055
|
+
[1m[35m (3.0ms)[0m commit transaction
|
1056
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1057
|
+
---------------------------------------------
|
1058
|
+
PostsControllerTest: test_should_render_table
|
1059
|
+
---------------------------------------------
|
1060
|
+
Processing by PostsController#index as HTML
|
1061
|
+
Parameters: {"template"=>"render"}
|
1062
|
+
[1m[35mPost Load (1.7ms)[0m SELECT "posts".* FROM "posts"
|
1063
|
+
Rendered posts/render.html.erb within layouts/application (13.5ms)
|
1064
|
+
Completed 200 OK in 120ms (Views: 117.6ms | ActiveRecord: 1.7ms)
|
1065
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1066
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1067
|
+
-----------------------------------------------------------------------------------
|
1068
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1069
|
+
-----------------------------------------------------------------------------------
|
1070
|
+
Processing by PostsController#index as HTML
|
1071
|
+
Parameters: {"template"=>"defaults"}
|
1072
|
+
[1m[36mPost Load (1.5ms)[0m [1mSELECT "posts".* FROM "posts"[0m
|
1073
|
+
Rendered posts/defaults.html.erb within layouts/application (3.2ms)
|
1074
|
+
Completed 200 OK in 21ms (Views: 19.1ms | ActiveRecord: 1.5ms)
|
1075
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1076
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1077
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1078
|
+
[1m[36mFixture Delete (2.6ms)[0m [1mDELETE FROM "posts"[0m
|
1079
|
+
[1m[35mFixture Insert (0.6ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:55:30', '2015-06-08 18:55:30', 980190962)
|
1080
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 18:55:30', '2015-06-08 18:55:30', 298486374)[0m
|
1081
|
+
[1m[35m (3.4ms)[0m commit transaction
|
1082
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1083
|
+
---------------------------------------------
|
1084
|
+
PostsControllerTest: test_should_render_table
|
1085
|
+
---------------------------------------------
|
1086
|
+
Processing by PostsController#index as HTML
|
1087
|
+
Parameters: {"template"=>"render"}
|
1088
|
+
[1m[35mPost Load (1.2ms)[0m SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
|
1089
|
+
[1m[36mPost Load (0.1ms)[0m [1mSELECT "posts".* FROM "posts"[0m
|
1090
|
+
Rendered posts/render.html.erb within layouts/application (60.2ms)
|
1091
|
+
Completed 200 OK in 173ms (Views: 171.1ms | ActiveRecord: 1.4ms)
|
1092
|
+
[1m[35m (0.2ms)[0m rollback transaction
|
1093
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1094
|
+
-----------------------------------------------------------------------------------
|
1095
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1096
|
+
-----------------------------------------------------------------------------------
|
1097
|
+
Processing by PostsController#index as HTML
|
1098
|
+
Parameters: {"template"=>"defaults"}
|
1099
|
+
[1m[35mPost Load (1.5ms)[0m SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
|
1100
|
+
[1m[36mPost Load (0.1ms)[0m [1mSELECT "posts".* FROM "posts"[0m
|
1101
|
+
Rendered posts/defaults.html.erb within layouts/application (4.0ms)
|
1102
|
+
Completed 200 OK in 25ms (Views: 22.9ms | ActiveRecord: 1.6ms)
|
1103
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
1104
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1105
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1106
|
+
[1m[36mFixture Delete (2.4ms)[0m [1mDELETE FROM "posts"[0m
|
1107
|
+
[1m[35mFixture Insert (0.6ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:01:12', '2015-06-08 19:01:12', 980190962)
|
1108
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:01:12', '2015-06-08 19:01:12', 298486374)[0m
|
1109
|
+
[1m[35m (3.2ms)[0m commit transaction
|
1110
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1111
|
+
---------------------------------------------
|
1112
|
+
PostsControllerTest: test_should_render_table
|
1113
|
+
---------------------------------------------
|
1114
|
+
Processing by PostsController#index as HTML
|
1115
|
+
Parameters: {"template"=>"render"}
|
1116
|
+
[1m[35mPost Load (2.1ms)[0m SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
|
1117
|
+
[1m[36mPost Load (0.3ms)[0m [1mSELECT "posts".* FROM "posts"[0m
|
1118
|
+
Rendered posts/render.html.erb within layouts/application (22.4ms)
|
1119
|
+
Completed 200 OK in 131ms (Views: 128.5ms | ActiveRecord: 2.3ms)
|
1120
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1121
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1122
|
+
---------------------------------------------------
|
1123
|
+
PostsControllerTest: test_should_render_empty_table
|
1124
|
+
---------------------------------------------------
|
1125
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1126
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1127
|
+
-----------------------------------------------------------------------------------
|
1128
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1129
|
+
-----------------------------------------------------------------------------------
|
1130
|
+
Processing by PostsController#index as HTML
|
1131
|
+
Parameters: {"template"=>"defaults"}
|
1132
|
+
[1m[35mPost Load (1.9ms)[0m SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
|
1133
|
+
[1m[36mPost Load (0.1ms)[0m [1mSELECT "posts".* FROM "posts"[0m
|
1134
|
+
Rendered posts/defaults.html.erb within layouts/application (6.4ms)
|
1135
|
+
Completed 200 OK in 29ms (Views: 26.5ms | ActiveRecord: 2.0ms)
|
1136
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1137
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.4ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1138
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1139
|
+
[1m[36mFixture Delete (2.6ms)[0m [1mDELETE FROM "posts"[0m
|
1140
|
+
[1m[35mFixture Insert (0.6ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:01:34', '2015-06-08 19:01:34', 980190962)
|
1141
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:01:34', '2015-06-08 19:01:34', 298486374)[0m
|
1142
|
+
[1m[35m (3.2ms)[0m commit transaction
|
1143
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1144
|
+
---------------------------------------------------
|
1145
|
+
PostsControllerTest: test_should_render_empty_table
|
1146
|
+
---------------------------------------------------
|
1147
|
+
Processing by PostsController#index as HTML
|
1148
|
+
Parameters: {"template"=>"empty"}
|
1149
|
+
[1m[35mPost Load (1.6ms)[0m SELECT "posts".* FROM "posts" WHERE (0 = 1) ORDER BY "posts"."id" ASC LIMIT 1
|
1150
|
+
Rendered posts/empty.html.erb within layouts/application (53.7ms)
|
1151
|
+
Completed 500 Internal Server Error in 124ms (ActiveRecord: 1.6ms)
|
1152
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1153
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1154
|
+
-----------------------------------------------------------------------------------
|
1155
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1156
|
+
-----------------------------------------------------------------------------------
|
1157
|
+
Processing by PostsController#index as HTML
|
1158
|
+
Parameters: {"template"=>"defaults"}
|
1159
|
+
[1m[36mPost Load (1.5ms)[0m [1mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1[0m
|
1160
|
+
[1m[35mPost Load (0.2ms)[0m SELECT "posts".* FROM "posts"
|
1161
|
+
Rendered posts/defaults.html.erb within layouts/application (16.5ms)
|
1162
|
+
Completed 200 OK in 76ms (Views: 74.2ms | ActiveRecord: 1.7ms)
|
1163
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1164
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1165
|
+
---------------------------------------------
|
1166
|
+
PostsControllerTest: test_should_render_table
|
1167
|
+
---------------------------------------------
|
1168
|
+
Processing by PostsController#index as HTML
|
1169
|
+
Parameters: {"template"=>"render"}
|
1170
|
+
[1m[36mPost Load (1.6ms)[0m [1mSELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1[0m
|
1171
|
+
[1m[35mPost Load (0.1ms)[0m SELECT "posts".* FROM "posts"
|
1172
|
+
Rendered posts/render.html.erb within layouts/application (4.1ms)
|
1173
|
+
Completed 200 OK in 27ms (Views: 24.9ms | ActiveRecord: 1.8ms)
|
1174
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1175
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1176
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1177
|
+
[1m[36mFixture Delete (2.5ms)[0m [1mDELETE FROM "posts"[0m
|
1178
|
+
[1m[35mFixture Insert (0.2ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:03:59', '2015-06-08 19:03:59', 980190962)
|
1179
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:03:59', '2015-06-08 19:03:59', 298486374)[0m
|
1180
|
+
[1m[35m (3.3ms)[0m commit transaction
|
1181
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1182
|
+
---------------------------------------------------
|
1183
|
+
PostsControllerTest: test_should_render_empty_table
|
1184
|
+
---------------------------------------------------
|
1185
|
+
Processing by PostsController#index as HTML
|
1186
|
+
Parameters: {"template"=>"empty"}
|
1187
|
+
Rendered posts/empty.html.erb within layouts/application (38.9ms)
|
1188
|
+
Completed 500 Internal Server Error in 130ms (ActiveRecord: 0.0ms)
|
1189
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1190
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1191
|
+
-----------------------------------------------------------------------------------
|
1192
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1193
|
+
-----------------------------------------------------------------------------------
|
1194
|
+
Processing by PostsController#index as HTML
|
1195
|
+
Parameters: {"template"=>"defaults"}
|
1196
|
+
Rendered posts/defaults.html.erb within layouts/application (17.0ms)
|
1197
|
+
Completed 500 Internal Server Error in 34ms (ActiveRecord: 0.0ms)
|
1198
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1199
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1200
|
+
---------------------------------------------
|
1201
|
+
PostsControllerTest: test_should_render_table
|
1202
|
+
---------------------------------------------
|
1203
|
+
Processing by PostsController#index as HTML
|
1204
|
+
Parameters: {"template"=>"render"}
|
1205
|
+
Rendered posts/render.html.erb within layouts/application (16.6ms)
|
1206
|
+
Completed 500 Internal Server Error in 34ms (ActiveRecord: 0.0ms)
|
1207
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1208
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.5ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1209
|
+
[1m[35m (0.2ms)[0m begin transaction
|
1210
|
+
[1m[36mFixture Delete (2.5ms)[0m [1mDELETE FROM "posts"[0m
|
1211
|
+
[1m[35mFixture Insert (0.6ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:04:25', '2015-06-08 19:04:25', 980190962)
|
1212
|
+
[1m[36mFixture Insert (0.2ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:04:25', '2015-06-08 19:04:25', 298486374)[0m
|
1213
|
+
[1m[35m (3.2ms)[0m commit transaction
|
1214
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1215
|
+
-----------------------------------------------------------------------------------
|
1216
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1217
|
+
-----------------------------------------------------------------------------------
|
1218
|
+
Processing by PostsController#index as HTML
|
1219
|
+
Parameters: {"template"=>"defaults"}
|
1220
|
+
[1m[35mPost Load (3.4ms)[0m SELECT "posts".* FROM "posts"
|
1221
|
+
Rendered posts/defaults.html.erb within layouts/application (39.0ms)
|
1222
|
+
Completed 200 OK in 194ms (Views: 190.0ms | ActiveRecord: 3.4ms)
|
1223
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1224
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1225
|
+
---------------------------------------------------
|
1226
|
+
PostsControllerTest: test_should_render_empty_table
|
1227
|
+
---------------------------------------------------
|
1228
|
+
Processing by PostsController#index as HTML
|
1229
|
+
Parameters: {"template"=>"empty"}
|
1230
|
+
[1m[36mPost Load (1.6ms)[0m [1mSELECT "posts".* FROM "posts" WHERE (0 = 1)[0m
|
1231
|
+
Rendered posts/empty.html.erb within layouts/application (3.4ms)
|
1232
|
+
Completed 200 OK in 21ms (Views: 19.1ms | ActiveRecord: 1.6ms)
|
1233
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1234
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1235
|
+
---------------------------------------------
|
1236
|
+
PostsControllerTest: test_should_render_table
|
1237
|
+
---------------------------------------------
|
1238
|
+
Processing by PostsController#index as HTML
|
1239
|
+
Parameters: {"template"=>"render"}
|
1240
|
+
[1m[35mPost Load (1.2ms)[0m SELECT "posts".* FROM "posts"
|
1241
|
+
Rendered posts/render.html.erb within layouts/application (3.2ms)
|
1242
|
+
Completed 200 OK in 21ms (Views: 19.5ms | ActiveRecord: 1.2ms)
|
1243
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1244
|
+
[1m[36mActiveRecord::SchemaMigration Load (1.6ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
1245
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1246
|
+
[1m[36mFixture Delete (2.3ms)[0m [1mDELETE FROM "posts"[0m
|
1247
|
+
[1m[35mFixture Insert (0.5ms)[0m INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:09:34', '2015-06-08 19:09:34', 980190962)
|
1248
|
+
[1m[36mFixture Insert (0.1ms)[0m [1mINSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-06-08 19:09:34', '2015-06-08 19:09:34', 298486374)[0m
|
1249
|
+
[1m[35m (3.0ms)[0m commit transaction
|
1250
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
1251
|
+
---------------------------------------------
|
1252
|
+
PostsControllerTest: test_should_render_table
|
1253
|
+
---------------------------------------------
|
1254
|
+
Processing by PostsController#index as HTML
|
1255
|
+
Parameters: {"template"=>"render"}
|
1256
|
+
[1m[35mPost Load (1.5ms)[0m SELECT "posts".* FROM "posts"
|
1257
|
+
Rendered posts/render.html.erb within layouts/application (18.9ms)
|
1258
|
+
Completed 200 OK in 133ms (Views: 131.5ms | ActiveRecord: 1.5ms)
|
1259
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
1260
|
+
[1m[35m (0.1ms)[0m begin transaction
|
1261
|
+
---------------------------------------------------
|
1262
|
+
PostsControllerTest: test_should_render_empty_table
|
1263
|
+
---------------------------------------------------
|
1264
|
+
Processing by PostsController#index as HTML
|
1265
|
+
Parameters: {"template"=>"empty"}
|
1266
|
+
[1m[36mPost Load (1.5ms)[0m [1mSELECT "posts".* FROM "posts" WHERE (0 = 1)[0m
|
1267
|
+
Rendered posts/empty.html.erb within layouts/application (3.4ms)
|
1268
|
+
Completed 200 OK in 31ms (Views: 29.6ms | ActiveRecord: 1.5ms)
|
1269
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
1270
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
1271
|
+
-----------------------------------------------------------------------------------
|
1272
|
+
PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
|
1273
|
+
-----------------------------------------------------------------------------------
|
1274
|
+
Processing by PostsController#index as HTML
|
1275
|
+
Parameters: {"template"=>"defaults"}
|
1276
|
+
[1m[35mPost Load (1.6ms)[0m SELECT "posts".* FROM "posts"
|
1277
|
+
Rendered posts/defaults.html.erb within layouts/application (3.4ms)
|
1278
|
+
Completed 200 OK in 21ms (Views: 19.5ms | ActiveRecord: 1.6ms)
|
1279
|
+
[1m[36m (0.1ms)[0m [1mrollback transaction[0m
|
@@ -19,6 +19,10 @@ class PostsControllerTest < ActionController::TestCase
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
assert_match(/Post\ Text/, @response.body)
|
24
|
+
assert_match(/Post\ Title/, @response.body)
|
25
|
+
assert_match(/View\ Link/, @response.body)
|
22
26
|
end
|
23
27
|
|
24
28
|
test 'should render table with defaults (set in application.rb)' do
|
@@ -37,5 +41,15 @@ class PostsControllerTest < ActionController::TestCase
|
|
37
41
|
end
|
38
42
|
end
|
39
43
|
end
|
44
|
+
|
45
|
+
assert_match(/Post\ Text/, @response.body)
|
46
|
+
assert_match(/Post\ Title/, @response.body)
|
47
|
+
assert_match(/View\ Link/, @response.body)
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'should render empty table' do
|
51
|
+
assert_nothing_raised do
|
52
|
+
get :index, template: :empty
|
53
|
+
end
|
40
54
|
end
|
41
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_table_for
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Nering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -38,7 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 4.0.0
|
41
|
-
description: Simple
|
41
|
+
description: Simple Table For helper for Rails let you generate HTML tables in a simple
|
42
|
+
and clean way
|
42
43
|
email:
|
43
44
|
- andrey.nering@gmail.com
|
44
45
|
executables: []
|
@@ -67,6 +68,7 @@ files:
|
|
67
68
|
- test/dummy/app/models/post.rb
|
68
69
|
- test/dummy/app/views/layouts/application.html.erb
|
69
70
|
- test/dummy/app/views/posts/defaults.html.erb
|
71
|
+
- test/dummy/app/views/posts/empty.html.erb
|
70
72
|
- test/dummy/app/views/posts/render.html.erb
|
71
73
|
- test/dummy/bin/bundle
|
72
74
|
- test/dummy/bin/rails
|
@@ -153,7 +155,7 @@ rubyforge_project:
|
|
153
155
|
rubygems_version: 2.4.5
|
154
156
|
signing_key:
|
155
157
|
specification_version: 4
|
156
|
-
summary: Simple
|
158
|
+
summary: Simple helper for creating HTML tables in Rails
|
157
159
|
test_files:
|
158
160
|
- test/dummy/app/assets/javascripts/application.js
|
159
161
|
- test/dummy/app/assets/javascripts/posts.js
|
@@ -166,6 +168,7 @@ test_files:
|
|
166
168
|
- test/dummy/app/models/post.rb
|
167
169
|
- test/dummy/app/views/layouts/application.html.erb
|
168
170
|
- test/dummy/app/views/posts/defaults.html.erb
|
171
|
+
- test/dummy/app/views/posts/empty.html.erb
|
169
172
|
- test/dummy/app/views/posts/render.html.erb
|
170
173
|
- test/dummy/bin/bundle
|
171
174
|
- test/dummy/bin/rails
|