typus 3.0.11 → 3.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. data/README.md +4 -1
  2. data/app/helpers/admin/relationships_helper.rb +2 -2
  3. data/app/views/admin/dashboard/_applications.html.erb +1 -1
  4. data/app/views/admin/helpers/resources/_errors.html.erb +1 -1
  5. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +1 -1
  6. data/app/views/admin/resources/index.html.erb +2 -2
  7. data/app/views/admin/templates/_has_n.html.erb +1 -1
  8. data/app/views/admin/templates/_has_one.html.erb +1 -1
  9. data/config/locales/typus.ca.yml +1 -1
  10. data/config/locales/typus.de.models.yml +6 -5
  11. data/config/locales/typus.de.yml +39 -36
  12. data/config/locales/typus.el.yml +1 -1
  13. data/config/locales/typus.es.yml +1 -1
  14. data/config/locales/typus.fr.yml +1 -1
  15. data/config/locales/typus.hu.yml +1 -1
  16. data/config/locales/typus.locale.yml.template +1 -1
  17. data/config/locales/typus.pt-BR.yml +1 -1
  18. data/config/locales/typus.pt-PT.yml +1 -1
  19. data/config/locales/typus.ru.yml +1 -1
  20. data/config/locales/typus.zh-CN.yml +1 -1
  21. data/lib/typus/version.rb +1 -1
  22. data/typus.gemspec +7 -4
  23. metadata +16 -164
  24. data/test/app/controllers/admin/account_controller_test.rb +0 -106
  25. data/test/app/controllers/admin/assets_controller_test.rb +0 -156
  26. data/test/app/controllers/admin/base_controller_test.rb +0 -41
  27. data/test/app/controllers/admin/birds_controller_test.rb +0 -42
  28. data/test/app/controllers/admin/cases_controller_test.rb +0 -21
  29. data/test/app/controllers/admin/categories_controller_test.rb +0 -134
  30. data/test/app/controllers/admin/comments_controller_test.rb +0 -79
  31. data/test/app/controllers/admin/dashboard_controller_test.rb +0 -162
  32. data/test/app/controllers/admin/image_holders_controller_test.rb +0 -75
  33. data/test/app/controllers/admin/invoices_controller_test.rb +0 -78
  34. data/test/app/controllers/admin/orders_controller_test.rb +0 -18
  35. data/test/app/controllers/admin/pages_controller_test.rb +0 -37
  36. data/test/app/controllers/admin/posts_controller_test.rb +0 -770
  37. data/test/app/controllers/admin/projects_controller_test.rb +0 -52
  38. data/test/app/controllers/admin/session_controller_test.rb +0 -92
  39. data/test/app/controllers/admin/status_controller_test.rb +0 -54
  40. data/test/app/controllers/admin/typus_users_controller_test.rb +0 -156
  41. data/test/app/controllers/admin/users_controller_test.rb +0 -106
  42. data/test/app/controllers/admin/views_controller_test.rb +0 -36
  43. data/test/app/helpers/admin/base_helper_test.rb +0 -83
  44. data/test/app/helpers/admin/dashboard_helper_test.rb +0 -32
  45. data/test/app/helpers/admin/file_preview_helper_test.rb +0 -90
  46. data/test/app/helpers/admin/filters_helper_test.rb +0 -166
  47. data/test/app/helpers/admin/form_helper_test.rb +0 -126
  48. data/test/app/helpers/admin/list_helper_test.rb +0 -76
  49. data/test/app/helpers/admin/relationships_helper_test.rb +0 -19
  50. data/test/app/helpers/admin/resources_helper_test.rb +0 -46
  51. data/test/app/helpers/admin/search_helper_test.rb +0 -60
  52. data/test/app/helpers/admin/sidebar_helper_test.rb +0 -34
  53. data/test/app/helpers/admin/table_helper_test.rb +0 -241
  54. data/test/app/mailers/admin/mailer_test.rb +0 -32
  55. data/test/app/models/admin_user_test.rb +0 -5
  56. data/test/app/models/typus_user_roles_test.rb +0 -125
  57. data/test/app/models/typus_user_test.rb +0 -228
  58. data/test/config/routes_test.rb +0 -29
  59. data/test/factories.rb +0 -122
  60. data/test/fixtures/config/broken/application.yml +0 -68
  61. data/test/fixtures/config/broken/application_roles.yml +0 -20
  62. data/test/fixtures/config/broken/empty.yml +0 -0
  63. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  64. data/test/fixtures/config/broken/undefined.yml +0 -3
  65. data/test/fixtures/config/broken/undefined_roles.yml +0 -6
  66. data/test/fixtures/config/default/typus.yml +0 -13
  67. data/test/fixtures/config/default/typus_roles.yml +0 -2
  68. data/test/fixtures/config/empty/empty_01.yml +0 -0
  69. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  70. data/test/fixtures/config/empty/empty_02.yml +0 -0
  71. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  72. data/test/fixtures/config/locales/es.yml +0 -10
  73. data/test/fixtures/config/namespaced/application.yml +0 -5
  74. data/test/fixtures/config/namespaced/application_roles.yml +0 -2
  75. data/test/fixtures/config/ordered/001_roles.yml +0 -2
  76. data/test/fixtures/config/ordered/002_roles.yml +0 -2
  77. data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
  78. data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
  79. data/test/lib/support/active_record_test.rb +0 -174
  80. data/test/lib/support/fake_user_test.rb +0 -63
  81. data/test/lib/support/hash_test.rb +0 -29
  82. data/test/lib/support/object_test.rb +0 -17
  83. data/test/lib/support/string_test.rb +0 -98
  84. data/test/lib/typus/configuration_test.rb +0 -46
  85. data/test/lib/typus/controller/actions_test.rb +0 -141
  86. data/test/lib/typus/controller/associations_test.rb +0 -7
  87. data/test/lib/typus/controller/autocomplete_test.rb +0 -7
  88. data/test/lib/typus/controller/filters_test.rb +0 -73
  89. data/test/lib/typus/controller/format_test.rb +0 -7
  90. data/test/lib/typus/i18n_test.rb +0 -9
  91. data/test/lib/typus/orm/active_record/class_methods_test.rb +0 -390
  92. data/test/lib/typus/orm/active_record/search_test.rb +0 -330
  93. data/test/lib/typus/regex_test.rb +0 -53
  94. data/test/lib/typus/resources_test.rb +0 -41
  95. data/test/lib/typus_test.rb +0 -142
  96. data/test/test_helper.rb +0 -15
@@ -1,52 +0,0 @@
1
- require "test_helper"
2
-
3
- =begin
4
-
5
- What's being tested here?
6
-
7
- - HasManyThrough
8
-
9
- =end
10
-
11
- class Admin::ProjectsControllerTest < ActionController::TestCase
12
-
13
- setup do
14
- @typus_user = Factory(:typus_user)
15
- @request.session[:typus_user_id] = @typus_user.id
16
-
17
- @project = Factory(:project)
18
- @user = @project.user
19
- end
20
-
21
- should_eventually "be able to destroy items" do
22
- get :destroy, :id => @user.id, :method => :delete
23
-
24
- assert_response :redirect
25
- assert_equal "User successfully removed.", flash[:notice]
26
- assert_redirected_to :action => :index
27
- end
28
-
29
- context "relate colaborators to project" do
30
-
31
- setup do
32
- @request.env['HTTP_REFERER'] = "/admin/projects/edit/#{@project.id}"
33
- end
34
-
35
- should "work" do
36
- user = Factory(:user)
37
-
38
- assert_difference('@project.collaborators.count') do
39
- post :relate, { :id => @project.id,
40
- :related => { :model => 'User', :id => user.id, :association_name => 'collaborators' } }
41
- end
42
-
43
- assert_response :redirect
44
- assert_redirected_to @request.env['HTTP_REFERER']
45
- assert_equal "Project successfully updated.", flash[:notice]
46
- end
47
-
48
- should_eventually "not allow to add collaborator twice"
49
-
50
- end
51
-
52
- end
@@ -1,92 +0,0 @@
1
- require "test_helper"
2
-
3
- =begin
4
-
5
- What's being tested here?
6
-
7
- - Sessions
8
-
9
- =end
10
-
11
- class Admin::SessionControllerTest < ActionController::TestCase
12
-
13
- context "Setup" do
14
-
15
- should "redirect_to_new_admin_account_when_no_admin_users" do
16
- get :new
17
- assert_response :redirect
18
- assert_redirected_to new_admin_account_path
19
- end
20
-
21
- end
22
-
23
- context "With users" do
24
-
25
- setup do
26
- @typus_user = Factory(:typus_user)
27
- end
28
-
29
- should "render new" do
30
- get :new
31
- assert_response :success
32
- end
33
-
34
- should "render new and verify title and header" do
35
- get :new
36
- assert_select "title", "Typus &mdash; Sign in"
37
- assert_select "h1", "Typus"
38
- end
39
-
40
- should "render session layout" do
41
- get :new
42
- assert_template "new"
43
- assert_template "layouts/admin/session"
44
- end
45
-
46
- should "verify_typus_sign_in_layout_does_not_include_recover_password_link" do
47
- get :new
48
- assert !@response.body.include?("Recover password")
49
- end
50
-
51
- should "verify new includes recover_password_link when mailer_sender is set" do
52
- Typus.expects(:mailer_sender).returns("john@example.com")
53
- get :new
54
- assert @response.body.include?("Recover password")
55
- end
56
-
57
- should "not_create_session_for_invalid_users" do
58
- post :create, { :typus_user => { :email => "john@example.com", :password => "XXXXXXXX" } }
59
- assert_response :redirect
60
- assert_redirected_to new_admin_session_path
61
- end
62
-
63
- should "not_create_session_for_a_disabled_user" do
64
- typus_user = Factory(:typus_user, :email => "disabled@example.com", :status => false)
65
-
66
- post :create, { :typus_user => { :email => typus_user.email, :password => "12345678" } }
67
-
68
- assert_nil @request.session[:typus_user_id]
69
- assert_response :redirect
70
- assert_redirected_to new_admin_session_path
71
- end
72
-
73
- should "create_session_for_an_enabled_user" do
74
- post :create, { :typus_user => { :email => @typus_user.email, :password => "12345678" } }
75
-
76
- assert_equal @typus_user.id, @request.session[:typus_user_id]
77
- assert_response :redirect
78
- assert_redirected_to admin_dashboard_path
79
- end
80
-
81
- should "destroy" do
82
- delete :destroy
83
-
84
- assert_nil @request.session[:typus_user_id]
85
- assert_response :redirect
86
- assert_redirected_to new_admin_session_path
87
- assert flash.empty?
88
- end
89
-
90
- end
91
-
92
- end
@@ -1,54 +0,0 @@
1
- require "test_helper"
2
-
3
- =begin
4
-
5
- What's being tested here?
6
-
7
- - Resource controller (which is not associated with a model).
8
-
9
- =end
10
-
11
- class Admin::StatusControllerTest < ActionController::TestCase
12
-
13
- context "Admin" do
14
-
15
- setup do
16
- @request.session[:typus_user_id] = Factory(:typus_user).id
17
- end
18
-
19
- should "render index" do
20
- get :index
21
- assert_response :success
22
- assert_template 'index'
23
- end
24
-
25
- end
26
-
27
- context "Editor" do
28
-
29
- setup do
30
- @request.session[:typus_user_id] = Factory(:typus_user, :role => "editor").id
31
- end
32
-
33
- should "not render index" do
34
- get :index
35
- assert_response :unprocessable_entity
36
- end
37
-
38
- end
39
-
40
- context "Not logged user" do
41
-
42
- setup do
43
- @request.session[:typus_user_id] = nil
44
- end
45
-
46
- should "not render index and redirect to new_admin_session_path with back_to" do
47
- get :index
48
- assert_response :redirect
49
- assert_redirected_to new_admin_session_path(:back_to => '/admin/status')
50
- end
51
-
52
- end
53
-
54
- end
@@ -1,156 +0,0 @@
1
- require "test_helper"
2
-
3
- =begin
4
-
5
- What's being tested here?
6
-
7
- - Stuff related to Admin users. (a.k.a. Profile Stuff)
8
-
9
- =end
10
-
11
- class Admin::TypusUsersControllerTest < ActionController::TestCase
12
-
13
- context "Admin" do
14
-
15
- setup do
16
- @typus_user = Factory(:typus_user)
17
- @typus_user_editor = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
18
- @request.session[:typus_user_id] = @typus_user.id
19
- @request.env['HTTP_REFERER'] = '/admin/typus_users'
20
- end
21
-
22
- should "be able to render new" do
23
- get :new
24
- assert_response :success
25
- end
26
-
27
- should "not be able to toogle his status" do
28
- get :toggle, { :id => @typus_user.id, :field => 'status' }
29
- assert_response :unprocessable_entity
30
- end
31
-
32
- should "be able to toggle other users status" do
33
- get :toggle, { :id => @typus_user_editor.id, :field => 'status' }
34
- assert_response :redirect
35
- assert_redirected_to @request.env['HTTP_REFERER']
36
- assert_equal "Typus user successfully updated.", flash[:notice]
37
- end
38
-
39
- should "not be able to destroy himself" do
40
- delete :destroy, :id => @typus_user.id
41
- assert_response :unprocessable_entity
42
- end
43
-
44
- should "be able to destroy other users" do
45
- assert_difference('TypusUser.count', -1) do
46
- delete :destroy, :id => @typus_user_editor.id
47
- end
48
-
49
- assert_response :redirect
50
- assert_redirected_to @request.env['HTTP_REFERER']
51
- assert_equal "Typus user successfully removed.", flash[:notice]
52
- end
53
-
54
- should "not be able to change his role" do
55
- post :update, :id => @typus_user.id, :typus_user => { :role => 'editor' }
56
- assert_response :unprocessable_entity
57
- end
58
-
59
- should "be able to update other users role" do
60
- post :update, :id => @typus_user_editor.id, :typus_user => { :role => 'admin' }
61
- assert_response :redirect
62
- assert_redirected_to "/admin/typus_users/edit/#{@typus_user_editor.id}"
63
- assert_equal "Typus user successfully updated.", flash[:notice]
64
- end
65
-
66
- end
67
-
68
- context "Editor" do
69
-
70
- setup do
71
- @request.env['HTTP_REFERER'] = '/admin/typus_users'
72
- @editor = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
73
- @request.session[:typus_user_id] = @editor.id
74
- end
75
-
76
- should "not be able to create typus_users" do
77
- get :new
78
- assert_response :unprocessable_entity
79
- end
80
-
81
- should "be able to edit his profile" do
82
- get :edit, :id => @editor.id
83
- assert_response :success
84
- end
85
-
86
- should "be able to update his profile" do
87
- post :update, :id => @editor.id, :typus_user => { :role => 'editor' }
88
- assert_response :redirect
89
- assert_redirected_to "/admin/typus_users/edit/#{@editor.id}"
90
- assert_equal "Typus user successfully updated.", flash[:notice]
91
- end
92
-
93
- should "not be able to change his role" do
94
- post :update, :id => @editor.id, :typus_user => { :role => 'admin' }
95
- assert_response :unprocessable_entity
96
- end
97
-
98
- should "not be able to destroy his profile" do
99
- delete :destroy, :id => @editor.id
100
- assert_response :unprocessable_entity
101
- end
102
-
103
- should "not be able to toggle his status" do
104
- get :toggle, { :id => @editor.id, :field => 'status' }
105
- assert_response :unprocessable_entity
106
- end
107
-
108
- should "not be able to edit other profiles" do
109
- get :edit, :id => Factory(:typus_user).id
110
- assert_response :unprocessable_entity
111
- end
112
-
113
- should "not be able to update other profiles" do
114
- post :update, :id => Factory(:typus_user).id, :typus_user => { :role => 'admin' }
115
- assert_response :unprocessable_entity
116
- end
117
-
118
- should "not be able to destroy other profiles" do
119
- delete :destroy, :id => Factory(:typus_user).id
120
- assert_response :unprocessable_entity
121
- end
122
-
123
- should "not be able to toggle other profiles status" do
124
- get :toggle, { :id => Factory(:typus_user).id, :field => 'status' }
125
- assert_response :unprocessable_entity
126
- end
127
-
128
- end
129
-
130
- ##
131
- # Designer doesn't have TypusUser permissions BUT can update his profile.
132
- #
133
-
134
- context "Designer" do
135
-
136
- setup do
137
- @designer = Factory(:typus_user, :role => "designer")
138
- @request.session[:typus_user_id] = @designer.id
139
- end
140
-
141
- should "be able to edit his profile" do
142
- get :edit, :id => @designer.id
143
- assert_response :success
144
- end
145
-
146
- should "be able to update his profile" do
147
- post :update, :id => @designer.id, :typus_user => { :role => 'designer', :email => 'designer@withafancydomain.com' }
148
- assert_response :redirect
149
- assert_redirected_to "/admin/typus_users/edit/#{@designer.id}"
150
- assert_equal "Typus user successfully updated.", flash[:notice]
151
- assert_equal "designer@withafancydomain.com", assigns(:item).email
152
- end
153
-
154
- end
155
-
156
- end
@@ -1,106 +0,0 @@
1
- require "test_helper"
2
-
3
- =begin
4
-
5
- What's being tested here?
6
-
7
- - HasManyThrough
8
-
9
- =end
10
-
11
- class Admin::UsersControllerTest < ActionController::TestCase
12
-
13
- setup do
14
- @typus_user = Factory(:typus_user)
15
- @request.session[:typus_user_id] = @typus_user.id
16
-
17
- @project = Factory(:project)
18
- @user = @project.user
19
- end
20
-
21
- should_eventually "be able to destroy items" do
22
- get :destroy, :id => @user.id, :method => :delete
23
-
24
- assert_response :redirect
25
- assert_equal "User successfully removed.", flash[:notice]
26
- assert_redirected_to :action => :index
27
- end
28
-
29
- context "index" do
30
-
31
- setup do
32
- @user_1 = Factory(:user)
33
- @project_1 = Factory(:project, :user => @user_1)
34
- Factory(:project, :user => @user_1)
35
- @project_2 = Factory(:project)
36
- end
37
-
38
- should "filter by projects" do
39
- get :index, :projects => @project_1.id
40
- assert_equal [@user_1], assigns(:items)
41
-
42
- get :index, :projects => @project_2.id
43
- assert_not_equal [@user_1], assigns(:items)
44
- end
45
-
46
- end
47
-
48
- context "unrelate collaborators" do
49
-
50
- ##
51
- # We have a project with many collaborators (which are users)
52
- #
53
-
54
- setup do
55
- @project = Factory(:project)
56
- @user = Factory(:user)
57
- @project.collaborators << @user
58
-
59
- @request.env['HTTP_REFERER'] = "/admin/projects/edit/#{@project.id}"
60
- end
61
-
62
- should "work" do
63
- assert_difference('@project.collaborators.count', -1) do
64
- post :unrelate, :id => @user.id,
65
- :resource => 'Project',
66
- :resource_id => @project.id,
67
- :association_name => "collaborators"
68
- end
69
- assert_response :redirect
70
- assert_redirected_to @request.env['HTTP_REFERER']
71
- assert_equal "Project successfully updated.", flash[:notice]
72
- end
73
-
74
- end
75
-
76
- ##
77
- # THIS IS HERE BECAUSE I FOUND A BIG HOLE IN THE FILTERS STUFF!
78
- #
79
- context "autocomplete" do
80
-
81
- setup do
82
- 25.times { Factory(:user) }
83
- end
84
-
85
- should "work and return a json hash with ten items" do
86
- get :autocomplete, { :term => "User" }
87
- assert_response :success
88
- assert_equal 20, assigns(:items).size
89
- end
90
-
91
- should "work and return json hash with one item" do
92
- post = User.first
93
- post.update_attributes(:name => "fesplugas")
94
-
95
- get :autocomplete, :term => "jmeiss"
96
- assert_response :success
97
- assert_equal 0, assigns(:items).size
98
-
99
- get :autocomplete, :term => "fesplugas"
100
- assert_response :success
101
- assert_equal 1, assigns(:items).size
102
- end
103
-
104
- end
105
-
106
- end