typus 3.0.11 → 3.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. data/README.md +4 -1
  2. data/app/helpers/admin/relationships_helper.rb +2 -2
  3. data/app/views/admin/dashboard/_applications.html.erb +1 -1
  4. data/app/views/admin/helpers/resources/_errors.html.erb +1 -1
  5. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +1 -1
  6. data/app/views/admin/resources/index.html.erb +2 -2
  7. data/app/views/admin/templates/_has_n.html.erb +1 -1
  8. data/app/views/admin/templates/_has_one.html.erb +1 -1
  9. data/config/locales/typus.ca.yml +1 -1
  10. data/config/locales/typus.de.models.yml +6 -5
  11. data/config/locales/typus.de.yml +39 -36
  12. data/config/locales/typus.el.yml +1 -1
  13. data/config/locales/typus.es.yml +1 -1
  14. data/config/locales/typus.fr.yml +1 -1
  15. data/config/locales/typus.hu.yml +1 -1
  16. data/config/locales/typus.locale.yml.template +1 -1
  17. data/config/locales/typus.pt-BR.yml +1 -1
  18. data/config/locales/typus.pt-PT.yml +1 -1
  19. data/config/locales/typus.ru.yml +1 -1
  20. data/config/locales/typus.zh-CN.yml +1 -1
  21. data/lib/typus/version.rb +1 -1
  22. data/typus.gemspec +7 -4
  23. metadata +16 -164
  24. data/test/app/controllers/admin/account_controller_test.rb +0 -106
  25. data/test/app/controllers/admin/assets_controller_test.rb +0 -156
  26. data/test/app/controllers/admin/base_controller_test.rb +0 -41
  27. data/test/app/controllers/admin/birds_controller_test.rb +0 -42
  28. data/test/app/controllers/admin/cases_controller_test.rb +0 -21
  29. data/test/app/controllers/admin/categories_controller_test.rb +0 -134
  30. data/test/app/controllers/admin/comments_controller_test.rb +0 -79
  31. data/test/app/controllers/admin/dashboard_controller_test.rb +0 -162
  32. data/test/app/controllers/admin/image_holders_controller_test.rb +0 -75
  33. data/test/app/controllers/admin/invoices_controller_test.rb +0 -78
  34. data/test/app/controllers/admin/orders_controller_test.rb +0 -18
  35. data/test/app/controllers/admin/pages_controller_test.rb +0 -37
  36. data/test/app/controllers/admin/posts_controller_test.rb +0 -770
  37. data/test/app/controllers/admin/projects_controller_test.rb +0 -52
  38. data/test/app/controllers/admin/session_controller_test.rb +0 -92
  39. data/test/app/controllers/admin/status_controller_test.rb +0 -54
  40. data/test/app/controllers/admin/typus_users_controller_test.rb +0 -156
  41. data/test/app/controllers/admin/users_controller_test.rb +0 -106
  42. data/test/app/controllers/admin/views_controller_test.rb +0 -36
  43. data/test/app/helpers/admin/base_helper_test.rb +0 -83
  44. data/test/app/helpers/admin/dashboard_helper_test.rb +0 -32
  45. data/test/app/helpers/admin/file_preview_helper_test.rb +0 -90
  46. data/test/app/helpers/admin/filters_helper_test.rb +0 -166
  47. data/test/app/helpers/admin/form_helper_test.rb +0 -126
  48. data/test/app/helpers/admin/list_helper_test.rb +0 -76
  49. data/test/app/helpers/admin/relationships_helper_test.rb +0 -19
  50. data/test/app/helpers/admin/resources_helper_test.rb +0 -46
  51. data/test/app/helpers/admin/search_helper_test.rb +0 -60
  52. data/test/app/helpers/admin/sidebar_helper_test.rb +0 -34
  53. data/test/app/helpers/admin/table_helper_test.rb +0 -241
  54. data/test/app/mailers/admin/mailer_test.rb +0 -32
  55. data/test/app/models/admin_user_test.rb +0 -5
  56. data/test/app/models/typus_user_roles_test.rb +0 -125
  57. data/test/app/models/typus_user_test.rb +0 -228
  58. data/test/config/routes_test.rb +0 -29
  59. data/test/factories.rb +0 -122
  60. data/test/fixtures/config/broken/application.yml +0 -68
  61. data/test/fixtures/config/broken/application_roles.yml +0 -20
  62. data/test/fixtures/config/broken/empty.yml +0 -0
  63. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  64. data/test/fixtures/config/broken/undefined.yml +0 -3
  65. data/test/fixtures/config/broken/undefined_roles.yml +0 -6
  66. data/test/fixtures/config/default/typus.yml +0 -13
  67. data/test/fixtures/config/default/typus_roles.yml +0 -2
  68. data/test/fixtures/config/empty/empty_01.yml +0 -0
  69. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  70. data/test/fixtures/config/empty/empty_02.yml +0 -0
  71. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  72. data/test/fixtures/config/locales/es.yml +0 -10
  73. data/test/fixtures/config/namespaced/application.yml +0 -5
  74. data/test/fixtures/config/namespaced/application_roles.yml +0 -2
  75. data/test/fixtures/config/ordered/001_roles.yml +0 -2
  76. data/test/fixtures/config/ordered/002_roles.yml +0 -2
  77. data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
  78. data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
  79. data/test/lib/support/active_record_test.rb +0 -174
  80. data/test/lib/support/fake_user_test.rb +0 -63
  81. data/test/lib/support/hash_test.rb +0 -29
  82. data/test/lib/support/object_test.rb +0 -17
  83. data/test/lib/support/string_test.rb +0 -98
  84. data/test/lib/typus/configuration_test.rb +0 -46
  85. data/test/lib/typus/controller/actions_test.rb +0 -141
  86. data/test/lib/typus/controller/associations_test.rb +0 -7
  87. data/test/lib/typus/controller/autocomplete_test.rb +0 -7
  88. data/test/lib/typus/controller/filters_test.rb +0 -73
  89. data/test/lib/typus/controller/format_test.rb +0 -7
  90. data/test/lib/typus/i18n_test.rb +0 -9
  91. data/test/lib/typus/orm/active_record/class_methods_test.rb +0 -390
  92. data/test/lib/typus/orm/active_record/search_test.rb +0 -330
  93. data/test/lib/typus/regex_test.rb +0 -53
  94. data/test/lib/typus/resources_test.rb +0 -41
  95. data/test/lib/typus_test.rb +0 -142
  96. data/test/test_helper.rb +0 -15
@@ -1,36 +0,0 @@
1
- require "test_helper"
2
-
3
- =begin
4
-
5
- What's being tested here?
6
-
7
- - `set_context` which forces the display of items related to domain.
8
-
9
- =end
10
-
11
- class Admin::ViewsControllerTest < ActionController::TestCase
12
-
13
- setup do
14
- @request.session[:typus_user_id] = Factory(:typus_user).id
15
- @site = Factory(:site, :domain => 'test.host')
16
- view = Factory(:view, :site => @site)
17
- view = Factory(:view)
18
- end
19
-
20
- teardown do
21
- @request.session[:typus_user_id] = nil
22
- end
23
-
24
- test "get :index returns only views on the current_context" do
25
- get :index
26
- assert_response :success
27
- assert_equal [@site.id], assigns(:items).map(&:site_id)
28
- end
29
-
30
- test "get :new should initialize item in the current_scope" do
31
- get :new
32
- assert_response :success
33
- assert assigns(:item).site_id.eql?(@site.id)
34
- end
35
-
36
- end
@@ -1,83 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::BaseHelperTest < ActiveSupport::TestCase
4
-
5
- include Admin::BaseHelper
6
-
7
- include ActionView::Helpers::UrlHelper
8
- include ActionView::Helpers::TextHelper
9
-
10
- def render(*args); args; end
11
-
12
- context "login info" do
13
-
14
- setup do
15
- admin_user = mock
16
- self.stubs(:admin_user).returns(admin_user)
17
- admin_user.stubs(:name).returns("Admin")
18
- admin_user.stubs(:id).returns(1)
19
- end
20
-
21
- should "skip rendering when we're using a fake user" do
22
- admin_user.stubs(:is_a?).with(FakeUser).returns(true)
23
- output = login_info
24
- assert_nil output
25
- end
26
-
27
- context "when the current user is not a FakeUser" do
28
-
29
- setup do
30
- admin_user.stubs(:is_a?).with(FakeUser).returns(false)
31
- end
32
-
33
- context "when the user cannot edit his informations" do
34
-
35
- should "render a partial with the user name" do
36
- admin_user.stubs(:can?).with('edit', 'TypusUser').returns(false)
37
- assert_equal ["admin/helpers/base/login_info"], login_info
38
- end
39
-
40
- end
41
-
42
- context "when the user can edit his informations" do
43
-
44
- should "render a partial with a link" do
45
- link_options = { :action => 'edit', :controller => '/admin/typus_users', :id => 1 }
46
-
47
- admin_user.stubs(:can?).with('edit', 'TypusUser').returns(true)
48
- self.stubs(:link_to).with("Admin", link_options).returns(%(<a href="/admin/typus_users/edit/1">Admin</a>))
49
-
50
- assert_equal ["admin/helpers/base/login_info"], login_info
51
- end
52
-
53
- end
54
-
55
- end
56
-
57
- end
58
-
59
- context "header" do
60
-
61
- should "work returning a partial" do
62
- assert_equal ["admin/helpers/base/header"], header
63
- end
64
-
65
- end
66
-
67
- context "display_flash_message" do
68
-
69
- should "be displayed" do
70
- message = { :test => "This is the message." }
71
- output = display_flash_message(message)
72
- expected = ["admin/helpers/base/flash_message",
73
- { :flash_type => :test, :message => { :test => "This is the message." } }]
74
- assert_equal expected, output
75
- end
76
-
77
- should "not be displayed when message is empty" do
78
- assert_nil display_flash_message(Hash.new)
79
- end
80
-
81
- end
82
-
83
- end
@@ -1,32 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::DashboardHelperTest < ActiveSupport::TestCase
4
-
5
- include Admin::DashboardHelper
6
-
7
- include ActionView::Helpers::UrlHelper
8
- include ActionView::Helpers::TextHelper
9
-
10
- def render(*args); args; end
11
-
12
- context "resources" do
13
-
14
- setup do
15
- @expected = ["admin/helpers/dashboard/resources", { :resources => ["Git", "Status", "WatchDog"] }]
16
- end
17
-
18
- should "work for typus_user" do
19
- admin_user = Factory(:typus_user)
20
- output = resources(admin_user)
21
- assert_equal @expected, output
22
- end
23
-
24
- should "work for fake_user" do
25
- admin_user = FakeUser.new
26
- output = resources(admin_user)
27
- assert_equal @expected, output
28
- end
29
-
30
- end
31
-
32
- end
@@ -1,90 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::FilePreviewHelperTest < ActiveSupport::TestCase
4
-
5
- include Admin::FilePreviewHelper
6
-
7
- context "get_type_of_attachment" do
8
-
9
- setup do
10
- @asset = Factory(:asset)
11
- end
12
-
13
- should "return :dragonfly" do
14
- assert_equal :dragonfly, get_type_of_attachment(@asset.dragonfly)
15
- end
16
-
17
- should "return :paperclip" do
18
- assert_equal :paperclip, get_type_of_attachment(@asset.paperclip)
19
- end
20
-
21
- end
22
-
23
- context "link_to_detach_attribute" do
24
-
25
- setup do
26
- @asset = @item = Factory(:asset)
27
- end
28
-
29
- should "work for :dragonfly_required and return nil when attribute is required" do
30
- assert_nil link_to_detach_attribute('dragonfly_required')
31
- end
32
-
33
- should "work for :paperclip_required and return nil when attribute is required" do
34
- assert_nil link_to_detach_attribute('paperclip_required')
35
- end
36
-
37
- should "work for :dragonfly and return link when attribute is not required" do
38
- assert_match /Remove/, link_to_detach_attribute('dragonfly')
39
- end
40
-
41
- should "work for :paperclip_required and return link when attribute is not required" do
42
- assert_match /Remove/, link_to_detach_attribute('paperclip')
43
- end
44
-
45
- end
46
-
47
- context "typus_file_preview_for_dragonfly" do
48
-
49
- should "return link for non image files" do
50
- file = File.new("#{Rails.root}/config/database.yml")
51
- @asset = Factory(:asset, :dragonfly => file)
52
- assert_equal @asset.dragonfly.name, typus_file_preview_for_dragonfly(@asset.dragonfly).first
53
- assert_match /media/, typus_file_preview_for_dragonfly(@asset.dragonfly).last
54
- end
55
-
56
- should "return image and link for image files" do
57
- @asset = Factory(:asset)
58
- assert_equal "admin/helpers/file_preview", typus_file_preview_for_dragonfly(@asset.dragonfly).first
59
- assert_match /media/, typus_file_preview_for_dragonfly(@asset.dragonfly).last[:preview]
60
- assert_match /media/, typus_file_preview_for_dragonfly(@asset.dragonfly).last[:thumb]
61
- end
62
-
63
- end
64
-
65
- context "typus_file_preview_for_paperclip" do
66
-
67
- setup do
68
- @asset = Factory(:asset)
69
- end
70
-
71
- should "return link for non image files" do
72
- Typus.expects(:file_preview).at_least_once.returns(nil)
73
- assert_equal "rails.png", typus_file_preview_for_paperclip(@asset.paperclip).first
74
- assert_equal "/system/paperclips/#{@asset.id}/original/rails.png", typus_file_preview_for_paperclip(@asset.paperclip).last
75
- end
76
-
77
- should "return image and link for image files" do
78
- expected = ["admin/helpers/file_preview",
79
- {:preview => "/system/paperclips/#{@asset.id}/medium/rails.png",
80
- :thumb => "/system/paperclips/#{@asset.id}/thumb/rails.png",
81
- :options=>{}}]
82
- assert_equal expected, typus_file_preview_for_paperclip(@asset.paperclip)
83
- end
84
-
85
- end
86
-
87
- def link_to(*args); args; end
88
- def render(*args); args; end
89
-
90
- end
@@ -1,166 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require "test_helper"
4
-
5
- class Admin::FiltersHelperTest < ActiveSupport::TestCase
6
-
7
- include Admin::FiltersHelper
8
-
9
- def render(*args); args; end
10
-
11
- context "build_filters" do
12
-
13
- # FIXME: Should work without this ...
14
- setup do
15
- @resource = Entry
16
- @expected = ["admin/helpers/filters/filters",
17
- {:filters=>[{:filter=>"published",
18
- :items=>[["Show by published", ""], ["Yes", "true"], ["No", "false"]]}],
19
- :hidden_filters=>{}}]
20
- end
21
-
22
- should "reject controller and action params" do
23
- parameters = {"controller"=>"admin/posts", "action"=>"index"}
24
- assert_equal @expected, build_filters(Entry, parameters)
25
- end
26
-
27
- # TODO: I want to think about it ...
28
- should "reject locale params" do
29
- parameters = {"locale"=>"jp"}
30
- assert_equal @expected, build_filters(Entry, parameters)
31
- end
32
-
33
- # TODO: I want to think about it ...
34
- should "reject to sort_order and order_by" do
35
- parameters = {"sort_order"=>"asc", "order_by"=>"title"}
36
- assert_equal @expected, build_filters(Entry, parameters)
37
- end
38
-
39
- should "reject the utf8 param because the form already contains it" do
40
- parameters = {"utf8"=>"✓"}
41
- assert_equal @expected, build_filters(Entry, parameters)
42
- end
43
-
44
- should "not reject the search param" do
45
- parameters = {"search"=>"Chunky Bacon"}
46
-
47
- expected = ["admin/helpers/filters/filters",
48
- {:filters=>[{:filter=>"published",
49
- :items=>[["Show by published", ""], ["Yes", "true"], ["No", "false"]]}],
50
- :hidden_filters=>{"search"=>"Chunky Bacon"}}]
51
-
52
- assert_equal expected, build_filters(Entry, parameters)
53
- end
54
-
55
- should "not reject applied filters" do
56
- parameters = {"user_id"=>"1"}
57
-
58
- expected = ["admin/helpers/filters/filters",
59
- {:filters=>[{:filter=>"published",
60
- :items=>[["Show by published", ""], ["Yes", "true"], ["No", "false"]]}],
61
- :hidden_filters=>{"user_id"=>"1"}}]
62
-
63
- assert_equal expected, build_filters(Entry, parameters)
64
- end
65
-
66
- should "reject applied filter" do
67
- parameters = {"published"=>"true"}
68
-
69
- expected = ["admin/helpers/filters/filters",
70
- {:filters=>[{:filter=>"published",
71
- :items=>[["Show by published", ""], ["Yes", "true"], ["No", "false"]]}],
72
- :hidden_filters=>{}}]
73
-
74
- assert_equal expected, build_filters(Entry, parameters)
75
- end
76
-
77
- end
78
-
79
- should "relationship_filter"
80
-
81
- context "date_filter" do
82
-
83
- should "return an array" do
84
- output = date_filter("filter")
85
- expected = [["Show all dates", ""],
86
- ["Today", "today"],
87
- ["Last few days", "last_few_days"],
88
- ["Last 7 days", "last_7_days"],
89
- ["Last 30 days", "last_30_days"]]
90
- assert_equal expected, output
91
- end
92
-
93
- end
94
-
95
- context "boolean_filter" do
96
-
97
- setup do
98
- @resource = Post
99
- end
100
-
101
- should "return an array" do
102
- output = boolean_filter("filter")
103
- expected = [["Show by filter", ""],
104
- ["True", "true"],
105
- ["False", "false"]]
106
- assert_equal expected, output
107
- end
108
-
109
- end
110
-
111
- context "string_filter" do
112
-
113
- setup do
114
- @resource = Post
115
- end
116
-
117
- # This hack has to be removed!
118
- def set_context
119
- Post
120
- end
121
-
122
- should "return an array from status which is a Hash" do
123
- output = string_filter("status")
124
- expected = [["Show by status", ""],
125
- ["Unpublished", "unpublished"],
126
- ["<div class=''>Something special</div>", "special"],
127
- ["Draft", "draft"],
128
- ["Published", "published"]]
129
-
130
- expected.each { |e| assert output.include?(e) }
131
- end
132
-
133
- should "return an array from an ARRAY_SELECTOR" do
134
- output = string_filter("array_selector")
135
- expected = [["Show by array selector", ""],
136
- ["item1", "item1"],
137
- ["item2", "item2"]]
138
- assert_equal expected, output
139
- end
140
-
141
- should "return an array from an ARRAY_HASH_SELECTOR" do
142
- output = string_filter("array_hash_selector")
143
- expected = [["Show by array hash selector", ""],
144
- ["Draft", "draft"],
145
- ["Custom Status", "custom"]]
146
- assert_equal expected, output
147
- end
148
-
149
- end
150
-
151
- context "predefined_filters" do
152
-
153
- should "be empty" do
154
- assert predefined_filters.empty?
155
- end
156
-
157
- should "return my filter" do
158
- @predefined_filters = "mock"
159
- assert_equal "mock", predefined_filters
160
- end
161
-
162
- end
163
-
164
- def link_to(*args); args; end
165
-
166
- end
@@ -1,126 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::FormHelperTest < ActiveSupport::TestCase
4
-
5
- include Admin::FormHelper
6
- include Admin::ResourcesHelper
7
-
8
- should_eventually "verify_belongs_to_field" do
9
-
10
- params = { :controller => '/admin/post', :id => 1, :action => :create }
11
- self.stubs(:params).returns(params)
12
-
13
- admin_user = mock
14
- admin_user.stubs(:can?).with('create', Post).returns(false)
15
- @resource = Comment
16
-
17
- expected = <<-HTML
18
- <li><label for="comment_post">Post
19
- <small></small>
20
- </label>
21
- <select id="comment_post_id" name="comment[post_id]"><option value=""></option>
22
- <option value="3">Post#3</option>
23
- <option value="4">Post#4</option>
24
- <option value="1">Post#1</option>
25
- <option value="2">Post#2</option></select></li>
26
- HTML
27
-
28
- assert_equal expected, typus_belongs_to_field('post')
29
-
30
- end
31
-
32
- should_eventually "test_typus_belongs_to_field_with_different_attribute_name" do
33
-
34
- params = { :controller => '/admin/post', :id => 1, :action => :edit }
35
- self.stubs(:params).returns(params)
36
-
37
- admin_user = mock
38
- admin_user.stubs(:can?).with('create', Comment).returns(true)
39
- @resource = Post
40
-
41
- expected = <<-HTML
42
- <li><label for="post_favorite_comment">Favorite comment
43
- <small><a href="http://test.host/admin/comments/new?back_to=%2Fadmin%2Fpost%2Fedit%2F1&selected=favorite_comment_id" onclick="return confirm('Are you sure you want to leave this page?\\n\\nIf you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost.\\n\\nClick OK to continue, or click Cancel to stay on this page.');">Add</a></small>
44
- </label>
45
- <select id="post_favorite_comment_id" name="post[favorite_comment_id]"><option value=""></option>
46
- <option value="1">John</option>
47
- <option value="2">Me</option>
48
- <option value="3">John</option>
49
- <option value="4">Me</option></select></li>
50
- HTML
51
-
52
- assert_equal expected, typus_belongs_to_field('favorite_comment')
53
-
54
- end
55
-
56
- should_eventually "test_typus_tree_field" do
57
-
58
- self.stubs(:expand_tree_into_select_field).returns('expand_tree_into_select_field')
59
-
60
- @resource = Page
61
-
62
- expected = <<-HTML
63
- <li><label for="page_parent">Parent</label>
64
- <select id="page_parent" name="page[parent]">
65
- <option value=""></option>
66
- expand_tree_into_select_field
67
- </select></li>
68
- HTML
69
-
70
- assert_equal expected, typus_tree_field('parent')
71
-
72
- end
73
-
74
- context "attribute_disabled?" do
75
-
76
- setup do
77
- @resource = Post
78
- end
79
-
80
- should "work for non protected_attributes" do
81
- assert !attribute_disabled?('test')
82
- end
83
-
84
- should "work for protected_attributes" do
85
- Post.expects(:protected_attributes).returns(['test'])
86
- assert attribute_disabled?('test')
87
- end
88
-
89
- end
90
-
91
- context "expand_tree_into_select_field" do
92
-
93
- setup do
94
- @page = Factory(:page)
95
- @children = Factory(:page, :parent => @page)
96
- @subchildren = Factory(:page, :parent => @children)
97
- @items = Page.roots
98
- end
99
-
100
- should "verify it works" do
101
- @item = Page.first
102
-
103
- expected = <<-HTML
104
- <option value="#{@page.id}"> #{@page.to_label}</option>
105
- <option value="#{@children.id}">&nbsp;&nbsp; #{@children.to_label}</option>
106
- <option value="#{@subchildren.id}">&nbsp;&nbsp;&nbsp;&nbsp; #{@subchildren.to_label}</option>
107
- HTML
108
-
109
- assert_equal expected, expand_tree_into_select_field(@items, 'parent_id')
110
- end
111
-
112
- should "verify if selects an item" do
113
- @item = Page.last
114
-
115
- expected = <<-HTML
116
- <option value="#{@page.id}"> #{@page.to_label}</option>
117
- <option selected value="#{@children.id}">&nbsp;&nbsp; #{@children.to_label}</option>
118
- <option value="#{@subchildren.id}">&nbsp;&nbsp;&nbsp;&nbsp; #{@subchildren.to_label}</option>
119
- HTML
120
-
121
- assert_equal expected, expand_tree_into_select_field(@items, 'parent_id')
122
- end
123
-
124
- end
125
-
126
- end