typus 1.0.0.pre8 → 1.0.0.pre9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -6
- data/Gemfile +16 -13
- data/Gemfile.lock +26 -2
- data/Rakefile +2 -3
- data/app/controllers/admin/base_controller.rb +3 -5
- data/app/controllers/admin/resources_controller.rb +24 -26
- data/app/helpers/admin/base_helper.rb +14 -22
- data/app/helpers/admin/dashboard_helper.rb +2 -5
- data/app/helpers/admin/filters_helper.rb +6 -8
- data/app/helpers/admin/form_helper.rb +3 -9
- data/app/helpers/admin/preview_helper.rb +4 -6
- data/app/helpers/admin/relationships_helper.rb +9 -11
- data/app/helpers/admin/resources_helper.rb +6 -24
- data/app/helpers/admin/search_helper.rb +1 -1
- data/app/helpers/admin/sidebar_helper.rb +12 -15
- data/app/helpers/admin/table_helper.rb +13 -13
- data/app/views/admin/dashboard/show.html.erb +1 -1
- data/app/views/admin/helpers/_apps.html.erb +4 -3
- data/app/views/admin/helpers/_header.html.erb +2 -2
- data/app/views/admin/helpers/dashboard/_applications.html.erb +3 -3
- data/app/views/admin/helpers/dashboard/_resources.html.erb +17 -13
- data/app/views/admin/helpers/filters/_filters.html.erb +9 -27
- data/app/views/admin/helpers/resources/_pagination.html.erb +8 -9
- data/app/views/admin/helpers/search/_search.html.erb +1 -1
- data/app/views/admin/mailer/reset_password_link.text.erb +3 -0
- data/app/views/admin/resources/_form.html.erb +4 -4
- data/app/views/admin/resources/edit.html.erb +2 -3
- data/app/views/admin/resources/index.html.erb +15 -13
- data/app/views/admin/resources/new.html.erb +2 -2
- data/app/views/admin/resources/show.html.erb +1 -2
- data/app/views/admin/templates/_boolean.html.erb +1 -1
- data/app/views/admin/templates/_has_many.html.erb +2 -4
- data/app/views/admin/templates/_has_n.html.erb +1 -1
- data/app/views/admin/templates/_selector.html.erb +0 -1
- data/app/views/admin/templates/_string.html.erb +1 -1
- data/app/views/layouts/admin/session.html.erb +1 -1
- data/config/available_locales/ca.yml +3 -5
- data/config/available_locales/de.yml +2 -4
- data/config/available_locales/es.yml +2 -4
- data/config/available_locales/fr.yml +40 -39
- data/config/available_locales/fr_models.yml +2 -2
- data/config/available_locales/hu.yml +3 -5
- data/config/available_locales/it.yml +0 -4
- data/config/available_locales/language.yml.template +2 -4
- data/config/available_locales/pt-BR.yml +2 -4
- data/config/available_locales/ru.yml +2 -4
- data/config/routes.rb +1 -0
- data/lib/generators/templates/config/initializers/typus.rb +5 -5
- data/lib/generators/templates/config/initializers/typus_authentication.rb +5 -5
- data/lib/generators/templates/config/initializers/typus_resources.rb +7 -7
- data/lib/generators/templates/config/typus/README +11 -13
- data/lib/generators/templates/controller.rb +0 -2
- data/lib/generators/templates/functional_test.rb +4 -15
- data/lib/generators/typus/migration_generator.rb +0 -1
- data/lib/support/active_record.rb +18 -9
- data/lib/support/fake_user.rb +42 -0
- data/lib/support/object.rb +1 -0
- data/lib/support/string.rb +0 -32
- data/lib/tasks/typus.rake +0 -8
- data/lib/typus.rb +34 -18
- data/lib/typus/authentication/base.rb +26 -0
- data/lib/typus/authentication/http_basic.rb +22 -0
- data/lib/typus/authentication/none.rb +19 -0
- data/lib/typus/authentication/session.rb +190 -0
- data/lib/typus/format.rb +12 -19
- data/lib/typus/orm/active_record.rb +13 -51
- data/lib/typus/resources.rb +0 -9
- data/lib/typus/version.rb +1 -1
- data/test/factories.rb +43 -0
- data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -1
- data/test/fixtures/rails_app/app/models/page.rb +0 -4
- data/test/fixtures/rails_app/config/application.rb +6 -3
- data/test/fixtures/rails_app/config/database.yml +12 -20
- data/test/fixtures/rails_app/config/typus/application.yml +4 -8
- data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
- data/test/fixtures/rails_app/log/test.log +227115 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +2 -0
- data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +2 -0
- data/test/functional/admin/account_controller_test.rb +1 -1
- data/test/functional/admin/{resources_controller_assets_relationships.rb → assets_controller_test.rb} +12 -16
- data/test/functional/admin/categories_controller_test.rb +62 -0
- data/test/functional/admin/{resources_controller_comments_toggle_test.rb → comments_controller_test.rb} +0 -0
- data/test/functional/admin/dashboard_controller_test.rb +34 -2
- data/test/functional/admin/posts_controller_test.rb +548 -0
- data/test/functional/admin/session_controller_test.rb +2 -2
- data/test/functional/admin/{resources_controller_tableless_resource_test.rb → status_controller_test.rb} +0 -0
- data/test/functional/admin/{resources_controller_typus_users_test.rb → typus_users_controller_test.rb} +2 -2
- data/test/helpers/admin/base_helper_test.rb +35 -37
- data/test/helpers/admin/dashboard_helper_test.rb +4 -8
- data/test/helpers/admin/form_helper_test.rb +9 -34
- data/test/helpers/admin/resources_helper_test.rb +28 -16
- data/test/helpers/admin/sidebar_helper_test.rb +14 -27
- data/test/helpers/admin/table_helper_test.rb +24 -68
- data/test/integration/login_test.rb +13 -0
- data/test/integration_test_helper.rb +21 -0
- data/test/lib/support/active_record_test.rb +72 -21
- data/test/lib/support/array_test.rb +2 -6
- data/test/lib/support/string_test.rb +21 -30
- data/test/lib/typus/active_record_test.rb +162 -100
- data/test/lib/typus/resource_test.rb +2 -3
- data/test/lib/typus_test.rb +25 -22
- data/test/test_helper.rb +4 -17
- data/test/unit/admin/mailer_test.rb +2 -2
- data/test/unit/typus_user_roles_test.rb +23 -23
- data/test/unit/typus_user_test.rb +30 -24
- data/typus.gemspec +0 -1
- metadata +111 -60
- data/app/models/admin/fake_user.rb +0 -46
- data/lib/generators/templates/model.yml +0 -10
- data/lib/typus/authentication.rb +0 -241
- data/lib/vendor/paginator.rb +0 -143
- data/test/factories/assets.rb +0 -5
- data/test/factories/categories.rb +0 -3
- data/test/factories/comments.rb +0 -6
- data/test/factories/pages.rb +0 -5
- data/test/factories/pictures.rb +0 -7
- data/test/factories/posts.rb +0 -6
- data/test/factories/typus_users.rb +0 -8
- data/test/fixtures/rails_app/README +0 -244
- data/test/fixtures/rails_app/app/helpers/application_helper.rb +0 -2
- data/test/fixtures/rails_app/app/views/layouts/application.html.erb +0 -14
- data/test/fixtures/rails_app/config/environments/development.rb +0 -19
- data/test/fixtures/rails_app/config/environments/production.rb +0 -42
- data/test/fixtures/rails_app/config/initializers/acts_as_list.rb +0 -258
- data/test/fixtures/rails_app/config/initializers/acts_as_tree.rb +0 -98
- data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/fixtures/rails_app/config/initializers/inflections.rb +0 -10
- data/test/fixtures/rails_app/config/initializers/mime_types.rb +0 -5
- data/test/fixtures/rails_app/config/locales/en.yml +0 -5
- data/test/fixtures/rails_app/db/seeds.rb +0 -7
- data/test/fixtures/rails_app/public/404.html +0 -26
- data/test/fixtures/rails_app/public/422.html +0 -26
- data/test/fixtures/rails_app/public/500.html +0 -26
- data/test/fixtures/rails_app/public/favicon.ico +0 -0
- data/test/fixtures/rails_app/public/images/rails.png +0 -0
- data/test/fixtures/rails_app/public/index.html +0 -279
- data/test/fixtures/rails_app/public/javascripts/application.js +0 -2
- data/test/fixtures/rails_app/public/javascripts/controls.js +0 -965
- data/test/fixtures/rails_app/public/javascripts/dragdrop.js +0 -974
- data/test/fixtures/rails_app/public/javascripts/effects.js +0 -1123
- data/test/fixtures/rails_app/public/javascripts/prototype.js +0 -4874
- data/test/fixtures/rails_app/public/javascripts/rails.js +0 -118
- data/test/fixtures/rails_app/public/robots.txt +0 -5
- data/test/fixtures/rails_app/script/rails +0 -9
- data/test/functional/admin/dashboard_controller_http_basic_test.rb +0 -24
- data/test/functional/admin/dashboard_controller_none_test.rb +0 -18
- data/test/functional/admin/resources_controller_categories_before_test.rb +0 -10
- data/test/functional/admin/resources_controller_categories_lists_test.rb +0 -44
- data/test/functional/admin/resources_controller_categories_views_test.rb +0 -10
- data/test/functional/admin/resources_controller_posts_before_test.rb +0 -10
- data/test/functional/admin/resources_controller_posts_crud_custom_test.rb +0 -27
- data/test/functional/admin/resources_controller_posts_crud_test.rb +0 -44
- data/test/functional/admin/resources_controller_posts_formats_test.rb +0 -39
- data/test/functional/admin/resources_controller_posts_forms_test.rb +0 -58
- data/test/functional/admin/resources_controller_posts_permissions_test.rb +0 -100
- data/test/functional/admin/resources_controller_posts_relationships_test.rb +0 -91
- data/test/functional/admin/resources_controller_posts_roles.rb +0 -52
- data/test/functional/admin/resources_controller_posts_views_test.rb +0 -143
- data/test/lib/vendor/paginator_test.rb +0 -141
- data/typus-1.0.0.pre7.gem +0 -0
@@ -58,7 +58,7 @@ class Admin::SessionControllerTest < ActionController::TestCase
|
|
58
58
|
|
59
59
|
post :create, { :typus_user => { :email => typus_user.email, :password => "12345678" } }
|
60
60
|
|
61
|
-
|
61
|
+
assert_nil @request.session[:typus_user_id]
|
62
62
|
assert_response :redirect
|
63
63
|
assert_redirected_to new_admin_session_path
|
64
64
|
end
|
@@ -74,7 +74,7 @@ class Admin::SessionControllerTest < ActionController::TestCase
|
|
74
74
|
should "destroy" do
|
75
75
|
delete :destroy
|
76
76
|
|
77
|
-
|
77
|
+
assert_nil @request.session[:typus_user_id]
|
78
78
|
assert_response :redirect
|
79
79
|
assert_redirected_to new_admin_session_path
|
80
80
|
assert flash.empty?
|
File without changes
|
@@ -35,7 +35,7 @@ class Admin::TypusUsersControllerTest < ActionController::TestCase
|
|
35
35
|
end
|
36
36
|
|
37
37
|
should "not be able to destroy herself" do
|
38
|
-
|
38
|
+
assert_no_difference('TypusUser.count') do
|
39
39
|
delete :destroy, :id => @typus_user.id
|
40
40
|
end
|
41
41
|
|
@@ -77,7 +77,7 @@ class Admin::TypusUsersControllerTest < ActionController::TestCase
|
|
77
77
|
|
78
78
|
assert_response :redirect
|
79
79
|
assert_redirected_to @request.env['HTTP_REFERER']
|
80
|
-
assert_equal "Editor can't perform action. (new)", flash[:notice]
|
80
|
+
assert_equal "Editor can't perform action. (new)", flash[:notice]
|
81
81
|
end
|
82
82
|
|
83
83
|
end
|
@@ -8,62 +8,60 @@ class Admin::BaseHelperTest < ActiveSupport::TestCase
|
|
8
8
|
include ActionView::Helpers::TextHelper
|
9
9
|
|
10
10
|
def render(*args); args; end
|
11
|
+
# include ActionView::Rendering
|
12
|
+
# include ActionView::Partials
|
11
13
|
|
12
|
-
|
14
|
+
context "header" do
|
13
15
|
|
14
|
-
|
16
|
+
should_eventually "render with root_path" do
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
# ActionView::Helpers::UrlHelper does not support strings, which are
|
19
|
+
# returned by named routes link root_path
|
20
|
+
self.stubs(:link_to).returns(%(<a href="/">View site</a>))
|
21
|
+
self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
|
20
22
|
|
21
|
-
|
23
|
+
output = header
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
partial = "admin/helpers/header"
|
26
|
+
options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
|
27
|
+
%(<a href="/admin/dashboard">Dashboard</a>),
|
28
|
+
%(<a href="/">View site</a>) ] }
|
27
29
|
|
28
|
-
|
30
|
+
assert_equal [ partial, options ], output
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
=end
|
32
|
+
end
|
33
33
|
|
34
|
-
|
34
|
+
should_eventually "render without root_path" do
|
35
35
|
|
36
|
-
|
36
|
+
Rails.application.routes.named_routes.routes.reject! { |key, route| key == :root }
|
37
37
|
|
38
|
-
|
38
|
+
self.stubs(:link_to_unless_current).returns(%(<a href="/admin/dashboard">Dashboard</a>))
|
39
39
|
|
40
|
-
|
40
|
+
output = header
|
41
|
+
partial = "admin/helpers/header"
|
42
|
+
options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
|
43
|
+
%(<a href="/admin/dashboard">Dashboard</a>) ] }
|
41
44
|
|
42
|
-
|
43
|
-
partial = "admin/helpers/header"
|
44
|
-
options = { :links => [ %(<a href="/admin/dashboard">Dashboard</a>),
|
45
|
-
%(<a href="/admin/dashboard">Dashboard</a>) ] }
|
45
|
+
assert_equal [ partial, options ], output
|
46
46
|
|
47
|
-
|
47
|
+
end
|
48
48
|
|
49
49
|
end
|
50
50
|
|
51
|
-
|
51
|
+
context "display_flash_message" do
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
should "be displayed" do
|
54
|
+
message = { :test => "This is the message." }
|
55
|
+
output = display_flash_message(message)
|
56
|
+
expected = ["admin/helpers/flash_message",
|
57
|
+
{ :flash_type => :test, :message => { :test => "This is the message." } }]
|
58
|
+
assert_equal expected, output
|
59
|
+
end
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
assert_equal partial, output.first
|
62
|
-
assert_equal options, output.last
|
63
|
-
end
|
61
|
+
should "not be displayed when message is empty" do
|
62
|
+
assert_nil display_flash_message(Hash.new)
|
63
|
+
end
|
64
64
|
|
65
|
-
should "not display_flash_message with empty message" do
|
66
|
-
assert display_flash_message(Hash.new).nil?
|
67
65
|
end
|
68
66
|
|
69
67
|
end
|
@@ -10,14 +10,10 @@ class Admin::DashboardHelperTest < ActiveSupport::TestCase
|
|
10
10
|
def render(*args); args; end
|
11
11
|
|
12
12
|
should "render resources" do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
options = { :resources => ["Git", "Status", "WatchDog"] }
|
18
|
-
|
19
|
-
assert_equal partial, output.first
|
20
|
-
assert_equal options, output.last
|
13
|
+
current_user = Factory(:typus_user)
|
14
|
+
output = resources(current_user)
|
15
|
+
expected = ["admin/helpers/dashboard/resources", { :resources => ["Git", "Status", "WatchDog"] }]
|
16
|
+
assert_equal expected, output
|
21
17
|
end
|
22
18
|
|
23
19
|
end
|
@@ -5,16 +5,13 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
5
5
|
include Admin::FormHelper
|
6
6
|
include Admin::ResourcesHelper
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
# FIXME: Problem with params number. A form option has to be sent.
|
11
|
-
def test_typus_belongs_to_field
|
8
|
+
should_eventually "verify_belongs_to_field" do
|
12
9
|
|
13
10
|
params = { :controller => 'admin/post', :id => 1, :action => :create }
|
14
11
|
self.stubs(:params).returns(params)
|
15
12
|
|
16
|
-
|
17
|
-
|
13
|
+
current_user = mock()
|
14
|
+
current_user.stubs(:can?).with('create', Post).returns(false)
|
18
15
|
@resource = Comment
|
19
16
|
|
20
17
|
expected = <<-HTML
|
@@ -32,18 +29,13 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
32
29
|
|
33
30
|
end
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
=begin
|
38
|
-
|
39
|
-
# FIXME: Problem with the number of attributes.
|
40
|
-
def test_typus_belongs_to_field_with_different_attribute_name
|
32
|
+
should_eventually "test_typus_belongs_to_field_with_different_attribute_name" do
|
41
33
|
|
42
34
|
params = { :controller => 'admin/post', :id => 1, :action => :edit }
|
43
35
|
self.stubs(:params).returns(params)
|
44
36
|
|
45
|
-
|
46
|
-
|
37
|
+
current_user = mock()
|
38
|
+
current_user.stubs(:can?).with('create', Comment).returns(true)
|
47
39
|
@resource = Post
|
48
40
|
|
49
41
|
expected = <<-HTML
|
@@ -61,12 +53,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
61
53
|
|
62
54
|
end
|
63
55
|
|
64
|
-
|
65
|
-
|
66
|
-
=begin
|
67
|
-
|
68
|
-
# FIXME: Problem with the number of params.
|
69
|
-
def test_typus_tree_field
|
56
|
+
should_eventually "test_typus_tree_field" do
|
70
57
|
|
71
58
|
self.stubs(:expand_tree_into_select_field).returns('expand_tree_into_select_field')
|
72
59
|
|
@@ -84,13 +71,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
84
71
|
|
85
72
|
end
|
86
73
|
|
87
|
-
|
88
|
-
|
89
|
-
=begin
|
90
|
-
|
91
|
-
# FIXME: Attribute disabled
|
92
|
-
|
93
|
-
should "verify attribute_disabled" do
|
74
|
+
should_eventually "verify_attribute_disabled" do
|
94
75
|
@resource = Post
|
95
76
|
assert !attribute_disabled?('test')
|
96
77
|
Post.expects(:accessible_attributes).returns(['test'])
|
@@ -99,11 +80,7 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
99
80
|
assert attribute_disabled?('test')
|
100
81
|
end
|
101
82
|
|
102
|
-
|
103
|
-
|
104
|
-
=begin
|
105
|
-
|
106
|
-
def test_expand_tree_into_select_field
|
83
|
+
should_eventually "test_expand_tree_into_select_field" do
|
107
84
|
|
108
85
|
items = Page.roots
|
109
86
|
|
@@ -137,6 +114,4 @@ class Admin::FormHelperTest < ActiveSupport::TestCase
|
|
137
114
|
|
138
115
|
end
|
139
116
|
|
140
|
-
=end
|
141
|
-
|
142
117
|
end
|
@@ -9,23 +9,32 @@ class Admin::ResourcesHelperTest < ActiveSupport::TestCase
|
|
9
9
|
|
10
10
|
def render(*args); args; end
|
11
11
|
|
12
|
-
|
13
|
-
@resource = Post
|
14
|
-
params = { :action => "edit", :back_to => "/back_to_param" }
|
15
|
-
self.expects(:params).at_least_once.returns(params)
|
12
|
+
context "display_link_to_previous" do
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
should "verify display_link_to_previous" do
|
15
|
+
@resource = Post
|
16
|
+
params = { :action => "edit", :back_to => "/back_to_param" }
|
17
|
+
self.expects(:params).at_least_once.returns(params)
|
19
18
|
|
20
|
-
|
19
|
+
expected = [ "admin/helpers/resources/display_link_to_previous", { :message => "You're updating a Post." } ]
|
20
|
+
output = display_link_to_previous
|
21
|
+
|
22
|
+
assert_equal expected, output
|
23
|
+
end
|
21
24
|
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
context "remove_filter_link" do
|
27
|
+
|
28
|
+
should "return nil when blank" do
|
29
|
+
output = remove_filter_link("")
|
30
|
+
assert_nil output
|
31
|
+
end
|
32
|
+
|
33
|
+
should "return link when it's present"
|
34
|
+
|
26
35
|
end
|
27
36
|
|
28
|
-
context "
|
37
|
+
context "build_list" do
|
29
38
|
|
30
39
|
setup do
|
31
40
|
@model = TypusUser
|
@@ -34,17 +43,20 @@ class Admin::ResourcesHelperTest < ActiveSupport::TestCase
|
|
34
43
|
@resource = "typus_users"
|
35
44
|
end
|
36
45
|
|
37
|
-
should "
|
38
|
-
|
46
|
+
should "return a table" do
|
47
|
+
expected = [ "admin/typus_users/list", { :items => [] } ]
|
39
48
|
output = build_list(@model, @fields, @items, @resource)
|
40
|
-
assert_equal
|
49
|
+
assert_equal expected, output
|
41
50
|
end
|
42
51
|
|
43
|
-
should "
|
52
|
+
should "return a template" do
|
44
53
|
self.stubs(:render).returns("a_template")
|
45
54
|
File.stubs(:exist?).returns(true)
|
55
|
+
|
56
|
+
expected = "a_template"
|
46
57
|
output = build_list(@model, @fields, @items, @resource)
|
47
|
-
|
58
|
+
|
59
|
+
assert_equal expected, output
|
48
60
|
end
|
49
61
|
|
50
62
|
end
|
@@ -16,12 +16,9 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
16
16
|
default_url_options[:host] = 'test.host'
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
should "test_actions"
|
20
20
|
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_export
|
21
|
+
should_eventually "test_export" do
|
25
22
|
@resource = Post
|
26
23
|
|
27
24
|
params = { :controller => 'admin/posts', :action => 'index' }
|
@@ -35,12 +32,12 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
35
32
|
assert_equal expected, output
|
36
33
|
end
|
37
34
|
|
38
|
-
|
35
|
+
should_eventually "test_build_typus_list_with_empty_content_and_empty_header" do
|
39
36
|
output = build_typus_list([], :header => nil)
|
40
37
|
assert output.empty?
|
41
38
|
end
|
42
39
|
|
43
|
-
|
40
|
+
should_eventually "test_build_typus_list_with_content_and_header" do
|
44
41
|
output = build_typus_list(['item1', 'item2'], :header => "Chunky Bacon")
|
45
42
|
assert !output.empty?
|
46
43
|
|
@@ -51,7 +48,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
51
48
|
assert_equal expected, output
|
52
49
|
end
|
53
50
|
|
54
|
-
|
51
|
+
should_eventually "test_build_typus_list_with_content_without_header" do
|
55
52
|
output = build_typus_list(['item1', 'item2'])
|
56
53
|
expected = [ "admin/helpers/list", { :header => nil,
|
57
54
|
:options => {},
|
@@ -59,7 +56,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
59
56
|
assert_equal expected, output
|
60
57
|
end
|
61
58
|
|
62
|
-
|
59
|
+
should_eventually "test_search" do
|
63
60
|
|
64
61
|
@resource = TypusUser
|
65
62
|
|
@@ -82,23 +79,18 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
82
79
|
|
83
80
|
end
|
84
81
|
|
85
|
-
|
82
|
+
should_eventually "test_filters" do
|
86
83
|
@resource = TypusUser
|
87
84
|
@resource.expects(:typus_filters).returns(Array.new)
|
88
85
|
output = filters
|
89
86
|
assert output.nil?
|
90
87
|
end
|
91
88
|
|
92
|
-
|
93
|
-
end
|
89
|
+
should "test_filters_with_filters"
|
94
90
|
|
95
|
-
|
96
|
-
end
|
91
|
+
should "test_relationship_filter"
|
97
92
|
|
98
|
-
|
99
|
-
|
100
|
-
# FIXME
|
101
|
-
return
|
93
|
+
should_eventually "test_date_filter" do
|
102
94
|
|
103
95
|
@resource = TypusUser
|
104
96
|
filter = 'created_at'
|
@@ -138,10 +130,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
138
130
|
|
139
131
|
end
|
140
132
|
|
141
|
-
|
142
|
-
|
143
|
-
# FIXME
|
144
|
-
return
|
133
|
+
should_eventually "test_boolean_filter" do
|
145
134
|
|
146
135
|
@resource = TypusUser
|
147
136
|
filter = 'status'
|
@@ -177,7 +166,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
177
166
|
|
178
167
|
end
|
179
168
|
|
180
|
-
|
169
|
+
should_eventually "test_string_filter_when_values_are_strings" do
|
181
170
|
|
182
171
|
@resource = TypusUser
|
183
172
|
filter = 'role'
|
@@ -235,7 +224,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
235
224
|
|
236
225
|
end
|
237
226
|
|
238
|
-
|
227
|
+
should_eventually "test_string_filter_when_values_are_arrays_of_strings" do
|
239
228
|
|
240
229
|
@resource = TypusUser
|
241
230
|
filter = 'role'
|
@@ -272,7 +261,7 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
272
261
|
|
273
262
|
end
|
274
263
|
|
275
|
-
|
264
|
+
should_eventually "test_string_filter_when_empty_values" do
|
276
265
|
@resource = TypusUser
|
277
266
|
filter = 'role'
|
278
267
|
request = 'role=admin&page=1'
|
@@ -282,6 +271,4 @@ class Admin::SidebarHelperTest < ActiveSupport::TestCase
|
|
282
271
|
assert output.empty?
|
283
272
|
end
|
284
273
|
|
285
|
-
=end
|
286
|
-
|
287
274
|
end
|
@@ -15,12 +15,9 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
15
15
|
default_url_options[:host] = "test.host"
|
16
16
|
end
|
17
17
|
|
18
|
-
|
18
|
+
should_eventually "test_build_table" do
|
19
19
|
|
20
|
-
|
21
|
-
def test_build_table
|
22
|
-
|
23
|
-
@current_user = Factory(:typus_user)
|
20
|
+
current_user = Factory(:typus_user)
|
24
21
|
|
25
22
|
params = { :controller => 'admin/typus_users', :action => 'index' }
|
26
23
|
self.expects(:params).at_least_once.returns(params)
|
@@ -41,14 +38,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
41
38
|
|
42
39
|
end
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
=begin
|
41
|
+
should_eventually "test_table_header" do
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
@current_user = mock()
|
51
|
-
@current_user.expects(:can?).with("delete", TypusUser).returns(true)
|
43
|
+
current_user = mock()
|
44
|
+
current_user.expects(:can?).with("delete", TypusUser).returns(true)
|
52
45
|
|
53
46
|
fields = TypusUser.typus_fields_for(:list)
|
54
47
|
|
@@ -66,14 +59,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
66
59
|
|
67
60
|
end
|
68
61
|
|
69
|
-
|
70
|
-
|
71
|
-
=begin
|
62
|
+
should_eventually "test_table_header_with_params" do
|
72
63
|
|
73
|
-
|
74
|
-
|
75
|
-
@current_user = mock()
|
76
|
-
@current_user.expects(:can?).with("delete", TypusUser).returns(true)
|
64
|
+
current_user = mock()
|
65
|
+
current_user.expects(:can?).with("delete", TypusUser).returns(true)
|
77
66
|
|
78
67
|
fields = TypusUser.typus_fields_for(:list)
|
79
68
|
|
@@ -92,14 +81,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
92
81
|
|
93
82
|
end
|
94
83
|
|
95
|
-
|
96
|
-
|
97
|
-
=begin
|
98
|
-
|
99
|
-
def test_table_header_when_user_cannot_delete_items
|
84
|
+
should_eventually "test_table_header_when_user_cannot_delete_items" do
|
100
85
|
|
101
|
-
|
102
|
-
|
86
|
+
current_user = mock()
|
87
|
+
current_user.expects(:can?).with("delete", TypusUser).returns(false)
|
103
88
|
|
104
89
|
fields = TypusUser.typus_fields_for(:list)
|
105
90
|
|
@@ -117,14 +102,10 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
117
102
|
|
118
103
|
end
|
119
104
|
|
120
|
-
|
105
|
+
should_eventually "test_table_header_when_user_cannot_delete_items_with_params" do
|
121
106
|
|
122
|
-
=
|
123
|
-
|
124
|
-
def test_table_header_when_user_cannot_delete_items_with_params
|
125
|
-
|
126
|
-
@current_user = mock()
|
127
|
-
@current_user.expects(:can?).with("delete", TypusUser).returns(false)
|
107
|
+
current_user = mock()
|
108
|
+
current_user.expects(:can?).with("delete", TypusUser).returns(false)
|
128
109
|
|
129
110
|
fields = TypusUser.typus_fields_for(:list)
|
130
111
|
|
@@ -141,13 +122,9 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
141
122
|
|
142
123
|
end
|
143
124
|
|
144
|
-
|
145
|
-
|
146
|
-
=begin
|
125
|
+
should_eventually "test_table_belongs_to_field" do
|
147
126
|
|
148
|
-
|
149
|
-
|
150
|
-
@current_user = Factory(:typus_user)
|
127
|
+
current_user = Factory(:typus_user)
|
151
128
|
|
152
129
|
comment = comments(:without_post_id)
|
153
130
|
output = table_belongs_to_field("post", comment)
|
@@ -164,58 +141,42 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
164
141
|
|
165
142
|
end
|
166
143
|
|
167
|
-
|
168
|
-
|
169
|
-
=begin
|
170
|
-
|
171
|
-
def test_table_has_and_belongs_to_many_field
|
144
|
+
should_eventually "test_table_has_and_belongs_to_many_field" do
|
172
145
|
post = Factory(:post)
|
173
|
-
|
174
146
|
output = table_has_and_belongs_to_many_field("comments", post)
|
175
147
|
expected = %(<td>John, Me, Me</td>)
|
176
|
-
|
177
148
|
assert_equal expected.strip, output
|
178
149
|
end
|
179
150
|
|
180
|
-
|
181
|
-
|
182
|
-
should "test_table_string_field" do
|
151
|
+
should_eventually "test_table_string_field" do
|
183
152
|
post = Factory(:post)
|
184
|
-
|
185
153
|
output = table_string_field(:title, post, :created_at)
|
186
154
|
expected = %(<td class="title">#{post.title}</td>)
|
187
|
-
|
188
155
|
assert_equal expected.strip, output
|
189
156
|
end
|
190
157
|
|
191
|
-
|
158
|
+
should_eventually "test_table_string_field_with_link" do
|
192
159
|
post = Factory(:post)
|
193
|
-
|
194
160
|
output = table_string_field(:title, post, :title)
|
195
161
|
expected = %(<td class="title">#{post.title}</td>)
|
196
|
-
|
197
162
|
assert_equal expected.strip, output
|
198
163
|
end
|
199
164
|
|
200
|
-
|
165
|
+
should_eventually "table_tree_field_when_displays_a_parent" do
|
201
166
|
page = Factory(:page)
|
202
|
-
|
203
167
|
output = table_tree_field("test", page)
|
204
168
|
expected = "<td>—</td>"
|
205
|
-
|
206
169
|
assert_equal expected, output
|
207
170
|
end
|
208
171
|
|
209
|
-
|
172
|
+
should_eventually "table_tree_field_when_displays_a_children" do
|
210
173
|
page = Factory(:page, :status => "unpublished")
|
211
|
-
|
212
174
|
output = table_tree_field("test", page)
|
213
175
|
expected = "<td>—</td>"
|
214
|
-
|
215
176
|
assert_equal expected, output
|
216
177
|
end
|
217
178
|
|
218
|
-
|
179
|
+
should_eventually "test_table_datetime_field" do
|
219
180
|
post = Factory(:post)
|
220
181
|
Time::DATE_FORMATS[:post_short] = "%m/%y"
|
221
182
|
|
@@ -225,7 +186,7 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
225
186
|
assert_equal expected.strip, output
|
226
187
|
end
|
227
188
|
|
228
|
-
|
189
|
+
should_eventually "test_table_datetime_field_with_link" do
|
229
190
|
post = Factory(:post)
|
230
191
|
Time::DATE_FORMATS[:post_short] = "%m/%y"
|
231
192
|
|
@@ -235,10 +196,7 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
235
196
|
assert_equal expected.strip, output
|
236
197
|
end
|
237
198
|
|
238
|
-
|
239
|
-
|
240
|
-
# FIXME: NameError: undefined local variable or method `controller' for
|
241
|
-
def test_table_boolean_field
|
199
|
+
should_eventually "test_table_boolean_field" do
|
242
200
|
|
243
201
|
post = Factory(:typus_user)
|
244
202
|
output = table_boolean_field("status", post)
|
@@ -258,6 +216,4 @@ class Admin::TableHelperTest < ActiveSupport::TestCase
|
|
258
216
|
|
259
217
|
end
|
260
218
|
|
261
|
-
=end
|
262
|
-
|
263
219
|
end
|