fesplugas-typus 0.9.7 → 0.9.8
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.
- data/README.rdoc +3 -8
- data/VERSION +1 -1
- data/app/controllers/admin/master_controller.rb +8 -10
- data/app/helpers/admin/form_helper.rb +18 -5
- data/app/helpers/admin/master_helper.rb +7 -7
- data/app/helpers/admin/sidebar_helper.rb +0 -23
- data/app/helpers/typus_helper.rb +1 -1
- data/app/views/admin/dashboard/_sidebar.html.erb +1 -1
- data/app/views/admin/resources/show.html.erb +3 -1
- data/config/locales/es.yml +2 -4
- data/config/locales/pt-BR.yml +2 -4
- data/config/locales/ru.yml +2 -4
- data/generators/typus/templates/config/typus/application.yml +1 -1
- data/lib/typus/user.rb +2 -5
- data/lib/typus.rb +0 -17
- data/test/functional/admin/posts_controller_test.rb +4 -2
- data/test/functional/typus_controller_test.rb +1 -1
- data/test/helpers/admin/form_helper_test.rb +4 -4
- data/test/helpers/admin/master_helper_test.rb +5 -1
- data/test/helpers/admin/sidebar_helper_test.rb +0 -16
- data/test/lib/typus_test.rb +0 -19
- data/test/unit/typus_user_test.rb +4 -6
- data/typus.gemspec +2 -2
- metadata +2 -2
data/README.rdoc
CHANGED
|
@@ -8,15 +8,14 @@
|
|
|
8
8
|
extensible enough to match lots of use cases.
|
|
9
9
|
|
|
10
10
|
- Project site and documentation http://intraducibles.com/projects/typus
|
|
11
|
-
- Screenshoots http://intraducibles.com/projects/typus/screenshots
|
|
12
11
|
- Plugin source http://github.com/fesplugas/typus/tree
|
|
13
12
|
- Google Group http://groups.google.es/group/typus
|
|
14
13
|
|
|
15
|
-
==
|
|
14
|
+
== Impatients to see it working?
|
|
16
15
|
|
|
17
16
|
Step 1: Create a Rails application using a template.
|
|
18
17
|
|
|
19
|
-
$ rails example.com -m http://
|
|
18
|
+
$ rails example.com -m http://gist.github.com/86613.txt
|
|
20
19
|
|
|
21
20
|
Step 2: Start the server:
|
|
22
21
|
|
|
@@ -28,14 +27,10 @@ Step 3: Go to the admin area and enjoy it!
|
|
|
28
27
|
|
|
29
28
|
== Installing
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
Install from GitHub the latest version which it's compatible with Rails 2.3.2.
|
|
32
31
|
|
|
33
32
|
$ script/plugin install git://github.com/fesplugas/typus.git
|
|
34
33
|
|
|
35
|
-
*Gem*: Add *Typus* to your <tt>config/environment.rb</tt>.
|
|
36
|
-
|
|
37
|
-
config.gem 'fesplugas-typus', :lib => 'typus', :source => 'http://gems.github.com'
|
|
38
|
-
|
|
39
34
|
Once *Typus* is installed, run the generator to create required files and migrate your
|
|
40
35
|
database. (<tt>typus_users</tt> table is created)
|
|
41
36
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.8
|
|
@@ -127,7 +127,7 @@ class Admin::MasterController < ApplicationController
|
|
|
127
127
|
path = if @resource[:class].typus_options_for(:index_after_save)
|
|
128
128
|
params[:back_to] ? "#{params[:back_to]}##{@resource[:self]}" : { :action => 'index' }
|
|
129
129
|
else
|
|
130
|
-
{ :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id }
|
|
130
|
+
{ :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id, :back_to => params[:back_to] }
|
|
131
131
|
end
|
|
132
132
|
redirect_to path
|
|
133
133
|
else
|
|
@@ -246,14 +246,11 @@ private
|
|
|
246
246
|
# If current_user is a root user, by-pass.
|
|
247
247
|
return if @current_user.is_root?
|
|
248
248
|
|
|
249
|
-
#
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
unless @item.send(Typus.user_fk) == session[:typus_user_id]
|
|
255
|
-
flash[:notice] = _("Record owned by another user.")
|
|
256
|
-
redirect_to :action => 'show', :id => @item.id
|
|
249
|
+
# OPTIMIZE: `typus_users` is currently hard-coded. We should find a good name for this option.
|
|
250
|
+
if @item.respond_to?('typus_users') && !@item.send('typus_users').include?(@current_user) ||
|
|
251
|
+
@item.respond_to?(Typus.user_fk) && !(@item.send(Typus.user_fk) == session[:typus_user_id])
|
|
252
|
+
flash[:notice] = _("You don't have permission to access this item.")
|
|
253
|
+
redirect_to :back
|
|
257
254
|
end
|
|
258
255
|
|
|
259
256
|
end
|
|
@@ -323,12 +320,13 @@ private
|
|
|
323
320
|
path = "#{params[:back_to]}?#{params[:selected]}=#{@item.id}"
|
|
324
321
|
when :polymorphic
|
|
325
322
|
resource.send(@item.class.name.tableize).create(params[:item])
|
|
323
|
+
path = "#{params[:back_to]}##{@resource[:self]}"
|
|
326
324
|
end
|
|
327
325
|
|
|
328
326
|
flash[:success] = message || _("{{model_a}} successfully assigned to {{model_b}}.",
|
|
329
327
|
:model_a => @item.class,
|
|
330
328
|
:model_b => resource_class.name)
|
|
331
|
-
redirect_to path ||
|
|
329
|
+
redirect_to path || params[:back_to]
|
|
332
330
|
|
|
333
331
|
end
|
|
334
332
|
|
|
@@ -180,11 +180,17 @@ module Admin::FormHelper
|
|
|
180
180
|
|
|
181
181
|
def typus_relationships
|
|
182
182
|
|
|
183
|
+
# OPTIMIZE
|
|
183
184
|
@back_to = '/' + [ params[:controller], params[:action], params[:id] ].compact.join('/')
|
|
184
185
|
|
|
185
186
|
returning(String.new) do |html|
|
|
186
187
|
@resource[:class].typus_defaults_for(:relationships).each do |relationship|
|
|
187
|
-
|
|
188
|
+
|
|
189
|
+
association = @resource[:class].reflect_on_association(relationship.to_sym)
|
|
190
|
+
|
|
191
|
+
next if !@current_user.can_perform?(association.class_name.constantize, 'read')
|
|
192
|
+
|
|
193
|
+
case association.macro
|
|
188
194
|
when :has_and_belongs_to_many
|
|
189
195
|
html << typus_form_has_and_belongs_to_many(relationship)
|
|
190
196
|
when :has_many
|
|
@@ -192,6 +198,7 @@ module Admin::FormHelper
|
|
|
192
198
|
when :has_one
|
|
193
199
|
html << typus_form_has_one(relationship)
|
|
194
200
|
end
|
|
201
|
+
|
|
195
202
|
end
|
|
196
203
|
end
|
|
197
204
|
|
|
@@ -209,7 +216,7 @@ module Admin::FormHelper
|
|
|
209
216
|
|
|
210
217
|
link_options = { :controller => "admin/#{field}",
|
|
211
218
|
:action => 'new',
|
|
212
|
-
:back_to => @back_to,
|
|
219
|
+
:back_to => "#{@back_to}##{field}",
|
|
213
220
|
:resource => @resource[:self].singularize,
|
|
214
221
|
:resource_id => @item.id,
|
|
215
222
|
foreign_key => @item.id }
|
|
@@ -218,13 +225,19 @@ module Admin::FormHelper
|
|
|
218
225
|
<a name="#{field}"></a>
|
|
219
226
|
<div class="box_relationships">
|
|
220
227
|
<h2>
|
|
221
|
-
#{link_to model_to_relate.human_name.pluralize, :controller => "admin/#{model_to_relate_as_resource}"}
|
|
228
|
+
#{link_to model_to_relate.human_name.pluralize, { :controller => "admin/#{model_to_relate_as_resource}", foreign_key => @item.id }, :title => _('{{model}} filtered by {{filtered_by}}', :model => model_to_relate.human_name.pluralize, :filtered_by => @item.typus_name)}
|
|
222
229
|
<small>#{link_to _('Add new'), link_options if @current_user.can_perform?(model_to_relate, 'create')}</small>
|
|
223
230
|
</h2>
|
|
224
231
|
HTML
|
|
225
|
-
|
|
232
|
+
|
|
233
|
+
conditions = if model_to_relate.typus_options_for(:only_user_items) && !@current_user.is_root?
|
|
234
|
+
{ Typus.user_fk => @current_user }
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
items = @resource[:class].find(params[:id]).send(field).find(:all, :order => model_to_relate.typus_order_by, :conditions => conditions)
|
|
238
|
+
|
|
226
239
|
unless items.empty?
|
|
227
|
-
options = { :back_to => @back_to, :resource => @resource[:self], :resource_id => @item.id }
|
|
240
|
+
options = { :back_to => "#{@back_to}##{field}", :resource => @resource[:self], :resource_id => @item.id }
|
|
228
241
|
html << build_list(model_to_relate,
|
|
229
242
|
model_to_relate.typus_fields_for(:relationship),
|
|
230
243
|
items,
|
|
@@ -6,23 +6,23 @@ module Admin::MasterHelper
|
|
|
6
6
|
include Admin::FormHelper
|
|
7
7
|
include Admin::TableHelper
|
|
8
8
|
|
|
9
|
-
def display_link_to_previous
|
|
9
|
+
def display_link_to_previous # (_params = params)
|
|
10
10
|
|
|
11
11
|
options = {}
|
|
12
|
-
options[:resource_from] =
|
|
13
|
-
options[:resource_to] =
|
|
12
|
+
options[:resource_from] = @resource[:class].human_name
|
|
13
|
+
options[:resource_to] = params[:resource].classify.humanize if params[:resource]
|
|
14
14
|
|
|
15
|
-
editing = %w( edit update ).include?(
|
|
15
|
+
editing = %w( edit update ).include?(params[:action])
|
|
16
16
|
|
|
17
17
|
message = case
|
|
18
|
-
when
|
|
18
|
+
when params[:resource] && editing
|
|
19
19
|
_("You're updating a {{resource_from}} for {{resource_to}}.",
|
|
20
20
|
:resource_from => options[:resource_from],
|
|
21
21
|
:resource_to => options[:resource_to])
|
|
22
22
|
when editing
|
|
23
23
|
_("You're updating a {{resource_from}}.",
|
|
24
24
|
:resource_from => options[:resource_from])
|
|
25
|
-
when
|
|
25
|
+
when params[:resource]
|
|
26
26
|
_("You're adding a new {{resource_from}} to {{resource_to}}.",
|
|
27
27
|
:resource_from => options[:resource_from],
|
|
28
28
|
:resource_to => options[:resource_to])
|
|
@@ -34,7 +34,7 @@ module Admin::MasterHelper
|
|
|
34
34
|
returning(String.new) do |html|
|
|
35
35
|
html << <<-HTML
|
|
36
36
|
<div id="flash" class="notice">
|
|
37
|
-
<p>#{message} #{link_to _("Do you want to cancel it?"),
|
|
37
|
+
<p>#{message} #{link_to _("Do you want to cancel it?"), params[:back_to]}</p>
|
|
38
38
|
</div>
|
|
39
39
|
HTML
|
|
40
40
|
end
|
|
@@ -13,12 +13,6 @@ module Admin::SidebarHelper
|
|
|
13
13
|
#{build_typus_list(export, :header => 'export')}
|
|
14
14
|
HTML
|
|
15
15
|
|
|
16
|
-
%w( parent_module submodules ).each do |block|
|
|
17
|
-
html << <<-HTML
|
|
18
|
-
#{build_typus_list(modules(block), :header => block)}
|
|
19
|
-
HTML
|
|
20
|
-
end
|
|
21
|
-
|
|
22
16
|
end
|
|
23
17
|
|
|
24
18
|
end
|
|
@@ -88,23 +82,6 @@ module Admin::SidebarHelper
|
|
|
88
82
|
|
|
89
83
|
end
|
|
90
84
|
|
|
91
|
-
def modules(name)
|
|
92
|
-
|
|
93
|
-
models = case name
|
|
94
|
-
when 'parent_module': Typus.parent(@resource[:class], 'module')
|
|
95
|
-
when 'submodules': Typus.module(@resource[:class])
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
return [] if models.empty?
|
|
99
|
-
|
|
100
|
-
returning(Array.new) do |items|
|
|
101
|
-
models.each do |model|
|
|
102
|
-
items << (link_to model.humanize, :controller => model.tableize)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
end
|
|
107
|
-
|
|
108
85
|
def previous_and_next
|
|
109
86
|
return [] unless %w( edit show update ).include?(params[:action])
|
|
110
87
|
returning(Array.new) do |items|
|
data/app/helpers/typus_helper.rb
CHANGED
|
@@ -136,7 +136,7 @@ module TypusHelper
|
|
|
136
136
|
|
|
137
137
|
<<-HTML
|
|
138
138
|
<ul>
|
|
139
|
-
<li>#{_('Logged as')} #{link_to user.
|
|
139
|
+
<li>#{_('Logged as')} #{link_to user.name, admin_edit_typus_user_path, :title => "#{user.email} (#{user.role})"}</li>
|
|
140
140
|
<li>#{link_to _('Sign out'), admin_sign_out_path }</li>
|
|
141
141
|
</ul>
|
|
142
142
|
HTML
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
<p>If you need help don't hesitate in joining the <%= link_to 'Typus', 'http://groups.google.com/group/typus', :rel => 'external' %> mailing list.</p>
|
|
6
6
|
|
|
7
|
-
<p>
|
|
7
|
+
<p>Remember you can replace this sidebar adding <code>_sidebar.html.erb</code> file on <code>app/views/admin/dashboard</code> folder.</p>
|
|
8
8
|
|
|
9
9
|
<p>Have a nice day!</p>
|
data/config/locales/es.yml
CHANGED
|
@@ -81,10 +81,7 @@ es:
|
|
|
81
81
|
"{{current_user_role}} can't go to {{action}} on {{controller}}": "{{current_user_role}} no pude ir a {{action}} en {{controller}}."
|
|
82
82
|
"{{current_user_role}} can't delete this item": "{{current_user_role}} no puede borrar este elemento."
|
|
83
83
|
"{{current_user_role}} can't perform action ({{action}})": "{{current_user_role}} no puede relizar la accion ({{action}})"
|
|
84
|
-
"Record owned by another user": "Registro propiedad de otro usuario."
|
|
85
84
|
"{{current_user_role}} can't display items": "{{current_user_role}} no puede mostrar los elementos."
|
|
86
|
-
"Submodules": "Submodulos"
|
|
87
|
-
"Parent module": "Modulo padre"
|
|
88
85
|
"You can update your password at": "Puedes actualizar tu contraseña en"
|
|
89
86
|
"If you didn't request a password update, you can ignore this message": "Si no pediste una actualización de tu contraseña, puedes ignorar este mensaje."
|
|
90
87
|
"Have a nice day": "Que tengas un buen dia."
|
|
@@ -102,4 +99,5 @@ es:
|
|
|
102
99
|
"Today": "Hoy"
|
|
103
100
|
"Past 7 days": "Últimos 7 dias"
|
|
104
101
|
"This month": "Este mes"
|
|
105
|
-
"This year": "Este año"
|
|
102
|
+
"This year": "Este año"
|
|
103
|
+
"{{model}} filtered by {{filtered_by}}": "{{model}} filtrados por {{filtered_by}}"
|
data/config/locales/pt-BR.yml
CHANGED
|
@@ -81,10 +81,7 @@ pt-BR:
|
|
|
81
81
|
"{{current_user_role}} can't go to {{action}} on {{controller}}": "{{current_user_role}} não pode ir a {{action}} no {{controller}}."
|
|
82
82
|
"{{current_user_role}} can't delete this item": "{{current_user_role}} não pode apagar este item."
|
|
83
83
|
"{{current_user_role}} can't perform action ({{action}})": "{{current_user_role}} não pode realizar a ação ({{action}})"
|
|
84
|
-
"Record owned by another user": "Registro é propriedade de outro usuário."
|
|
85
84
|
"{{current_user_role}} can't display items": "{{current_user_role}} não pode mostrar os items."
|
|
86
|
-
"Submodules": "Submódulos"
|
|
87
|
-
"Parent module": "Módulo pai"
|
|
88
85
|
"You can update your password at": "Você pode atualizar sua senha em"
|
|
89
86
|
"If you didn't request a password update, you can ignore this message": "Se você não pediu uma renovação de senha, por favor ignore esta mensagem."
|
|
90
87
|
"Have a nice day": "Tenha um bom dia."
|
|
@@ -104,4 +101,5 @@ pt-BR:
|
|
|
104
101
|
"This month": "Este mês"
|
|
105
102
|
"This year": "Este ano"
|
|
106
103
|
"Created at": "Criado em"
|
|
107
|
-
"Updated at": "Atualizado em"
|
|
104
|
+
"Updated at": "Atualizado em"
|
|
105
|
+
"{{model}} filtered by {{filtered_by}}":
|
data/config/locales/ru.yml
CHANGED
|
@@ -81,10 +81,7 @@ ru:
|
|
|
81
81
|
"{{current_user_role}} can't go to {{action}} on {{controller}}": "{{current_user_role}} не может перейти к {{action}} в {{controller}}."
|
|
82
82
|
"{{current_user_role}} can't delete this item": "{{current_user_role}} не может удалить эту запись"
|
|
83
83
|
"{{current_user_role}} can't perform action ({{action}})": "{{current_user_role}} не может выполнить действие ({{action}})"
|
|
84
|
-
"Record owned by another user": "Запись принадлежит другому пользователю."
|
|
85
84
|
"{{current_user_role}} can't display items": "{{current_user_role}} не может отобразить записи"
|
|
86
|
-
"Submodules": "Подмодули"
|
|
87
|
-
"Parent module": "Дочерний модуль"
|
|
88
85
|
"You can update your password at": "Вы можете установить свой пароль на"
|
|
89
86
|
"If you didn't request a password update, you can ignore this message": "Если Вы не запрашивали обновление пароля, Вы можете проигнорировать это сообщение."
|
|
90
87
|
"Have a nice day": "Добрый день."
|
|
@@ -104,4 +101,5 @@ ru:
|
|
|
104
101
|
"This month": "Этот месяц"
|
|
105
102
|
"This year": "Этот год"
|
|
106
103
|
"Created at": "Создано"
|
|
107
|
-
"Updated at": "Обновлено"
|
|
104
|
+
"Updated at": "Обновлено"
|
|
105
|
+
"{{model}} filtered by {{filtered_by}}":
|
data/lib/typus/user.rb
CHANGED
|
@@ -55,11 +55,8 @@ module Typus
|
|
|
55
55
|
|
|
56
56
|
module InstanceMethods
|
|
57
57
|
|
|
58
|
-
def
|
|
59
|
-
|
|
60
|
-
full_name = (!first_name.empty? && !last_name.empty?) ? "#{first_name} #{last_name}" : email
|
|
61
|
-
full_name << " (#{role})" if options[:display_role]
|
|
62
|
-
return full_name
|
|
58
|
+
def name
|
|
59
|
+
(!first_name.empty? && !last_name.empty?) ? "#{first_name} #{last_name}" : email
|
|
63
60
|
end
|
|
64
61
|
|
|
65
62
|
def authenticated?(password)
|
data/lib/typus.rb
CHANGED
|
@@ -29,23 +29,6 @@ module Typus
|
|
|
29
29
|
Typus::Configuration.config.collect { |i| i.first if i.last['application'] == name }.compact.uniq.sort
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
##
|
|
33
|
-
# Returns a list of the submodules of a module.
|
|
34
|
-
#
|
|
35
|
-
def module(name)
|
|
36
|
-
Typus::Configuration.config.collect { |i| i.first if i.last['module'] == name.name }.compact.uniq.sort
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
##
|
|
40
|
-
# Parent
|
|
41
|
-
#
|
|
42
|
-
# Typus::Configuration.config['Post']['module']
|
|
43
|
-
# Typus::Configuration.config['Post']['application']
|
|
44
|
-
#
|
|
45
|
-
def parent(model, name)
|
|
46
|
-
Typus::Configuration.config[model.name][name] || ''
|
|
47
|
-
end
|
|
48
|
-
|
|
49
32
|
def models
|
|
50
33
|
Typus::Configuration.config.map { |i| i.first }.sort
|
|
51
34
|
end
|
|
@@ -244,15 +244,17 @@ class Admin::PostsControllerTest < ActionController::TestCase
|
|
|
244
244
|
|
|
245
245
|
def test_should_verify_editor_cannot_edit_other_users_records
|
|
246
246
|
|
|
247
|
+
@request.env['HTTP_REFERER'] = '/admin/posts'
|
|
248
|
+
|
|
247
249
|
typus_user = typus_users(:editor)
|
|
248
250
|
@request.session[:typus_user_id] = typus_user.id
|
|
249
251
|
|
|
250
252
|
post = posts(:owned_by_admin)
|
|
251
253
|
get :edit, { :id => post.id }
|
|
252
254
|
assert_response :redirect
|
|
253
|
-
assert_redirected_to
|
|
255
|
+
assert_redirected_to '/admin/posts'
|
|
254
256
|
assert flash[:notice]
|
|
255
|
-
assert_equal "
|
|
257
|
+
assert_equal "You don't have permission to access this item.", flash[:notice]
|
|
256
258
|
|
|
257
259
|
end
|
|
258
260
|
|
|
@@ -260,7 +260,7 @@ class TypusControllerTest < ActionController::TestCase
|
|
|
260
260
|
assert_match "href=\"\/admin\/typus_users\/edit\/#{typus_user.id}\"", @response.body
|
|
261
261
|
|
|
262
262
|
assert_select 'body div#header' do
|
|
263
|
-
assert_select 'a', 'Admin Example
|
|
263
|
+
assert_select 'a', 'Admin Example'
|
|
264
264
|
assert_select 'a', 'Sign out'
|
|
265
265
|
end
|
|
266
266
|
|
|
@@ -239,8 +239,8 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
239
239
|
<a name="comments"></a>
|
|
240
240
|
<div class="box_relationships">
|
|
241
241
|
<h2>
|
|
242
|
-
<a href="http://test.host/admin/comments">Comments</a>
|
|
243
|
-
<small><a href="http://test.host/admin/comments/new?resource=post&resource_id=1">Add new</a></small>
|
|
242
|
+
<a href="http://test.host/admin/comments" title="Comments filtered by Post#1">Comments</a>
|
|
243
|
+
<small><a href="http://test.host/admin/comments/new?back_to=%23comments&resource=post&resource_id=1">Add new</a></small>
|
|
244
244
|
</h2>
|
|
245
245
|
<!-- a_nice_list --></div>
|
|
246
246
|
HTML
|
|
@@ -264,8 +264,8 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
|
264
264
|
<a name="comments"></a>
|
|
265
265
|
<div class="box_relationships">
|
|
266
266
|
<h2>
|
|
267
|
-
<a href="http://test.host/admin/comments">Comments</a>
|
|
268
|
-
<small><a href="http://test.host/admin/comments/new?resource=post&resource_id=1">Add new</a></small>
|
|
267
|
+
<a href="http://test.host/admin/comments" title="Comments filtered by Post#1">Comments</a>
|
|
268
|
+
<small><a href="http://test.host/admin/comments/new?back_to=%23comments&resource=post&resource_id=1">Add new</a></small>
|
|
269
269
|
</h2>
|
|
270
270
|
<div id="flash" class="notice"><p>There are no comments.</p></div>
|
|
271
271
|
</div>
|
|
@@ -9,7 +9,11 @@ class Admin::MasterHelperTest < ActiveSupport::TestCase
|
|
|
9
9
|
|
|
10
10
|
def test_display_link_to_previous
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
@resource = { :class => Post }
|
|
13
|
+
params = { :action => 'edit', :back_to => '/back_to_param' }
|
|
14
|
+
self.expects(:params).at_least_once.returns(params)
|
|
15
|
+
|
|
16
|
+
output = display_link_to_previous
|
|
13
17
|
expected = <<-HTML
|
|
14
18
|
<div id="flash" class="notice">
|
|
15
19
|
<p>You're updating a Post. <a href="/back_to_param">Do you want to cancel it?</a></p>
|
|
@@ -18,8 +18,6 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
|
18
18
|
self.expects(:default_actions).returns(['action1', 'action2'])
|
|
19
19
|
self.expects(:previous_and_next).returns(['previous', 'next'])
|
|
20
20
|
self.expects(:export).returns(['csv', 'pdf'])
|
|
21
|
-
self.expects(:modules).with('parent_module').returns(['parent_module'])
|
|
22
|
-
self.expects(:modules).with('submodules').returns(['submodules'])
|
|
23
21
|
|
|
24
22
|
output = actions
|
|
25
23
|
expected = <<-HTML
|
|
@@ -39,16 +37,6 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
|
39
37
|
<ul>
|
|
40
38
|
<li>csv</li>
|
|
41
39
|
<li>pdf</li>
|
|
42
|
-
</ul>
|
|
43
|
-
|
|
44
|
-
<h2>Parent module</h2>
|
|
45
|
-
<ul>
|
|
46
|
-
<li>parent_module</li>
|
|
47
|
-
</ul>
|
|
48
|
-
|
|
49
|
-
<h2>Submodules</h2>
|
|
50
|
-
<ul>
|
|
51
|
-
<li>submodules</li>
|
|
52
40
|
</ul>
|
|
53
41
|
|
|
54
42
|
HTML
|
|
@@ -100,10 +88,6 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
|
100
88
|
assert_no_match /\/h2/, output
|
|
101
89
|
end
|
|
102
90
|
|
|
103
|
-
def test_modules
|
|
104
|
-
assert true
|
|
105
|
-
end
|
|
106
|
-
|
|
107
91
|
def test_previous_and_next
|
|
108
92
|
|
|
109
93
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
data/test/lib/typus_test.rb
CHANGED
|
@@ -37,25 +37,6 @@ class TypusTest < ActiveSupport::TestCase
|
|
|
37
37
|
assert_equal %w( Comment Post ), Typus.application('Blog')
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def test_should_return_modules_of_a_module
|
|
41
|
-
assert Typus.respond_to?(:module)
|
|
42
|
-
assert_equal %w( Category ), Typus.module(Post)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_should_verify_parent_exists
|
|
46
|
-
assert Typus.respond_to?(:parent)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def test_should_verify_parent_for_application
|
|
50
|
-
assert Typus.parent(TypusUser, 'application').kind_of?(String)
|
|
51
|
-
assert_equal 'Typus', Typus.parent(TypusUser, 'application')
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_should_verify_parent_for_nothing
|
|
55
|
-
assert Typus.parent(TypusUser, 'nothing').kind_of?(String)
|
|
56
|
-
assert_equal '', Typus.parent(TypusUser, 'nothing')
|
|
57
|
-
end
|
|
58
|
-
|
|
59
40
|
def test_should_return_models_and_should_be_sorted
|
|
60
41
|
assert Typus.respond_to?(:models)
|
|
61
42
|
assert Typus.models.kind_of?(Array)
|
|
@@ -121,16 +121,14 @@ this_is_chelm@example.com
|
|
|
121
121
|
assert_equal "can't be blank", @typus_user.errors[:role]
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
def
|
|
125
|
-
assert_equal
|
|
126
|
-
assert_equal "#{@typus_user.email}", @typus_user.full_name
|
|
124
|
+
def test_should_return_name_when_only_email
|
|
125
|
+
assert_equal @typus_user.email, @typus_user.name
|
|
127
126
|
end
|
|
128
127
|
|
|
129
|
-
def
|
|
128
|
+
def test_should_return_name_when_theres_first_name_and_last_name
|
|
130
129
|
@typus_user.first_name = 'John'
|
|
131
130
|
@typus_user.last_name = 'Smith'
|
|
132
|
-
assert_equal
|
|
133
|
-
assert_equal 'John Smith', @typus_user.full_name
|
|
131
|
+
assert_equal 'John Smith', @typus_user.name
|
|
134
132
|
end
|
|
135
133
|
|
|
136
134
|
def test_should_return_verify_is_root
|
data/typus.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{typus}
|
|
5
|
-
s.version = "0.9.
|
|
5
|
+
s.version = "0.9.8"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Francesc Esplugas"]
|
|
9
|
-
s.date = %q{2009-06-
|
|
9
|
+
s.date = %q{2009-06-11}
|
|
10
10
|
s.description = %q{Effortless backend interface for Ruby on Rails applications. (Admin scaffold generator.)}
|
|
11
11
|
s.email = %q{francesc@intraducibles.com}
|
|
12
12
|
s.extra_rdoc_files = [
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fesplugas-typus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Francesc Esplugas
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-06-
|
|
12
|
+
date: 2009-06-11 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|