simple_table_for 0.1.1 → 0.2.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: 60a5b1d6898d6efb9a727f6a4a4fc1c0b1ef80e1
4
- data.tar.gz: e803e52c907e8ce9d3fd575d92fd497c9e8683a4
3
+ metadata.gz: b208088ee644b17dd731b8cf5724348b62ab32d7
4
+ data.tar.gz: df5cbddee701c5ba3bb4fe085b9d503430b0df2c
5
5
  SHA512:
6
- metadata.gz: 2a9718c2fe529bae191afb7352cde17329592a833c1f058eced55c1ca4fb1273ed3d7efe1fd6c5892da664848fd97d0a1f5948428a192865c5bdcc5526646c9c
7
- data.tar.gz: 2294be28c4897afa9b0811de2e18fa4c937eed461cae36bddaee19d5edd375288023dc0bf9f90b7f3004633c6b118064d3a6fa440c6c9ec8dfe9a589c91649e6
6
+ metadata.gz: 31c202cd5a104cc41c7c809a13284af657f11f8904660f32a2e3fbe402301ab094e6e4af197b4864a3ccade749afcbdc02bd28993dce8204d8f7ac1d4f45a936
7
+ data.tar.gz: 1e4545d2e0ae2364dfa0fe799479c678be51afa1409ead8cdad1077364f4e50674a38fa54b5b9fd931eb6d2337df03868cf9959b58f36a59d8ca324889153bae
data/README.md CHANGED
@@ -41,7 +41,9 @@ You can also set default id and class for tables:
41
41
  ```ruby
42
42
  # application.rb
43
43
  class Application < Rails:Application
44
- SimpleTableFor::Defaults.set id: 'table-id', class: 'table table-condensed table-striped table-bordered'
44
+ config.simple_table_for.defaults = {
45
+ class: 'table table-condensed table-striped table-bordered'
46
+ }
45
47
  end
46
48
  ```
47
49
 
@@ -0,0 +1,11 @@
1
+ module SimpleTableFor
2
+ class Defaults
3
+ def self.get
4
+ @defaults || {}
5
+ end
6
+
7
+ def self.set(options)
8
+ @defaults = options
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,40 @@
1
+ module SimpleTableFor
2
+ module Helpers
3
+ # Creates a table field
4
+ # See table_for for details
5
+ def field(content, options = {})
6
+ content_tag :td, content, options
7
+ end
8
+
9
+ # Creates a table
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) %>
17
+ # <% end %>
18
+ def table_for(collection, headers, options = {})
19
+ options = Defaults.get.merge options
20
+
21
+ content_tag :table, options do
22
+ concat (content_tag :thead do
23
+ content_tag :tr do
24
+ headers.map do |header|
25
+ concat(content_tag :th, header)
26
+ end
27
+ end
28
+ end)
29
+
30
+ concat (content_tag :tbody do
31
+ collection.map do |obj|
32
+ concat (content_tag :tr do
33
+ capture{ yield obj }
34
+ end)
35
+ end
36
+ end)
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,10 @@
1
+ module SimpleTableFor
2
+ class ::Application < Rails::Application
3
+ config.simple_table_for = ActiveSupport::OrderedOptions.new
4
+ config.simple_table_for.defaults = ActiveSupport::OrderedOptions.new
5
+
6
+ config.after_initialize do |app|
7
+ Defaults.set app.config.simple_table_for.defaults
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleTableFor
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -1,61 +1,5 @@
1
- module SimpleTableFor
2
- module Helpers
3
- # Creates a table field
4
- # See table for details
5
- def field(content, options = {})
6
- content_tag :td, content, id: options[:id], class: options[:class]
7
- end
8
-
9
- # Creates a table
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) %>
17
- # <% end %>
18
- def table_for(collection, headers, options = {})
19
- options = Defaults.get.merge options
20
-
21
- content_tag :table, id: options[:id], class: options[:class] do
22
- concat (content_tag :thead do
23
- content_tag :tr do
24
- headers.map do |header|
25
- concat(content_tag :th, header)
26
- end
27
- end
28
- end)
29
-
30
- concat (content_tag :tbody do
31
- collection.map do |obj|
32
- concat (content_tag :tr do
33
- capture{ yield obj }
34
- end)
35
- end
36
- end)
37
- end
38
- end
39
- end
40
-
41
- # This class handles the default options
42
- class Defaults
43
- # Get de default options
44
- def self.get
45
- @defaults || defaults
46
- end
47
-
48
- # Set the default options
49
- # SimpleTableFor::Defaults.set id: 'id', class: 'class'
50
- def self.set(options)
51
- @defaults = defaults.merge options
52
- end
53
-
54
- private
55
- def self.defaults
56
- {id: '', class: ''}
57
- end
58
- end
59
- end
1
+ require_relative 'simple_table_for/defaults'
2
+ require_relative 'simple_table_for/rails'
3
+ require_relative 'simple_table_for/helpers'
60
4
 
61
5
  ActionView::Base.send :include, SimpleTableFor::Helpers if defined? ActionView::Base
@@ -21,6 +21,9 @@ module Dummy
21
21
 
22
22
  # Do not swallow errors in after_commit/after_rollback callbacks.
23
23
  config.active_record.raise_in_transactional_callbacks = true
24
+
25
+ config.simple_table_for.defaults = {
26
+ class: 'default-class'
27
+ }
24
28
  end
25
29
  end
26
-
Binary file
@@ -659,3 +659,341 @@ Processing by PostsController#index as HTML
659
659
  Rendered posts/defaults.html.erb within layouts/application (3.4ms)
660
660
  Completed 200 OK in 21ms (Views: 18.9ms | ActiveRecord: 1.6ms)
661
661
   (0.1ms) rollback transaction
662
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
663
+  (0.1ms) begin transaction
664
+ Fixture Delete (2.7ms) DELETE FROM "posts"
665
+ Fixture Insert (0.5ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-03-31 12:16:31', '2015-03-31 12:16:31', 980190962)
666
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-03-31 12:16:31', '2015-03-31 12:16:31', 298486374)
667
+  (3.0ms) commit transaction
668
+  (0.1ms) begin transaction
669
+ ---------------------------------------------
670
+ PostsControllerTest: test_should_render_table
671
+ ---------------------------------------------
672
+ Processing by PostsController#index as HTML
673
+ Parameters: {"template"=>"render"}
674
+ Post Load (1.3ms) SELECT "posts".* FROM "posts"
675
+ Rendered posts/render.html.erb within layouts/application (13.2ms)
676
+ Completed 200 OK in 127ms (Views: 125.5ms | ActiveRecord: 1.3ms)
677
+  (0.1ms) rollback transaction
678
+  (0.1ms) begin transaction
679
+ -----------------------------------------------------------
680
+ PostsControllerTest: test_should_render_table_with_defaults
681
+ -----------------------------------------------------------
682
+ Processing by PostsController#index as HTML
683
+ Parameters: {"template"=>"defaults"}
684
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
685
+ Rendered posts/defaults.html.erb within layouts/application (3.3ms)
686
+ Completed 200 OK in 21ms (Views: 18.6ms | ActiveRecord: 1.6ms)
687
+  (0.1ms) rollback transaction
688
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
689
+  (0.1ms) begin transaction
690
+ Fixture Delete (2.7ms) DELETE FROM "posts"
691
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:14:03', '2015-04-01 13:14:03', 980190962)
692
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:14:03', '2015-04-01 13:14:03', 298486374)
693
+  (3.7ms) commit transaction
694
+  (0.1ms) begin transaction
695
+ -----------------------------------------------------------
696
+ PostsControllerTest: test_should_render_table_with_defaults
697
+ -----------------------------------------------------------
698
+ Processing by PostsController#index as HTML
699
+ Parameters: {"template"=>"defaults"}
700
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
701
+ Rendered posts/defaults.html.erb within layouts/application (12.8ms)
702
+ Completed 200 OK in 160ms (Views: 158.4ms | ActiveRecord: 1.5ms)
703
+  (0.1ms) rollback transaction
704
+  (0.1ms) begin transaction
705
+ ---------------------------------------------
706
+ PostsControllerTest: test_should_render_table
707
+ ---------------------------------------------
708
+ Processing by PostsController#index as HTML
709
+ Parameters: {"template"=>"render"}
710
+ Post Load (1.3ms) SELECT "posts".* FROM "posts"
711
+ Rendered posts/render.html.erb within layouts/application (3.2ms)
712
+ Completed 200 OK in 21ms (Views: 18.9ms | ActiveRecord: 1.3ms)
713
+  (0.1ms) rollback transaction
714
+ ActiveRecord::SchemaMigration Load (1.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
715
+  (0.1ms) begin transaction
716
+ Fixture Delete (22.2ms) DELETE FROM "posts"
717
+ Fixture Insert (0.5ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:24:29', '2015-04-01 13:24:29', 980190962)
718
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:24:29', '2015-04-01 13:24:29', 298486374)
719
+  (3.1ms) commit transaction
720
+  (0.1ms) begin transaction
721
+ ---------------------------------------------
722
+ PostsControllerTest: test_should_render_table
723
+ ---------------------------------------------
724
+ Processing by PostsController#index as HTML
725
+ Parameters: {"template"=>"render"}
726
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
727
+ Rendered posts/render.html.erb within layouts/application (13.1ms)
728
+ Completed 200 OK in 148ms (Views: 146.5ms | ActiveRecord: 1.5ms)
729
+  (0.1ms) rollback transaction
730
+  (0.1ms) begin transaction
731
+ -----------------------------------------------------------
732
+ PostsControllerTest: test_should_render_table_with_defaults
733
+ -----------------------------------------------------------
734
+ Processing by PostsController#index as HTML
735
+ Parameters: {"template"=>"defaults"}
736
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
737
+ Rendered posts/defaults.html.erb within layouts/application (3.3ms)
738
+ Completed 200 OK in 20ms (Views: 18.8ms | ActiveRecord: 1.5ms)
739
+  (0.1ms) rollback transaction
740
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
741
+  (0.2ms) begin transaction
742
+ Fixture Delete (2.4ms) DELETE FROM "posts"
743
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:34:03', '2015-04-01 13:34:03', 980190962)
744
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:34:03', '2015-04-01 13:34:03', 298486374)
745
+  (2.9ms) commit transaction
746
+  (0.1ms) begin transaction
747
+ ---------------------------------------------
748
+ PostsControllerTest: test_should_render_table
749
+ ---------------------------------------------
750
+ Processing by PostsController#index as HTML
751
+ Parameters: {"template"=>"render"}
752
+ Post Load (1.7ms) SELECT "posts".* FROM "posts"
753
+ Rendered posts/render.html.erb within layouts/application (15.1ms)
754
+ Completed 200 OK in 142ms (Views: 139.8ms | ActiveRecord: 1.7ms)
755
+  (0.3ms) rollback transaction
756
+  (0.1ms) begin transaction
757
+ -----------------------------------------------------------
758
+ PostsControllerTest: test_should_render_table_with_defaults
759
+ -----------------------------------------------------------
760
+ Processing by PostsController#index as HTML
761
+ Parameters: {"template"=>"defaults"}
762
+ Post Load (1.9ms) SELECT "posts".* FROM "posts"
763
+ Rendered posts/defaults.html.erb within layouts/application (4.0ms)
764
+ Completed 200 OK in 24ms (Views: 22.2ms | ActiveRecord: 1.9ms)
765
+  (0.1ms) rollback transaction
766
+ ActiveRecord::SchemaMigration Load (2.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
767
+  (0.1ms) begin transaction
768
+ Fixture Delete (2.4ms) DELETE FROM "posts"
769
+ Fixture Insert (0.5ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:34:41', '2015-04-01 13:34:41', 980190962)
770
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:34:41', '2015-04-01 13:34:41', 298486374)
771
+  (3.0ms) commit transaction
772
+  (0.1ms) begin transaction
773
+ -----------------------------------------------------------
774
+ PostsControllerTest: test_should_render_table_with_defaults
775
+ -----------------------------------------------------------
776
+ Processing by PostsController#index as HTML
777
+ Parameters: {"template"=>"defaults"}
778
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
779
+ Rendered posts/defaults.html.erb within layouts/application (13.5ms)
780
+ Completed 200 OK in 134ms (Views: 132.2ms | ActiveRecord: 1.6ms)
781
+  (0.1ms) rollback transaction
782
+  (0.3ms) begin transaction
783
+ ---------------------------------------------
784
+ PostsControllerTest: test_should_render_table
785
+ ---------------------------------------------
786
+ Processing by PostsController#index as HTML
787
+ Parameters: {"template"=>"render"}
788
+ Post Load (1.9ms) SELECT "posts".* FROM "posts"
789
+ Rendered posts/render.html.erb within layouts/application (4.5ms)
790
+ Completed 200 OK in 25ms (Views: 23.1ms | ActiveRecord: 1.9ms)
791
+  (0.1ms) rollback transaction
792
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
793
+  (0.2ms) begin transaction
794
+ Fixture Delete (2.7ms) DELETE FROM "posts"
795
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:36:39', '2015-04-01 13:36:39', 980190962)
796
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:36:39', '2015-04-01 13:36:39', 298486374)
797
+  (3.0ms) commit transaction
798
+  (0.1ms) begin transaction
799
+ -----------------------------------------------------------
800
+ PostsControllerTest: test_should_render_table_with_defaults
801
+ -----------------------------------------------------------
802
+ Processing by PostsController#index as HTML
803
+ Parameters: {"template"=>"defaults"}
804
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
805
+ Rendered posts/defaults.html.erb within layouts/application (13.1ms)
806
+ Completed 200 OK in 123ms (Views: 121.5ms | ActiveRecord: 1.5ms)
807
+  (0.1ms) rollback transaction
808
+  (0.1ms) begin transaction
809
+ ---------------------------------------------
810
+ PostsControllerTest: test_should_render_table
811
+ ---------------------------------------------
812
+ Processing by PostsController#index as HTML
813
+ Parameters: {"template"=>"render"}
814
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
815
+ Rendered posts/render.html.erb within layouts/application (3.4ms)
816
+ Completed 200 OK in 22ms (Views: 19.7ms | ActiveRecord: 1.6ms)
817
+  (0.1ms) rollback transaction
818
+ ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
819
+  (0.2ms) begin transaction
820
+ Fixture Delete (2.4ms) DELETE FROM "posts"
821
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:37:47', '2015-04-01 13:37:47', 980190962)
822
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:37:47', '2015-04-01 13:37:47', 298486374)
823
+  (3.5ms) commit transaction
824
+  (0.1ms) begin transaction
825
+ ---------------------------------------------
826
+ PostsControllerTest: test_should_render_table
827
+ ---------------------------------------------
828
+ Processing by PostsController#index as HTML
829
+ Parameters: {"template"=>"render"}
830
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
831
+ Rendered posts/render.html.erb within layouts/application (13.6ms)
832
+ Completed 200 OK in 128ms (Views: 126.2ms | ActiveRecord: 1.5ms)
833
+  (0.1ms) rollback transaction
834
+  (0.1ms) begin transaction
835
+ -----------------------------------------------------------
836
+ PostsControllerTest: test_should_render_table_with_defaults
837
+ -----------------------------------------------------------
838
+ Processing by PostsController#index as HTML
839
+ Parameters: {"template"=>"defaults"}
840
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
841
+ Rendered posts/defaults.html.erb within layouts/application (4.1ms)
842
+ Completed 200 OK in 22ms (Views: 20.2ms | ActiveRecord: 1.6ms)
843
+  (0.1ms) rollback transaction
844
+ ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
845
+  (0.2ms) begin transaction
846
+ Fixture Delete (18.7ms) DELETE FROM "posts"
847
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:38:46', '2015-04-01 13:38:46', 980190962)
848
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:38:46', '2015-04-01 13:38:46', 298486374)
849
+  (3.0ms) commit transaction
850
+  (0.1ms) begin transaction
851
+ ---------------------------------------------
852
+ PostsControllerTest: test_should_render_table
853
+ ---------------------------------------------
854
+ Processing by PostsController#index as HTML
855
+ Parameters: {"template"=>"render"}
856
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
857
+ Rendered posts/render.html.erb within layouts/application (13.6ms)
858
+ Completed 200 OK in 124ms (Views: 122.0ms | ActiveRecord: 1.6ms)
859
+  (0.1ms) rollback transaction
860
+  (0.2ms) begin transaction
861
+ -----------------------------------------------------------
862
+ PostsControllerTest: test_should_render_table_with_defaults
863
+ -----------------------------------------------------------
864
+ Processing by PostsController#index as HTML
865
+ Parameters: {"template"=>"defaults"}
866
+ Post Load (1.8ms) SELECT "posts".* FROM "posts"
867
+ Rendered posts/defaults.html.erb within layouts/application (3.6ms)
868
+ Completed 200 OK in 21ms (Views: 19.2ms | ActiveRecord: 1.8ms)
869
+  (0.1ms) rollback transaction
870
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
871
+  (0.1ms) begin transaction
872
+ Fixture Delete (2.9ms) DELETE FROM "posts"
873
+ Fixture Insert (0.7ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:41:33', '2015-04-01 13:41:33', 980190962)
874
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:41:33', '2015-04-01 13:41:33', 298486374)
875
+  (3.4ms) commit transaction
876
+  (0.1ms) begin transaction
877
+ ---------------------------------------------
878
+ PostsControllerTest: test_should_render_table
879
+ ---------------------------------------------
880
+ Processing by PostsController#index as HTML
881
+ Parameters: {"template"=>"render"}
882
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
883
+ Rendered posts/render.html.erb within layouts/application (12.6ms)
884
+ Completed 200 OK in 122ms (Views: 120.1ms | ActiveRecord: 1.5ms)
885
+  (0.1ms) rollback transaction
886
+  (0.1ms) begin transaction
887
+ -----------------------------------------------------------
888
+ PostsControllerTest: test_should_render_table_with_defaults
889
+ -----------------------------------------------------------
890
+ Processing by PostsController#index as HTML
891
+ Parameters: {"template"=>"defaults"}
892
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
893
+ Rendered posts/defaults.html.erb within layouts/application (3.5ms)
894
+ Completed 200 OK in 22ms (Views: 20.0ms | ActiveRecord: 1.6ms)
895
+  (0.0ms) rollback transaction
896
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
897
+  (0.1ms) begin transaction
898
+ Fixture Delete (2.7ms) DELETE FROM "posts"
899
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:45:49', '2015-04-01 13:45:49', 980190962)
900
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:45:49', '2015-04-01 13:45:49', 298486374)
901
+  (3.0ms) commit transaction
902
+  (0.1ms) begin transaction
903
+ ---------------------------------------------
904
+ PostsControllerTest: test_should_render_table
905
+ ---------------------------------------------
906
+ Processing by PostsController#index as HTML
907
+ Parameters: {"template"=>"render"}
908
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
909
+ Rendered posts/render.html.erb within layouts/application (12.8ms)
910
+ Completed 200 OK in 124ms (Views: 121.8ms | ActiveRecord: 1.6ms)
911
+  (0.1ms) rollback transaction
912
+  (0.1ms) begin transaction
913
+ -----------------------------------------------------------------------------------
914
+ PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
915
+ -----------------------------------------------------------------------------------
916
+ Processing by PostsController#index as HTML
917
+ Parameters: {"template"=>"defaults"}
918
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
919
+ Rendered posts/defaults.html.erb within layouts/application (3.5ms)
920
+ Completed 200 OK in 22ms (Views: 20.5ms | ActiveRecord: 1.6ms)
921
+  (0.1ms) rollback transaction
922
+ ActiveRecord::SchemaMigration Load (1.8ms) SELECT "schema_migrations".* FROM "schema_migrations"
923
+  (0.1ms) begin transaction
924
+ Fixture Delete (2.5ms) DELETE FROM "posts"
925
+ Fixture Insert (0.7ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:49:05', '2015-04-01 13:49:05', 980190962)
926
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:49:05', '2015-04-01 13:49:05', 298486374)
927
+  (3.6ms) commit transaction
928
+  (0.1ms) begin transaction
929
+ ---------------------------------------------
930
+ PostsControllerTest: test_should_render_table
931
+ ---------------------------------------------
932
+ Processing by PostsController#index as HTML
933
+ Parameters: {"template"=>"render"}
934
+ Post Load (1.7ms) SELECT "posts".* FROM "posts"
935
+ Rendered posts/render.html.erb within layouts/application (13.1ms)
936
+ Completed 200 OK in 125ms (Views: 122.4ms | ActiveRecord: 1.7ms)
937
+  (0.1ms) rollback transaction
938
+  (0.2ms) begin transaction
939
+ -----------------------------------------------------------------------------------
940
+ PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
941
+ -----------------------------------------------------------------------------------
942
+ Processing by PostsController#index as HTML
943
+ Parameters: {"template"=>"defaults"}
944
+ Post Load (1.7ms) SELECT "posts".* FROM "posts"
945
+ Rendered posts/defaults.html.erb within layouts/application (3.5ms)
946
+ Completed 200 OK in 21ms (Views: 18.8ms | ActiveRecord: 1.7ms)
947
+  (0.1ms) rollback transaction
948
+ ActiveRecord::SchemaMigration Load (1.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
949
+  (0.3ms) begin transaction
950
+ Fixture Delete (3.3ms) DELETE FROM "posts"
951
+ Fixture Insert (0.7ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:55:37', '2015-04-01 13:55:37', 980190962)
952
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 13:55:37', '2015-04-01 13:55:37', 298486374)
953
+  (3.9ms) commit transaction
954
+  (0.1ms) begin transaction
955
+ -----------------------------------------------------------------------------------
956
+ PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
957
+ -----------------------------------------------------------------------------------
958
+ Processing by PostsController#index as HTML
959
+ Parameters: {"template"=>"defaults"}
960
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
961
+ Rendered posts/defaults.html.erb within layouts/application (13.2ms)
962
+ Completed 200 OK in 144ms (Views: 141.6ms | ActiveRecord: 1.6ms)
963
+  (0.1ms) rollback transaction
964
+  (0.1ms) begin transaction
965
+ ---------------------------------------------
966
+ PostsControllerTest: test_should_render_table
967
+ ---------------------------------------------
968
+ Processing by PostsController#index as HTML
969
+ Parameters: {"template"=>"render"}
970
+ Post Load (1.7ms) SELECT "posts".* FROM "posts"
971
+ Rendered posts/render.html.erb within layouts/application (3.6ms)
972
+ Completed 200 OK in 22ms (Views: 20.4ms | ActiveRecord: 1.7ms)
973
+  (0.1ms) rollback transaction
974
+ ActiveRecord::SchemaMigration Load (1.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
975
+  (0.2ms) begin transaction
976
+ Fixture Delete (2.5ms) DELETE FROM "posts"
977
+ Fixture Insert (0.6ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 14:07:36', '2015-04-01 14:07:36', 980190962)
978
+ Fixture Insert (0.1ms) INSERT INTO "posts" ("title", "text", "created_at", "updated_at", "id") VALUES ('MyString', 'MyText', '2015-04-01 14:07:36', '2015-04-01 14:07:36', 298486374)
979
+  (3.2ms) commit transaction
980
+  (0.1ms) begin transaction
981
+ ---------------------------------------------
982
+ PostsControllerTest: test_should_render_table
983
+ ---------------------------------------------
984
+ Processing by PostsController#index as HTML
985
+ Parameters: {"template"=>"render"}
986
+ Post Load (1.5ms) SELECT "posts".* FROM "posts"
987
+ Rendered posts/render.html.erb within layouts/application (13.2ms)
988
+ Completed 200 OK in 123ms (Views: 120.6ms | ActiveRecord: 1.5ms)
989
+  (0.1ms) rollback transaction
990
+  (0.3ms) begin transaction
991
+ -----------------------------------------------------------------------------------
992
+ PostsControllerTest: test_should_render_table_with_defaults_(set_in_application.rb)
993
+ -----------------------------------------------------------------------------------
994
+ Processing by PostsController#index as HTML
995
+ Parameters: {"template"=>"defaults"}
996
+ Post Load (1.6ms) SELECT "posts".* FROM "posts"
997
+ Rendered posts/defaults.html.erb within layouts/application (3.4ms)
998
+ Completed 200 OK in 25ms (Views: 23.1ms | ActiveRecord: 1.6ms)
999
+  (0.1ms) rollback transaction
@@ -21,13 +21,10 @@ class PostsControllerTest < ActionController::TestCase
21
21
  end
22
22
  end
23
23
 
24
- test 'should render table with defaults' do
25
- old_defaults = SimpleTableFor::Defaults.get
26
- SimpleTableFor::Defaults.set({id: 'default-id', class: 'default-class'})
27
-
24
+ test 'should render table with defaults (set in application.rb)' do
28
25
  get :index, template: :defaults
29
26
 
30
- assert_select 'table#default-id.default-class' do
27
+ assert_select 'table.default-class' do
31
28
  assert_select 'thead' do
32
29
  assert_select 'tr' do
33
30
  assert_select 'th'
@@ -40,7 +37,5 @@ class PostsControllerTest < ActionController::TestCase
40
37
  end
41
38
  end
42
39
  end
43
-
44
- SimpleTableFor::Defaults.set old_defaults
45
40
  end
46
41
  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.1.1
4
+ version: 0.2.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-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -49,6 +49,9 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - lib/simple_table_for.rb
52
+ - lib/simple_table_for/defaults.rb
53
+ - lib/simple_table_for/helpers.rb
54
+ - lib/simple_table_for/rails.rb
52
55
  - lib/simple_table_for/version.rb
53
56
  - lib/tasks/simple_table_for_tasks.rake
54
57
  - test/dummy/README.rdoc