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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b208088ee644b17dd731b8cf5724348b62ab32d7
4
- data.tar.gz: df5cbddee701c5ba3bb4fe085b9d503430b0df2c
3
+ metadata.gz: db5493bc8ee8100c8bd4118c60682816cbb2fd9b
4
+ data.tar.gz: 0078013530968c090263bf5c30d6a6a9b2a8d55a
5
5
  SHA512:
6
- metadata.gz: 31c202cd5a104cc41c7c809a13284af657f11f8904660f32a2e3fbe402301ab094e6e4af197b4864a3ccade749afcbdc02bd28993dce8204d8f7ac1d4f45a936
7
- data.tar.gz: 1e4545d2e0ae2364dfa0fe799479c678be51afa1409ead8cdad1077364f4e50674a38fa54b5b9fd931eb6d2337df03868cf9959b58f36a59d8ca324889153bae
6
+ metadata.gz: ad299a14b40c1363a9b456c1fa24b84e2872af1d9e4706d2ff3bbb6724a2662ad17e476f44593f5aaf871b4f18decfdaee63ea6d1a7a4b1da15dd1cd84b6385d
7
+ data.tar.gz: a0a5b4348d773e0ed0363b70e3850c48e745dd3dd2e2fa1432f9fd6860765e4c9f04b6521dbed874a888d7c330da9c38ef1ecf1b631315d2f5ae0067e674f26b
data/README.md CHANGED
@@ -1,46 +1,55 @@
1
- SimpleTableFor
2
- ==============
1
+ Simple Table For helper
2
+ =======================
3
3
 
4
- A simple helper to generate tables in Rails applications.
4
+ Generate HTML tables in a simple and clean way.
5
5
 
6
- In your Gemfile:
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
- Parameters:
13
-
14
- ```ruby
15
- table_for(collection, headers, options, &block)
16
- ```
17
-
18
- Usage:
12
+ ## Usage
19
13
 
20
14
  ```erb
21
- <%= table_for @posts, %w[Title Text Date Comments\ count -] do |post| %>
22
- <%= field post.title %>
23
- <%= field post.text %>
24
- <%= field post.date %>
25
- <%= field post.comments.count %>
26
- <%= field link_to('View', post) %>
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 @posts, %w[Title -], id: 'posts-table', class: 'table' do |post| %>
34
- <%= field post.title, class: 'post-title' %>
35
- <%= field link_to('View', post), class: '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
- You can also set default id and class for tables:
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
- # Creates a table field
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
- # Creates a table
9
+ # Generates a table.
10
10
  # Usage:
11
- # <%= table_for @posts, %w[Title Text Date Comments\ count -] do |post| %>
12
- # <%= field post.title %>
13
- # <%= field post.text %>
14
- # <%= field post.date %>
15
- # <%= field post.comments.count %>
16
- # <%= field link_to('View', post) %>
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
- concat(content_tag :th, header)
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,3 +1,3 @@
1
1
  module SimpleTableFor
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -1,4 +1,4 @@
1
- <%= table_for @posts, %w[Title Text Link] do |p| %>
1
+ <%= table_for @posts, [:title, :text, 'View Link'], model: Post do |p| %>
2
2
  <%= field p.title %>
3
3
  <%= field p.text %>
4
4
  <%= field link_to('View', p) %>
@@ -0,0 +1,7 @@
1
+ <% @posts = @posts.where('0 = 1') %>
2
+
3
+ <%= table_for @posts, [:title, :text, 'View Link'], model: Post do |p| %>
4
+ <%= field p.title %>
5
+ <%= field p.text %>
6
+ <%= field link_to('View', p) %>
7
+ <% end %>
@@ -1,4 +1,4 @@
1
- <%= table_for @posts, %w[Title Text Link], id: 'the-id', class: 'the-class' do |p| %>
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' %>
@@ -20,4 +20,8 @@
20
20
  # available at http://guides.rubyonrails.org/i18n.html.
21
21
 
22
22
  en:
23
- hello: "Hello world"
23
+ activerecord:
24
+ attributes:
25
+ post:
26
+ text: Post Text
27
+ title: Post Title
Binary file
@@ -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
   (0.1ms) rollback transaction
1000
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
1001
+  (0.1ms) begin transaction
1002
+ Fixture Delete (2.6ms) DELETE FROM "posts"
1003
+ Fixture Insert (0.5ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1005
+  (3.3ms) commit transaction
1006
+  (0.1ms) begin transaction
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
+  (0.1ms) rollback transaction
1015
+  (0.1ms) begin transaction
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
+  (0.1ms) rollback transaction
1024
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
1025
+  (0.1ms) begin transaction
1026
+ Fixture Delete (2.6ms) DELETE FROM "posts"
1027
+ Fixture Insert (0.6ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1029
+  (2.9ms) commit transaction
1030
+  (0.1ms) begin transaction
1031
+ ---------------------------------------------
1032
+ PostsControllerTest: test_should_render_table
1033
+ ---------------------------------------------
1034
+ Processing by PostsController#index as HTML
1035
+ Parameters: {"template"=>"render"}
1036
+ Post Load (1.5ms) 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
+  (0.1ms) rollback transaction
1040
+  (0.1ms) 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
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
1047
+ Rendered posts/defaults.html.erb within layouts/application (3.4ms)
1048
+ Completed 200 OK in 22ms (Views: 19.7ms | ActiveRecord: 1.6ms)
1049
+  (0.1ms) rollback transaction
1050
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
1051
+  (0.1ms) begin transaction
1052
+ Fixture Delete (3.2ms) DELETE FROM "posts"
1053
+ Fixture Insert (0.8ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1055
+  (3.0ms) commit transaction
1056
+  (0.1ms) begin transaction
1057
+ ---------------------------------------------
1058
+ PostsControllerTest: test_should_render_table
1059
+ ---------------------------------------------
1060
+ Processing by PostsController#index as HTML
1061
+ Parameters: {"template"=>"render"}
1062
+ Post Load (1.7ms) 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
+  (0.1ms) rollback transaction
1066
+  (0.1ms) 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
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
1073
+ Rendered posts/defaults.html.erb within layouts/application (3.2ms)
1074
+ Completed 200 OK in 21ms (Views: 19.1ms | ActiveRecord: 1.5ms)
1075
+  (0.1ms) rollback transaction
1076
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
1077
+  (0.1ms) begin transaction
1078
+ Fixture Delete (2.6ms) DELETE FROM "posts"
1079
+ Fixture Insert (0.6ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1081
+  (3.4ms) commit transaction
1082
+  (0.1ms) begin transaction
1083
+ ---------------------------------------------
1084
+ PostsControllerTest: test_should_render_table
1085
+ ---------------------------------------------
1086
+ Processing by PostsController#index as HTML
1087
+ Parameters: {"template"=>"render"}
1088
+ Post Load (1.2ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
1089
+ Post Load (0.1ms) SELECT "posts".* FROM "posts"
1090
+ Rendered posts/render.html.erb within layouts/application (60.2ms)
1091
+ Completed 200 OK in 173ms (Views: 171.1ms | ActiveRecord: 1.4ms)
1092
+  (0.2ms) rollback transaction
1093
+  (0.1ms) begin transaction
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
+ Post Load (1.5ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
1100
+ Post Load (0.1ms) SELECT "posts".* FROM "posts"
1101
+ Rendered posts/defaults.html.erb within layouts/application (4.0ms)
1102
+ Completed 200 OK in 25ms (Views: 22.9ms | ActiveRecord: 1.6ms)
1103
+  (0.0ms) rollback transaction
1104
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
1105
+  (0.1ms) begin transaction
1106
+ Fixture Delete (2.4ms) DELETE FROM "posts"
1107
+ Fixture Insert (0.6ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1109
+  (3.2ms) commit transaction
1110
+  (0.1ms) begin transaction
1111
+ ---------------------------------------------
1112
+ PostsControllerTest: test_should_render_table
1113
+ ---------------------------------------------
1114
+ Processing by PostsController#index as HTML
1115
+ Parameters: {"template"=>"render"}
1116
+ Post Load (2.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
1117
+ Post Load (0.3ms) SELECT "posts".* FROM "posts"
1118
+ Rendered posts/render.html.erb within layouts/application (22.4ms)
1119
+ Completed 200 OK in 131ms (Views: 128.5ms | ActiveRecord: 2.3ms)
1120
+  (0.1ms) rollback transaction
1121
+  (0.1ms) begin transaction
1122
+ ---------------------------------------------------
1123
+ PostsControllerTest: test_should_render_empty_table
1124
+ ---------------------------------------------------
1125
+  (0.1ms) rollback transaction
1126
+  (0.2ms) begin transaction
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
+ Post Load (1.9ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
1133
+ Post Load (0.1ms) SELECT "posts".* FROM "posts"
1134
+ Rendered posts/defaults.html.erb within layouts/application (6.4ms)
1135
+ Completed 200 OK in 29ms (Views: 26.5ms | ActiveRecord: 2.0ms)
1136
+  (0.1ms) rollback transaction
1137
+ ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
1138
+  (0.1ms) begin transaction
1139
+ Fixture Delete (2.6ms) DELETE FROM "posts"
1140
+ Fixture Insert (0.6ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1142
+  (3.2ms) commit transaction
1143
+  (0.1ms) begin transaction
1144
+ ---------------------------------------------------
1145
+ PostsControllerTest: test_should_render_empty_table
1146
+ ---------------------------------------------------
1147
+ Processing by PostsController#index as HTML
1148
+ Parameters: {"template"=>"empty"}
1149
+ Post Load (1.6ms) 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
+  (0.1ms) rollback transaction
1153
+  (0.1ms) 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
+ Post Load (1.5ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
1160
+ Post Load (0.2ms) 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
+  (0.1ms) rollback transaction
1164
+  (0.1ms) begin transaction
1165
+ ---------------------------------------------
1166
+ PostsControllerTest: test_should_render_table
1167
+ ---------------------------------------------
1168
+ Processing by PostsController#index as HTML
1169
+ Parameters: {"template"=>"render"}
1170
+ Post Load (1.6ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
1171
+ Post Load (0.1ms) 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
+  (0.1ms) rollback transaction
1175
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
1176
+  (0.1ms) begin transaction
1177
+ Fixture Delete (2.5ms) DELETE FROM "posts"
1178
+ Fixture Insert (0.2ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1180
+  (3.3ms) commit transaction
1181
+  (0.1ms) begin transaction
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
+  (0.1ms) rollback transaction
1190
+  (0.1ms) begin transaction
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
+  (0.1ms) rollback transaction
1199
+  (0.2ms) begin transaction
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
+  (0.1ms) rollback transaction
1208
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
1209
+  (0.2ms) begin transaction
1210
+ Fixture Delete (2.5ms) DELETE FROM "posts"
1211
+ Fixture Insert (0.6ms) 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
+ Fixture Insert (0.2ms) 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', 298486374)
1213
+  (3.2ms) commit transaction
1214
+  (0.1ms) begin transaction
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
+ Post Load (3.4ms) 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
+  (0.1ms) rollback transaction
1224
+  (0.1ms) begin transaction
1225
+ ---------------------------------------------------
1226
+ PostsControllerTest: test_should_render_empty_table
1227
+ ---------------------------------------------------
1228
+ Processing by PostsController#index as HTML
1229
+ Parameters: {"template"=>"empty"}
1230
+ Post Load (1.6ms) SELECT "posts".* FROM "posts" WHERE (0 = 1)
1231
+ Rendered posts/empty.html.erb within layouts/application (3.4ms)
1232
+ Completed 200 OK in 21ms (Views: 19.1ms | ActiveRecord: 1.6ms)
1233
+  (0.1ms) rollback transaction
1234
+  (0.1ms) begin transaction
1235
+ ---------------------------------------------
1236
+ PostsControllerTest: test_should_render_table
1237
+ ---------------------------------------------
1238
+ Processing by PostsController#index as HTML
1239
+ Parameters: {"template"=>"render"}
1240
+ Post Load (1.2ms) 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
+  (0.1ms) rollback transaction
1244
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
1245
+  (0.1ms) begin transaction
1246
+ Fixture Delete (2.3ms) DELETE FROM "posts"
1247
+ Fixture Insert (0.5ms) 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
+ Fixture Insert (0.1ms) 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', 298486374)
1249
+  (3.0ms) commit transaction
1250
+  (0.1ms) begin transaction
1251
+ ---------------------------------------------
1252
+ PostsControllerTest: test_should_render_table
1253
+ ---------------------------------------------
1254
+ Processing by PostsController#index as HTML
1255
+ Parameters: {"template"=>"render"}
1256
+ Post Load (1.5ms) 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
+  (0.1ms) rollback transaction
1260
+  (0.1ms) begin transaction
1261
+ ---------------------------------------------------
1262
+ PostsControllerTest: test_should_render_empty_table
1263
+ ---------------------------------------------------
1264
+ Processing by PostsController#index as HTML
1265
+ Parameters: {"template"=>"empty"}
1266
+ Post Load (1.5ms) SELECT "posts".* FROM "posts" WHERE (0 = 1)
1267
+ Rendered posts/empty.html.erb within layouts/application (3.4ms)
1268
+ Completed 200 OK in 31ms (Views: 29.6ms | ActiveRecord: 1.5ms)
1269
+  (0.1ms) rollback transaction
1270
+  (0.2ms) begin transaction
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
+ Post Load (1.6ms) 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
+  (0.1ms) rollback transaction
@@ -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.2.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-04-01 00:00:00.000000000 Z
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 way of creating tables in Rails
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 way of creating tables in Rails
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