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
@@ -1,118 +0,0 @@
|
|
1
|
-
document.observe("dom:loaded", function() {
|
2
|
-
function handleRemote(element) {
|
3
|
-
var method, url, params;
|
4
|
-
|
5
|
-
if (element.tagName.toLowerCase() === 'form') {
|
6
|
-
method = element.readAttribute('method') || 'post';
|
7
|
-
url = element.readAttribute('action');
|
8
|
-
params = element.serialize(true);
|
9
|
-
} else {
|
10
|
-
method = element.readAttribute('data-method') || 'get';
|
11
|
-
url = element.readAttribute('href');
|
12
|
-
params = {};
|
13
|
-
}
|
14
|
-
|
15
|
-
var event = element.fire("ajax:before");
|
16
|
-
if (event.stopped) return false;
|
17
|
-
|
18
|
-
new Ajax.Request(url, {
|
19
|
-
method: method,
|
20
|
-
parameters: params,
|
21
|
-
asynchronous: true,
|
22
|
-
evalScripts: true,
|
23
|
-
|
24
|
-
onLoading: function(request) { element.fire("ajax:loading", {request: request}); },
|
25
|
-
onLoaded: function(request) { element.fire("ajax:loaded", {request: request}); },
|
26
|
-
onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
|
27
|
-
onComplete: function(request) { element.fire("ajax:complete", {request: request}); },
|
28
|
-
onSuccess: function(request) { element.fire("ajax:success", {request: request}); },
|
29
|
-
onFailure: function(request) { element.fire("ajax:failure", {request: request}); }
|
30
|
-
});
|
31
|
-
|
32
|
-
element.fire("ajax:after");
|
33
|
-
}
|
34
|
-
|
35
|
-
function handleMethod(element) {
|
36
|
-
var method, url, token_name, token;
|
37
|
-
|
38
|
-
method = element.readAttribute('data-method');
|
39
|
-
url = element.readAttribute('href');
|
40
|
-
csrf_param = $$('meta[name=csrf-param]').first();
|
41
|
-
csrf_token = $$('meta[name=csrf-token]').first();
|
42
|
-
|
43
|
-
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
44
|
-
element.parentNode.appendChild(form);
|
45
|
-
|
46
|
-
if (method != 'post') {
|
47
|
-
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
48
|
-
form.appendChild(field);
|
49
|
-
}
|
50
|
-
|
51
|
-
if (csrf_param) {
|
52
|
-
var param = csrf_param.readAttribute('content');
|
53
|
-
var token = csrf_token.readAttribute('content');
|
54
|
-
var field = new Element('input', { type: 'hidden', name: param, value: token });
|
55
|
-
form.appendChild(field);
|
56
|
-
}
|
57
|
-
|
58
|
-
form.submit();
|
59
|
-
}
|
60
|
-
|
61
|
-
$(document.body).observe("click", function(event) {
|
62
|
-
var message = event.findElement().readAttribute('data-confirm');
|
63
|
-
if (message && !confirm(message)) {
|
64
|
-
event.stop();
|
65
|
-
return false;
|
66
|
-
}
|
67
|
-
|
68
|
-
var element = event.findElement("a[data-remote]");
|
69
|
-
if (element) {
|
70
|
-
handleRemote(element);
|
71
|
-
event.stop();
|
72
|
-
return true;
|
73
|
-
}
|
74
|
-
|
75
|
-
var element = event.findElement("a[data-method]");
|
76
|
-
if (element) {
|
77
|
-
handleMethod(element);
|
78
|
-
event.stop();
|
79
|
-
return true;
|
80
|
-
}
|
81
|
-
});
|
82
|
-
|
83
|
-
// TODO: I don't think submit bubbles in IE
|
84
|
-
$(document.body).observe("submit", function(event) {
|
85
|
-
var element = event.findElement(),
|
86
|
-
message = element.readAttribute('data-confirm');
|
87
|
-
if (message && !confirm(message)) {
|
88
|
-
event.stop();
|
89
|
-
return false;
|
90
|
-
}
|
91
|
-
|
92
|
-
var inputs = element.select("input[type=submit][data-disable-with]");
|
93
|
-
inputs.each(function(input) {
|
94
|
-
input.disabled = true;
|
95
|
-
input.writeAttribute('data-original-value', input.value);
|
96
|
-
input.value = input.readAttribute('data-disable-with');
|
97
|
-
});
|
98
|
-
|
99
|
-
var element = event.findElement("form[data-remote]");
|
100
|
-
if (element) {
|
101
|
-
handleRemote(element);
|
102
|
-
event.stop();
|
103
|
-
}
|
104
|
-
});
|
105
|
-
|
106
|
-
$(document.body).observe("ajax:after", function(event) {
|
107
|
-
var element = event.findElement();
|
108
|
-
|
109
|
-
if (element.tagName.toLowerCase() === 'form') {
|
110
|
-
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
111
|
-
inputs.each(function(input) {
|
112
|
-
input.value = input.readAttribute('data-original-value');
|
113
|
-
input.writeAttribute('data-original-value', null);
|
114
|
-
input.disabled = false;
|
115
|
-
});
|
116
|
-
}
|
117
|
-
});
|
118
|
-
});
|
@@ -1,9 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
ENV_PATH = File.expand_path('../../config/environment', __FILE__)
|
5
|
-
BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
|
6
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
7
|
-
|
8
|
-
require BOOT_PATH
|
9
|
-
require 'rails/commands'
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::DashboardControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
context "When authentication is http_basic" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
Typus.stubs(:authentication).returns(:http_basic)
|
9
|
-
end
|
10
|
-
|
11
|
-
should "return a 401 message when no credentials sent" do
|
12
|
-
get :show
|
13
|
-
assert_response 401
|
14
|
-
end
|
15
|
-
|
16
|
-
should "authenticate user" do
|
17
|
-
@request.env['HTTP_AUTHORIZATION'] = 'Basic ' + Base64::encode64("admin:columbia")
|
18
|
-
get :show
|
19
|
-
assert_response :success
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::DashboardControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
context "When authentication is none" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
Typus.stubs(:authentication).returns(:none)
|
9
|
-
end
|
10
|
-
|
11
|
-
should "render dashboard" do
|
12
|
-
get :show
|
13
|
-
assert_response :success
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::CategoriesControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
@first_category = Factory(:category, :position => 1)
|
7
|
-
@second_category = Factory(:category, :position => 2)
|
8
|
-
end
|
9
|
-
|
10
|
-
should "verify referer" do
|
11
|
-
get :position, { :id => @first_category.id, :go => 'move_lower' }
|
12
|
-
assert_response :redirect
|
13
|
-
assert_redirected_to @request.env['HTTP_REFERER']
|
14
|
-
end
|
15
|
-
|
16
|
-
should "position item one step down" do
|
17
|
-
get :position, { :id => @first_category.id, :go => 'move_lower' }
|
18
|
-
|
19
|
-
assert_equal "Record moved lower.", flash[:notice]
|
20
|
-
assert_equal 2, @first_category.reload.position
|
21
|
-
assert_equal 1, @second_category.reload.position
|
22
|
-
end
|
23
|
-
|
24
|
-
should "position item one step up" do
|
25
|
-
get :position, { :id => @second_category.id, :go => 'move_higher' }
|
26
|
-
|
27
|
-
assert_equal "Record moved higher.", flash[:notice]
|
28
|
-
assert_equal 2, @first_category.reload.position
|
29
|
-
assert_equal 1, @second_category.reload.position
|
30
|
-
end
|
31
|
-
|
32
|
-
should "position top item to bottom" do
|
33
|
-
get :position, { :id => @first_category.id, :go => 'move_to_bottom' }
|
34
|
-
assert_equal "Record moved to bottom.", flash[:notice]
|
35
|
-
assert_equal 2, @first_category.reload.position
|
36
|
-
end
|
37
|
-
|
38
|
-
should "position bottom item to top" do
|
39
|
-
get :position, { :id => @second_category.id, :go => 'move_to_top' }
|
40
|
-
assert_equal "Record moved to top.", flash[:notice]
|
41
|
-
assert_equal 1, @second_category.reload.position
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
context "Overwrite action_after_save" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
Typus::Resources.expects(:action_after_save).returns("index")
|
9
|
-
end
|
10
|
-
|
11
|
-
should "create an item and redirect to index" do
|
12
|
-
assert_difference 'Post.count' do
|
13
|
-
post :create, { :post => { :title => 'This is another title', :body => 'Body' } }
|
14
|
-
assert_response :redirect
|
15
|
-
assert_redirected_to :action => 'index'
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
should "update an item and redirect to index" do
|
20
|
-
post :update, { :id => Factory(:post).id, :title => 'Updated' }
|
21
|
-
assert_response :redirect
|
22
|
-
assert_redirected_to :action => 'index'
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
should "render index" do
|
6
|
-
get :index
|
7
|
-
assert_response :success
|
8
|
-
assert_template 'index'
|
9
|
-
end
|
10
|
-
|
11
|
-
should "render new" do
|
12
|
-
get :new
|
13
|
-
assert_response :success
|
14
|
-
assert_template 'new'
|
15
|
-
end
|
16
|
-
|
17
|
-
should "create" do
|
18
|
-
assert_difference 'Post.count' do
|
19
|
-
post :create, { :post => { :title => 'This is another title', :body => 'Body' } }
|
20
|
-
assert_response :redirect
|
21
|
-
assert_redirected_to :controller => 'admin/posts', :action => 'edit', :id => Post.last
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
should "render show" do
|
26
|
-
get :show, { :id => Factory(:post).id }
|
27
|
-
assert_response :success
|
28
|
-
assert_template 'show'
|
29
|
-
end
|
30
|
-
|
31
|
-
should "render edit" do
|
32
|
-
get :edit, { :id => Factory(:post).id }
|
33
|
-
assert_response :success
|
34
|
-
assert_template 'edit'
|
35
|
-
end
|
36
|
-
|
37
|
-
should "update" do
|
38
|
-
_post = Factory(:post)
|
39
|
-
post :update, { :id => _post.id, :title => 'Updated' }
|
40
|
-
assert_response :redirect
|
41
|
-
assert_redirected_to :controller => 'admin/posts', :action => 'edit', :id => _post.id
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
setup do
|
6
|
-
Post.delete_all
|
7
|
-
@post = Factory(:post)
|
8
|
-
end
|
9
|
-
|
10
|
-
should "render index and return xml" do
|
11
|
-
expected = <<-RAW
|
12
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
13
|
-
<posts type="array">
|
14
|
-
<post>
|
15
|
-
<title>#{@post.title}</title>
|
16
|
-
<status>#{@post.status}</status>
|
17
|
-
</post>
|
18
|
-
</posts>
|
19
|
-
RAW
|
20
|
-
|
21
|
-
get :index, :format => "xml"
|
22
|
-
|
23
|
-
assert_response :success
|
24
|
-
assert_equal expected, @response.body
|
25
|
-
end
|
26
|
-
|
27
|
-
should "render index and return csv" do
|
28
|
-
expected = <<-RAW
|
29
|
-
title;status
|
30
|
-
#{@post.title};#{@post.status}
|
31
|
-
RAW
|
32
|
-
|
33
|
-
get :index, :format => "csv"
|
34
|
-
|
35
|
-
assert_response :success
|
36
|
-
assert_equal expected, @response.body
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
# Here we test everything related to forms.
|
4
|
-
|
5
|
-
class Admin::PostsControllerTest < ActionController::TestCase
|
6
|
-
|
7
|
-
# Our model definition is:
|
8
|
-
#
|
9
|
-
# Post:
|
10
|
-
# fields:
|
11
|
-
# form: title, body, created_at, status, published_at
|
12
|
-
#
|
13
|
-
should "verify forms" do
|
14
|
-
|
15
|
-
get :new
|
16
|
-
assert_template :new
|
17
|
-
|
18
|
-
assert_select "form"
|
19
|
-
|
20
|
-
# We have 3 inputs: 1 hidden which is the UTF8 stuff, one which is the
|
21
|
-
# Post#title and finally the submit button.
|
22
|
-
|
23
|
-
assert_select "form input", 3
|
24
|
-
|
25
|
-
# Post#title: Input
|
26
|
-
assert_select 'label[for="post_title"]'
|
27
|
-
assert_select 'input#post_title[type="text"]'
|
28
|
-
|
29
|
-
# We have 1 textarea
|
30
|
-
assert_select "form textarea", 1
|
31
|
-
|
32
|
-
# Post#body: Text Area
|
33
|
-
assert_select 'label[for="post_body"]'
|
34
|
-
assert_select 'textarea#post_body'
|
35
|
-
|
36
|
-
# We have 6 selectors
|
37
|
-
assert_select "form select", 6
|
38
|
-
|
39
|
-
# Post#created_at: Datetime
|
40
|
-
assert_select 'label[for="post_created_at"]'
|
41
|
-
assert_select 'select#post_created_at_1i'
|
42
|
-
assert_select 'select#post_created_at_2i'
|
43
|
-
assert_select 'select#post_created_at_3i'
|
44
|
-
assert_select 'select#post_created_at_4i'
|
45
|
-
assert_select 'select#post_created_at_5i'
|
46
|
-
|
47
|
-
# Post#status: Selector
|
48
|
-
assert_select 'label[for="post_status"]'
|
49
|
-
assert_select 'select#post_status'
|
50
|
-
|
51
|
-
# We have 1 template
|
52
|
-
|
53
|
-
# Post#published_at: Datetime
|
54
|
-
assert_match "templates#datepicker_template_published_at", @response.body
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,100 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
class Admin::PostsControllerTest < ActionController::TestCase
|
4
|
-
|
5
|
-
context "Root" do
|
6
|
-
|
7
|
-
setup do
|
8
|
-
editor = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
9
|
-
@post = Factory(:post, :typus_user => editor)
|
10
|
-
end
|
11
|
-
|
12
|
-
should "verify_root_can_edit_any_record" do
|
13
|
-
Post.all.each do |post|
|
14
|
-
get :edit, { :id => post.id }
|
15
|
-
assert_response :success
|
16
|
-
assert_template 'edit'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
should "verify_admin_updating_an_item_does_not_change_typus_user_id_if_not_defined" do
|
21
|
-
post :update, { :id => @post.id, :post => { :title => 'Updated by admin' } }
|
22
|
-
post_updated = Post.find(@post.id)
|
23
|
-
assert_equal @post.typus_user_id, post_updated.typus_user_id
|
24
|
-
end
|
25
|
-
|
26
|
-
should "verify_admin_updating_an_item_does_change_typus_user_id_to_whatever_admin_wants" do
|
27
|
-
post :update, { :id => @post.id, :post => { :title => 'Updated', :typus_user_id => 108 } }
|
28
|
-
post_updated = Post.find(@post.id)
|
29
|
-
assert_equal 108, post_updated.typus_user_id
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
context "No root" do
|
35
|
-
|
36
|
-
setup do
|
37
|
-
@typus_user = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
|
38
|
-
@request.session[:typus_user_id] = @typus_user.id
|
39
|
-
assert @typus_user.is_not_root?
|
40
|
-
@request.env['HTTP_REFERER'] = '/admin/posts'
|
41
|
-
end
|
42
|
-
|
43
|
-
should "verify_editor_can_show_any_record" do
|
44
|
-
Post.all.each do |post|
|
45
|
-
get :show, { :id => post.id }
|
46
|
-
assert_response :success
|
47
|
-
assert_template 'show'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
should "verify_editor_tried_to_edit_a_post_owned_by_himself" do
|
52
|
-
_post = Factory(:post, :typus_user => @typus_user)
|
53
|
-
get :edit, { :id => _post.id }
|
54
|
-
assert_response :success
|
55
|
-
end
|
56
|
-
|
57
|
-
should "verify_editor_tries_to_edit_a_post_owned_by_the_admin" do
|
58
|
-
get :edit, { :id => Factory(:post).id }
|
59
|
-
|
60
|
-
assert_response :redirect
|
61
|
-
assert_redirected_to @request.env['HTTP_REFERER']
|
62
|
-
assert_equal "You don't have permission to access this item.", flash[:alert]
|
63
|
-
end
|
64
|
-
|
65
|
-
should "verify_editor_tries_to_show_a_post_owned_by_the_admin" do
|
66
|
-
get :show, { :id => Factory(:post).id }
|
67
|
-
assert_response :success
|
68
|
-
end
|
69
|
-
|
70
|
-
should "verify_editor_tries_to_show_a_post_owned_by_the_admin whe only user items" do
|
71
|
-
|
72
|
-
Typus::Resources.expects(:only_user_items).returns(true)
|
73
|
-
post = Factory(:post)
|
74
|
-
get :show, { :id => post.id }
|
75
|
-
|
76
|
-
assert_response :redirect
|
77
|
-
assert_redirected_to @request.env['HTTP_REFERER']
|
78
|
-
assert_equal "You don't have permission to access this item.", flash[:alert]
|
79
|
-
end
|
80
|
-
|
81
|
-
should "verify_typus_user_id_of_item_when_creating_record" do
|
82
|
-
post :create, { :post => { :title => "Chunky Bacon", :body => "Lorem ipsum ..." } }
|
83
|
-
post_ = Post.find_by_title("Chunky Bacon")
|
84
|
-
|
85
|
-
assert_equal @request.session[:typus_user_id], post_.typus_user_id
|
86
|
-
end
|
87
|
-
|
88
|
-
should "verify_editor_updating_an_item_does_not_change_typus_user_id" do
|
89
|
-
|
90
|
-
[ 108, nil ].each do |typus_user_id|
|
91
|
-
_post = Factory(:post, :typus_user => @typus_user)
|
92
|
-
post :update, { :id => _post.id, :post => { :title => 'Updated', :typus_user_id => @typus_user.id } }
|
93
|
-
post_updated = Post.find(_post.id)
|
94
|
-
assert_equal @request.session[:typus_user_id], post_updated.typus_user_id
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|