typus 3.0.11 → 3.0.12

Sign up to get free protection for your applications and to get access to all the features.
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,32 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::MailerTest < ActiveSupport::TestCase
4
-
5
- setup do
6
- @typus_user = Factory(:typus_user)
7
- @url = "http://test.host/admin/account/#{@typus_user.token}"
8
- @email = Admin::Mailer.reset_password_link(@typus_user, @url)
9
- end
10
-
11
- should "verify email from is nil by default" do
12
- assert_nil Admin::Mailer.default[:from]
13
- end
14
-
15
- should "verify email to is typus user email" do
16
- assert @email.to.include?(@typus_user.email)
17
- end
18
-
19
- should "verify email subject" do
20
- expected = "[#{Typus.admin_title}] Reset password"
21
- assert_equal expected, @email.subject
22
- end
23
-
24
- should "verify default email mime_type" do
25
- assert_equal "text/plain", @email.mime_type
26
- end
27
-
28
- should "verify email contains reset password link with token" do
29
- assert_match @url, @email.body.encoded
30
- end
31
-
32
- end
@@ -1,5 +0,0 @@
1
- require "test_helper"
2
-
3
- class AdminUserTest < ActiveSupport::TestCase
4
-
5
- end
@@ -1,125 +0,0 @@
1
- require "test_helper"
2
-
3
- class TypusUserRolesTest < ActiveSupport::TestCase
4
-
5
- should "get a list of roles" do
6
- roles = %w(admin designer editor)
7
- assert_equal roles, Typus::Configuration.roles.map(&:first).sort
8
- end
9
-
10
- context "A TypusUser with role admin" do
11
-
12
- setup do
13
- @typus_user = Factory(:typus_user)
14
- end
15
-
16
- should "verify models access" do
17
- expected = ["Asset",
18
- "Bird",
19
- "Case",
20
- "Category",
21
- "Comment",
22
- "Dog",
23
- "Entry",
24
- "Git",
25
- "Hit",
26
- "ImageHolder",
27
- "Invoice",
28
- "Order",
29
- "Page",
30
- "Post",
31
- "Project",
32
- "ProjectCollaborator",
33
- "Status",
34
- "TypusUser",
35
- "User",
36
- "View",
37
- "WatchDog"]
38
- assert_equal expected, @typus_user.resources.map(&:first).sort
39
- end
40
-
41
- should_eventually "verify resources without actions related are removed" do
42
- assert !@typus_user.resources.map(&:first).include?('Order')
43
- end
44
-
45
- should "have access to all actions on models" do
46
- models = %w(Asset Category Comment Page Post TypusUser View)
47
- %w(create read update destroy).each { |a| models.each { |m| assert @typus_user.can?(a, m) } }
48
- end
49
-
50
- should "verify we can perform action on resource" do
51
- assert @typus_user.can?('index', 'Status', { :special => true })
52
- end
53
-
54
- should "verify we cannot perform action on resource" do
55
- assert @typus_user.cannot?('show', 'Status', { :special => true })
56
- end
57
-
58
- should_eventually "verify we cannot perform actions on resources which don't have that action defined" do
59
- assert @typus_user.cannot?('index', 'Order')
60
- end
61
-
62
- end
63
-
64
- context "A TypusUser with role editor" do
65
-
66
- setup do
67
- @typus_user = Factory(:typus_user, :role => "editor")
68
- end
69
-
70
- should "verify models access" do
71
- expected = %w(Category Comment Git Post TypusUser View)
72
- assert_equal expected, @typus_user.resources.map(&:first).sort
73
- end
74
-
75
- should "only create, read and update categories" do
76
- %w(create read update).each { |a| assert @typus_user.can?(a, 'Category') }
77
- %w(delete).each { |a| assert @typus_user.cannot?(a, 'Category') }
78
- end
79
-
80
- should "only create, read and update posts" do
81
- %w(create read update).each { |a| assert @typus_user.can?(a, 'Post') }
82
- %w(delete).each { |a| assert @typus_user.cannot?(a, 'Post') }
83
- end
84
-
85
- should "only read, update and delete comments" do
86
- %w(read update delete).each { |a| assert @typus_user.can?(a, 'Comment') }
87
- %w(create).each { |a| assert @typus_user.cannot?(a, 'Comment') }
88
- end
89
-
90
- should "only read and update typus_users" do
91
- %w(read update).each { |a| assert @typus_user.can?(a, 'TypusUser') }
92
- %w(create delete).each { |a| assert @typus_user.cannot?(a, 'TypusUser') }
93
- end
94
-
95
- end
96
-
97
- context "A TypusUser with role designer" do
98
-
99
- setup do
100
- @typus_user = Factory(:typus_user, :role => "designer")
101
- end
102
-
103
- should "verify models access" do
104
- expected = %w(Category Comment Post)
105
- assert_equal expected, @typus_user.resources.map(&:first).sort
106
- end
107
-
108
- should "only read and update categories" do
109
- %w(read update).each { |a| assert @typus_user.can?(a, 'Category') }
110
- %w(create delete).each { |a| assert @typus_user.cannot?(a, 'Category') }
111
- end
112
-
113
- should "only read comments" do
114
- %w(read).each { |a| assert @typus_user.can?(a, 'Comment') }
115
- %w(create update delete).each { |a| assert @typus_user.cannot?(a, 'Comment') }
116
- end
117
-
118
- should "only read and update posts" do
119
- %w(read update).each { |a| assert @typus_user.can?(a, 'Post') }
120
- %w(create delete).each { |a| assert @typus_user.cannot?(a, 'Post') }
121
- end
122
-
123
- end
124
-
125
- end
@@ -1,228 +0,0 @@
1
- require "test_helper"
2
-
3
- class TypusUserTest < ActiveSupport::TestCase
4
-
5
- [ %Q(this_is_chelm@example.com\n<script>location.href="http://spammersite.com"</script>),
6
- 'admin',
7
- 'TEST@EXAMPLE.COM',
8
- 'test@example',
9
- 'test@example.c',
10
- 'testexample.com' ].each do |value|
11
- should "not allow #{value}" do
12
- assert !Factory.build(:typus_user, :email => value).valid?
13
- end
14
- end
15
-
16
- [ 'test+filter@example.com',
17
- 'test.filter@example.com',
18
- 'test@example.co.uk',
19
- 'test@example.es' ].each do |value|
20
- should "allow #{value}" do
21
- assert Factory.build(:typus_user, :email => value).valid?
22
- end
23
- end
24
-
25
- should "validate_presence_of :email" do
26
- assert !Factory.build(:typus_user, :email => nil).valid?
27
- end
28
-
29
- should "validate_presence_of :role" do
30
- assert !Factory.build(:typus_user, :role => nil).valid?
31
- end
32
-
33
- should "validate password length" do
34
- assert !Factory.build(:typus_user, :password => "0"*5).valid?, "5"
35
- assert Factory.build(:typus_user, :password => "0"*6).valid?, "6"
36
- assert Factory.build(:typus_user, :password => "0"*40).valid?, "40"
37
- assert !Factory.build(:typus_user, :password => "0"*41).valid?, "41"
38
- end
39
-
40
- should "not allow_mass_assignment_of :status" do
41
- assert TypusUser.attr_protected.include?("status")
42
- end
43
-
44
- should "verify columns" do
45
- expected = %w(id first_name last_name email role status salt crypted_password token preferences created_at updated_at).sort
46
- output = TypusUser.columns.map(&:name).sort
47
- assert_equal expected, output
48
- end
49
-
50
- context "generate" do
51
-
52
- should "not be valid if email is not passed" do
53
- assert TypusUser.generate.invalid?
54
- end
55
-
56
- should "be valid when email is passed" do
57
- options = { :email => 'demo@example.com' }
58
- assert TypusUser.generate(options).valid?
59
- end
60
-
61
- should "accept password" do
62
- options = { :email => 'demo@example.com', :password => 'XXXXXXXX' }
63
- assert TypusUser.generate(options).valid?
64
- end
65
-
66
- should "accept role" do
67
- options = { :email => 'demo@example.com', :role => 'admin' }
68
- assert TypusUser.generate(options).valid?
69
- end
70
-
71
- should "have set a default locale" do
72
- options = { :email => 'demo@example.com', :role => 'admin' }
73
- assert_equal :en, TypusUser.generate(options).locale
74
- end
75
-
76
- end
77
-
78
- context "TypusUser" do
79
-
80
- setup do
81
- @typus_user = Factory(:typus_user)
82
- end
83
-
84
- should "return email" do
85
- assert_equal @typus_user.email, @typus_user.to_label
86
- end
87
-
88
- should "return first_name" do
89
- @typus_user.first_name = "John"
90
- assert_equal "John", @typus_user.to_label
91
- end
92
-
93
- should "return last_name" do
94
- @typus_user.last_name = "Locke"
95
- assert_equal "Locke", @typus_user.to_label
96
- end
97
-
98
- should "return name when first_name and last_name are set" do
99
- @typus_user.first_name, @typus_user.last_name = "John", "Locke"
100
- assert_equal "John Locke", @typus_user.to_label
101
- end
102
-
103
- should "return name when first_name and last_name are set to nil" do
104
- @typus_user.first_name, @typus_user.last_name = nil
105
- assert_equal @typus_user.email, @typus_user.to_label
106
- end
107
-
108
- should "verify salt never changes" do
109
- expected = @typus_user.salt
110
- @typus_user.update_attributes(:password => '11111111', :password_confirmation => '11111111')
111
- assert_equal expected, @typus_user.salt
112
- end
113
-
114
- should "verify authenticated? returns true or false" do
115
- assert @typus_user.authenticated?('12345678')
116
- assert !@typus_user.authenticated?('87654321')
117
- end
118
-
119
- should "verify can? accepts a Class" do
120
- assert @typus_user.can?('delete', TypusUser)
121
- end
122
-
123
- should "verify can? accepts an String" do
124
- assert @typus_user.can?('delete', 'TypusUser')
125
- end
126
-
127
- should "verify cannot? acccepts a Class" do
128
- assert !@typus_user.cannot?('delete', TypusUser)
129
- end
130
-
131
- should "verify cannot? acccepts an String" do
132
- assert !@typus_user.cannot?('delete', 'TypusUser')
133
- end
134
-
135
- should "verify preferences are nil by default" do
136
- assert @typus_user.preferences.nil?
137
- end
138
-
139
- should "return default_locale when no preferences are set" do
140
- assert_equal :en, @typus_user.locale
141
- end
142
-
143
- should "be able to set a locale" do
144
- @typus_user.locale = :jp
145
-
146
- expected = {:locale => :jp}
147
- assert_equal expected, @typus_user.preferences
148
- assert_equal :jp, @typus_user.locale
149
- end
150
-
151
- should "be able to set preferences" do
152
- @typus_user.preferences = {:chunky => "bacon"}
153
- assert @typus_user.preferences.present?
154
- end
155
-
156
- should "set locale preference without overriding previously set preferences" do
157
- @typus_user.preferences = {:chunky => "bacon"}
158
- @typus_user.locale = :jp
159
-
160
- expected = {:locale => :jp, :chunky => "bacon"}
161
- assert_equal expected, @typus_user.preferences
162
- end
163
-
164
- end
165
-
166
- context "Admin Role" do
167
-
168
- setup do
169
- @typus_user = Factory(:typus_user)
170
- end
171
-
172
- should "respond true and false to is_root? and is_not_root?" do
173
- assert @typus_user.is_root?
174
- assert !@typus_user.is_not_root?
175
- end
176
-
177
- should "get a list of all applications" do
178
- assert_equal Typus.applications, @typus_user.applications
179
- end
180
-
181
- should "get a list of application resources for CRUD Extended application" do
182
- expected = ["Asset", "Category", "Comment", "Page", "Post"]
183
- assert_equal expected, @typus_user.application("CRUD Extended")
184
- end
185
-
186
- should "get a list of application resources for Admin application" do
187
- assert_equal %w(TypusUser), @typus_user.application("Admin")
188
- end
189
-
190
- end
191
-
192
- context "Editor Role" do
193
-
194
- setup do
195
- @typus_user = Factory(:typus_user, :role => "editor")
196
- end
197
-
198
- should "respond true and false to is_no_root? and is_root?" do
199
- assert @typus_user.is_not_root?
200
- assert !@typus_user.is_root?
201
- end
202
-
203
- should "get a list of all applications" do
204
- expected = ["Admin", "CRUD Extended"]
205
- assert_equal expected, @typus_user.applications
206
- end
207
-
208
- should "get a list of application resources" do
209
- assert_equal %w(Category Comment Post), @typus_user.application("CRUD Extended")
210
- assert_equal %w(TypusUser), @typus_user.application("Admin")
211
- end
212
-
213
- end
214
-
215
- should "owns a resource" do
216
- typus_user = Factory(:typus_user)
217
- resource = Factory(:post, :typus_user_id => typus_user.id)
218
- assert typus_user.owns?(resource)
219
- end
220
-
221
- should "not own a resource" do
222
- typus_user = Factory(:typus_user)
223
- typus_user_2 = Factory(:typus_user)
224
- resource = Factory(:post, :typus_user_id => typus_user_2.id)
225
- assert !typus_user.owns?(resource)
226
- end
227
-
228
- end
@@ -1,29 +0,0 @@
1
- require "test_helper"
2
-
3
- class RoutesTest < ActiveSupport::TestCase
4
-
5
- setup do
6
- @routes = Rails.application.routes.routes.map(&:name)
7
- end
8
-
9
- should "verify admin routes" do
10
- expected = %w(admin)
11
- expected.each { |r| assert @routes.include?(r) }
12
- end
13
-
14
- should "verify admin dashboard routes" do
15
- expected = %w(admin_dashboard)
16
- expected.each { |r| assert @routes.include?(r) }
17
- end
18
-
19
- should "verify admin account named routes" do
20
- expected = %w(forgot_password_admin_account_index admin_account_index new_admin_account admin_account)
21
- expected.each { |r| assert @routes.include?(r) }
22
- end
23
-
24
- should "verify admin session named routes" do
25
- expected = %w(new_admin_session admin_session)
26
- expected.each { |r| assert @routes.include?(r) }
27
- end
28
-
29
- end
@@ -1,122 +0,0 @@
1
- ##
2
- # CRUD
3
- ##
4
-
5
- Factory.define :entry do |f|
6
- f.sequence(:title) { |n| "Entry##{n}" }
7
- f.content "Body of the entry"
8
- end
9
-
10
- Factory.define :case do |f|
11
- f.sequence(:title) { |n| "Case##{n}" }
12
- f.content "Body of the entry"
13
- end
14
-
15
- ##
16
- # CRUD Extended
17
- ##
18
-
19
- Factory.define :asset do |f|
20
- f.sequence(:caption) { |n| "Asset##{n}" }
21
- f.dragonfly File.new("#{Rails.root}/public/images/rails.png")
22
- f.dragonfly_required File.new("#{Rails.root}/public/images/rails.png")
23
- f.paperclip File.new("#{Rails.root}/public/images/rails.png")
24
- f.paperclip_required File.new("#{Rails.root}/public/images/rails.png")
25
- end
26
-
27
- Factory.define :category do |f|
28
- f.sequence(:name) { |n| "Category##{n}" }
29
- end
30
-
31
- Factory.define :comment do |f|
32
- f.sequence(:name) { |n| "Comment##{n}" }
33
- f.sequence(:email) { |n| "john+#{n}@example.com" }
34
- f.body "Body of the comment"
35
- f.association :post
36
- end
37
-
38
- Factory.define :page do |f|
39
- f.sequence(:title) { |n| "Page##{n}" }
40
- f.body "Content"
41
- end
42
-
43
- Factory.define :post do |f|
44
- f.sequence(:title) { |n| "Post##{n}" }
45
- f.body "Body"
46
- f.status "published"
47
- end
48
-
49
- Factory.define :typus_user do |f|
50
- f.sequence(:email) { |n| "user+#{n}@example.com" }
51
- f.role "admin"
52
- f.status true
53
- f.token "1A2B3C4D5E6F"
54
- f.password "12345678"
55
- end
56
-
57
- Factory.define :view do |f|
58
- f.ip "127.0.0.1"
59
- f.association :post
60
- f.association :site
61
- end
62
-
63
- ##
64
- # HasOne Association
65
- #
66
-
67
- Factory.define :invoice do |f|
68
- f.sequence(:number) { |n| "Invoice##{n}" }
69
- f.association :order
70
- end
71
-
72
- Factory.define :order do |f|
73
- f.sequence(:number) { |n| "Order##{n}" }
74
- end
75
-
76
- ##
77
- # HasManyThrough Association
78
- #
79
-
80
- Factory.define :user do |f|
81
- f.sequence(:name) { |n| "User##{n}" }
82
- f.sequence(:email) { |n| "user.#{n}@example.com" }
83
- end
84
-
85
- Factory.define :project do |f|
86
- f.sequence(:name) { |n| "Project##{n}" }
87
- f.association :user
88
- end
89
-
90
- Factory.define :project_collaborators do |f|
91
- f.association :user
92
- f.association :project
93
- end
94
-
95
- ##
96
- # Polymorphic
97
- ##
98
-
99
- Factory.define :animal do |f|
100
- f.sequence(:name) { |n| "Animal##{n}" }
101
- end
102
-
103
- Factory.define :bird do |f|
104
- f.sequence(:name) { |n| "Bird##{n}" }
105
- end
106
-
107
- Factory.define :dog do |f|
108
- f.sequence(:name) { |n| "Dog##{n}" }
109
- end
110
-
111
- Factory.define :image_holder do |f|
112
- f.sequence(:name) { |n| "ImageHolder##{n}" }
113
- end
114
-
115
- ##
116
- # Contexts
117
- ##
118
-
119
- Factory.define :site do |f|
120
- f.sequence(:name) { |n| "Site##{n}" }
121
- f.sequence(:domain) { |n| "site#{n}.local" }
122
- end