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.
- data/README.md +4 -1
- data/app/helpers/admin/relationships_helper.rb +2 -2
- data/app/views/admin/dashboard/_applications.html.erb +1 -1
- data/app/views/admin/helpers/resources/_errors.html.erb +1 -1
- data/app/views/admin/helpers/sidebar/_sidebar.html.erb +1 -1
- data/app/views/admin/resources/index.html.erb +2 -2
- data/app/views/admin/templates/_has_n.html.erb +1 -1
- data/app/views/admin/templates/_has_one.html.erb +1 -1
- data/config/locales/typus.ca.yml +1 -1
- data/config/locales/typus.de.models.yml +6 -5
- data/config/locales/typus.de.yml +39 -36
- data/config/locales/typus.el.yml +1 -1
- data/config/locales/typus.es.yml +1 -1
- data/config/locales/typus.fr.yml +1 -1
- data/config/locales/typus.hu.yml +1 -1
- data/config/locales/typus.locale.yml.template +1 -1
- data/config/locales/typus.pt-BR.yml +1 -1
- data/config/locales/typus.pt-PT.yml +1 -1
- data/config/locales/typus.ru.yml +1 -1
- data/config/locales/typus.zh-CN.yml +1 -1
- data/lib/typus/version.rb +1 -1
- data/typus.gemspec +7 -4
- metadata +16 -164
- data/test/app/controllers/admin/account_controller_test.rb +0 -106
- data/test/app/controllers/admin/assets_controller_test.rb +0 -156
- data/test/app/controllers/admin/base_controller_test.rb +0 -41
- data/test/app/controllers/admin/birds_controller_test.rb +0 -42
- data/test/app/controllers/admin/cases_controller_test.rb +0 -21
- data/test/app/controllers/admin/categories_controller_test.rb +0 -134
- data/test/app/controllers/admin/comments_controller_test.rb +0 -79
- data/test/app/controllers/admin/dashboard_controller_test.rb +0 -162
- data/test/app/controllers/admin/image_holders_controller_test.rb +0 -75
- data/test/app/controllers/admin/invoices_controller_test.rb +0 -78
- data/test/app/controllers/admin/orders_controller_test.rb +0 -18
- data/test/app/controllers/admin/pages_controller_test.rb +0 -37
- data/test/app/controllers/admin/posts_controller_test.rb +0 -770
- data/test/app/controllers/admin/projects_controller_test.rb +0 -52
- data/test/app/controllers/admin/session_controller_test.rb +0 -92
- data/test/app/controllers/admin/status_controller_test.rb +0 -54
- data/test/app/controllers/admin/typus_users_controller_test.rb +0 -156
- data/test/app/controllers/admin/users_controller_test.rb +0 -106
- data/test/app/controllers/admin/views_controller_test.rb +0 -36
- data/test/app/helpers/admin/base_helper_test.rb +0 -83
- data/test/app/helpers/admin/dashboard_helper_test.rb +0 -32
- data/test/app/helpers/admin/file_preview_helper_test.rb +0 -90
- data/test/app/helpers/admin/filters_helper_test.rb +0 -166
- data/test/app/helpers/admin/form_helper_test.rb +0 -126
- data/test/app/helpers/admin/list_helper_test.rb +0 -76
- data/test/app/helpers/admin/relationships_helper_test.rb +0 -19
- data/test/app/helpers/admin/resources_helper_test.rb +0 -46
- data/test/app/helpers/admin/search_helper_test.rb +0 -60
- data/test/app/helpers/admin/sidebar_helper_test.rb +0 -34
- data/test/app/helpers/admin/table_helper_test.rb +0 -241
- data/test/app/mailers/admin/mailer_test.rb +0 -32
- data/test/app/models/admin_user_test.rb +0 -5
- data/test/app/models/typus_user_roles_test.rb +0 -125
- data/test/app/models/typus_user_test.rb +0 -228
- data/test/config/routes_test.rb +0 -29
- data/test/factories.rb +0 -122
- data/test/fixtures/config/broken/application.yml +0 -68
- data/test/fixtures/config/broken/application_roles.yml +0 -20
- data/test/fixtures/config/broken/empty.yml +0 -0
- data/test/fixtures/config/broken/empty_roles.yml +0 -0
- data/test/fixtures/config/broken/undefined.yml +0 -3
- data/test/fixtures/config/broken/undefined_roles.yml +0 -6
- data/test/fixtures/config/default/typus.yml +0 -13
- data/test/fixtures/config/default/typus_roles.yml +0 -2
- data/test/fixtures/config/empty/empty_01.yml +0 -0
- data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
- data/test/fixtures/config/empty/empty_02.yml +0 -0
- data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
- data/test/fixtures/config/locales/es.yml +0 -10
- data/test/fixtures/config/namespaced/application.yml +0 -5
- data/test/fixtures/config/namespaced/application_roles.yml +0 -2
- data/test/fixtures/config/ordered/001_roles.yml +0 -2
- data/test/fixtures/config/ordered/002_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
- data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
- data/test/lib/support/active_record_test.rb +0 -174
- data/test/lib/support/fake_user_test.rb +0 -63
- data/test/lib/support/hash_test.rb +0 -29
- data/test/lib/support/object_test.rb +0 -17
- data/test/lib/support/string_test.rb +0 -98
- data/test/lib/typus/configuration_test.rb +0 -46
- data/test/lib/typus/controller/actions_test.rb +0 -141
- data/test/lib/typus/controller/associations_test.rb +0 -7
- data/test/lib/typus/controller/autocomplete_test.rb +0 -7
- data/test/lib/typus/controller/filters_test.rb +0 -73
- data/test/lib/typus/controller/format_test.rb +0 -7
- data/test/lib/typus/i18n_test.rb +0 -9
- data/test/lib/typus/orm/active_record/class_methods_test.rb +0 -390
- data/test/lib/typus/orm/active_record/search_test.rb +0 -330
- data/test/lib/typus/regex_test.rb +0 -53
- data/test/lib/typus/resources_test.rb +0 -41
- data/test/lib/typus_test.rb +0 -142
- data/test/test_helper.rb +0 -15
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
What's being tested here?
|
|
6
|
-
|
|
7
|
-
- Create first user. (/admin/account/new)
|
|
8
|
-
- Stuff that happens when there are already users.
|
|
9
|
-
|
|
10
|
-
=end
|
|
11
|
-
|
|
12
|
-
class Admin::AccountControllerTest < ActionController::TestCase
|
|
13
|
-
|
|
14
|
-
context "No users" do
|
|
15
|
-
|
|
16
|
-
should "render new when there are not admin users" do
|
|
17
|
-
get :new
|
|
18
|
-
|
|
19
|
-
assert_response :success
|
|
20
|
-
assert_template "new"
|
|
21
|
-
assert_equal "Enter your email below to create the first user.", flash[:notice]
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
should "render session layout" do
|
|
25
|
-
get :new
|
|
26
|
-
assert_template "new"
|
|
27
|
-
assert_template "layouts/admin/session"
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
should "verify forgot_password redirects to new when there are no admin users" do
|
|
31
|
-
get :forgot_password
|
|
32
|
-
|
|
33
|
-
assert_response :redirect
|
|
34
|
-
assert_redirected_to new_admin_account_path
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
should "verify send_password redirects to new when there are no admin users"
|
|
38
|
-
|
|
39
|
-
should "not sign_up invalid emails" do
|
|
40
|
-
post :create, :typus_user => { :email => "example.com" }
|
|
41
|
-
|
|
42
|
-
assert_response :redirect
|
|
43
|
-
assert_redirected_to :action => :new
|
|
44
|
-
assert flash.empty?
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
should "sign_up a valid email" do
|
|
48
|
-
assert_difference('TypusUser.count') do
|
|
49
|
-
post :create, :typus_user => { :email => "john@example.com" }
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
assert_response :redirect
|
|
53
|
-
assert_redirected_to :action => "show", :id => TypusUser.find_by_email("john@example.com").token
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context "There are users" do
|
|
59
|
-
|
|
60
|
-
setup do
|
|
61
|
-
@typus_user = Factory(:typus_user)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
should "new redirect new admin session when there are admin users" do
|
|
65
|
-
get :new
|
|
66
|
-
assert_response :redirect
|
|
67
|
-
assert_redirected_to new_admin_session_path
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
should "verify forgot_password is rendered when there are admin users" do
|
|
71
|
-
get :forgot_password
|
|
72
|
-
assert_response :success
|
|
73
|
-
assert_template "forgot_password"
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
should "not_send_recovery_password_link_to_unexisting_user" do
|
|
77
|
-
post :send_password, { :typus_user => { :email => "unexisting" } }
|
|
78
|
-
assert_response :success
|
|
79
|
-
assert flash.empty?
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
should "test_should_send_recovery_password_link_to_existing_user" do
|
|
83
|
-
post :send_password, { :typus_user => { :email => @typus_user.email } }
|
|
84
|
-
|
|
85
|
-
assert_response :redirect
|
|
86
|
-
assert_redirected_to new_admin_session_path
|
|
87
|
-
assert_equal "Password recovery link sent to your email.", flash[:notice]
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
should "test_should_create_admin_user_session_and_redirect_user_to_its_details" do
|
|
91
|
-
get :show, :id => @typus_user.token
|
|
92
|
-
|
|
93
|
-
assert_equal @typus_user.id, @request.session[:typus_user_id]
|
|
94
|
-
assert_response :redirect
|
|
95
|
-
assert_redirected_to :controller => "/admin/typus_users", :action => "edit", :id => @typus_user.id
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
should "test_should_return_404_on_reset_passsword_if_token_is_not_valid" do
|
|
99
|
-
assert_raises ActiveRecord::RecordNotFound do
|
|
100
|
-
get :show, :id => "unexisting"
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
end
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
What's being tested here?
|
|
6
|
-
|
|
7
|
-
- Asset management like attach (edit) and detach (update).
|
|
8
|
-
- Assets runnings with a custom template.
|
|
9
|
-
|
|
10
|
-
=end
|
|
11
|
-
|
|
12
|
-
class Admin::AssetsControllerTest < ActionController::TestCase
|
|
13
|
-
|
|
14
|
-
setup do
|
|
15
|
-
@request.session[:typus_user_id] = Factory(:typus_user).id
|
|
16
|
-
@post = Factory(:post)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
context "edit" do
|
|
20
|
-
|
|
21
|
-
setup do
|
|
22
|
-
@asset = Factory(:asset)
|
|
23
|
-
@request.env['HTTP_REFERER'] = "/admin/assets/edit/#{@asset.id}"
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
should "verify there is a file link" do
|
|
27
|
-
get :edit, :id => @asset.id
|
|
28
|
-
assert_match /media/, @response.body
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
should "verify dragonfly can be removed" do
|
|
32
|
-
get :edit, :id => @asset.id
|
|
33
|
-
assert_match /Remove/, @response.body
|
|
34
|
-
|
|
35
|
-
assert @asset.dragonfly_uid.present?
|
|
36
|
-
|
|
37
|
-
get :update, :id => @asset.id, :attribute => "dragonfly"
|
|
38
|
-
assert_response :redirect
|
|
39
|
-
assert_redirected_to "/admin/assets/edit/#{@asset.id}"
|
|
40
|
-
assert_equal "Asset successfully updated.", flash[:notice]
|
|
41
|
-
|
|
42
|
-
@asset.reload
|
|
43
|
-
assert @asset.dragonfly_uid.blank?
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
should "verify dragonfly_required can not removed" do
|
|
47
|
-
get :edit, :id => @asset.id
|
|
48
|
-
assert_no_match /Remove required file/, @response.body
|
|
49
|
-
|
|
50
|
-
get :update, :id => @asset.id, :attribute => "dragonfly_required"
|
|
51
|
-
assert_response :success
|
|
52
|
-
|
|
53
|
-
@asset.reload
|
|
54
|
-
assert @asset.dragonfly_required.present?
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
should "verify message on polymorphic relationship" do
|
|
58
|
-
asset = Factory(:asset)
|
|
59
|
-
get :edit, :id => asset.id, :resource => @post.class.name, :resource_id => @post.id
|
|
60
|
-
assert_select 'body div#flash', "Cancel adding a new asset?"
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
context "Headless" do
|
|
66
|
-
|
|
67
|
-
should "render index with a custom layout" do
|
|
68
|
-
get :index, :layout => "admin/headless"
|
|
69
|
-
assert_response :success
|
|
70
|
-
assert_template "admin/headless"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
should "render new with a custom layout" do
|
|
74
|
-
get :new, :layout => "admin/headless"
|
|
75
|
-
assert_response :success
|
|
76
|
-
assert_template "admin/headless"
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
should "render edit with a custom layout" do
|
|
80
|
-
asset = Factory(:asset)
|
|
81
|
-
get :edit, :id => asset.id, :layout => "admin/headless"
|
|
82
|
-
assert_response :success
|
|
83
|
-
assert_template "admin/headless"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context "create" do
|
|
87
|
-
|
|
88
|
-
setup do
|
|
89
|
-
@asset = { :caption => "My Caption",
|
|
90
|
-
:dragonfly_required => File.new("#{Rails.root}/public/images/rails.png"),
|
|
91
|
-
:paperclip_required => File.new("#{Rails.root}/public/images/rails.png") }
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
should "redirect to edit with custom layout" do
|
|
95
|
-
assert_difference('Asset.count') do
|
|
96
|
-
post :create, { :asset => @asset, :layout => "admin/headless" }
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
assert_response :redirect
|
|
100
|
-
assert_redirected_to :action => "edit", :id => Asset.last.id, :layout => "admin/headless"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
should "redirect to index with custom layout" do
|
|
104
|
-
Typus::Resources.expects(:action_after_save).returns("index")
|
|
105
|
-
|
|
106
|
-
assert_difference('Asset.count') do
|
|
107
|
-
post :create, { :asset => @asset, :layout => "admin/headless" }
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
assert_response :redirect
|
|
111
|
-
assert_redirected_to :action => "index", :layout => "admin/headless"
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
should "render new with custom layout after an error" do
|
|
115
|
-
post :create, { :asset => {}, :layout => "admin/headless" }
|
|
116
|
-
assert_response :success
|
|
117
|
-
assert_template "new"
|
|
118
|
-
assert_template "admin/headless"
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
context "update" do
|
|
124
|
-
|
|
125
|
-
setup do
|
|
126
|
-
@asset = Factory(:asset)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
should "redirect to edit with custom layout" do
|
|
130
|
-
asset = {:caption => "My Caption", :dragonfly_required => File.new("#{Rails.root}/public/images/rails.png")}
|
|
131
|
-
post :update, :id => @asset.id, :asset => asset, :layout => "admin/headless"
|
|
132
|
-
assert_response :redirect
|
|
133
|
-
assert_redirected_to :action => "edit", :id => @asset.id, :layout => "admin/headless"
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
should "render update with custom layout after an error" do
|
|
137
|
-
post :update, :id => @asset.id, :asset => { :dragonfly_required => nil }, :layout => "admin/headless"
|
|
138
|
-
assert_response :success
|
|
139
|
-
assert_template "admin/helpers/resources/_errors"
|
|
140
|
-
assert_template "admin/resources/edit"
|
|
141
|
-
assert_template "admin/headless"
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
should "redirect to index with custom layout" do
|
|
145
|
-
Typus::Resources.expects(:action_after_save).returns("index")
|
|
146
|
-
asset = {:caption => "My Caption", :dragonfly_required => File.new("#{Rails.root}/public/images/rails.png")}
|
|
147
|
-
post :update, :id => @asset.id, :asset => asset, :layout => "admin/headless"
|
|
148
|
-
assert_response :redirect
|
|
149
|
-
assert_redirected_to :action => "index", :layout => "admin/headless"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
end
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
What's being tested here?
|
|
6
|
-
|
|
7
|
-
- Access to user_guide.
|
|
8
|
-
- ...
|
|
9
|
-
|
|
10
|
-
=end
|
|
11
|
-
|
|
12
|
-
class Admin::BaseControllerTest < ActionController::TestCase
|
|
13
|
-
|
|
14
|
-
context "non-authenticated" do
|
|
15
|
-
|
|
16
|
-
should "not be able to get the user_guide" do
|
|
17
|
-
get :user_guide
|
|
18
|
-
assert_response :redirect
|
|
19
|
-
assert_redirected_to new_admin_session_path(:back_to => '/admin/user_guide')
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
context "authenticated" do
|
|
25
|
-
|
|
26
|
-
setup do
|
|
27
|
-
@request.session[:typus_user_id] = Factory(:typus_user).id
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
teardown do
|
|
31
|
-
@request.session[:typus_user_id] = nil
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
should "be able to get the user_guide" do
|
|
35
|
-
get :user_guide
|
|
36
|
-
assert_response :success
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
end
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
What's being tested here?
|
|
6
|
-
|
|
7
|
-
- Polymorphic associations.
|
|
8
|
-
|
|
9
|
-
=end
|
|
10
|
-
|
|
11
|
-
class Admin::BirdsControllerTest < ActionController::TestCase
|
|
12
|
-
|
|
13
|
-
setup do
|
|
14
|
-
@typus_user = Factory(:typus_user)
|
|
15
|
-
@request.session[:typus_user_id] = @typus_user.id
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context "relate" do
|
|
19
|
-
|
|
20
|
-
setup do
|
|
21
|
-
@bird = Factory(:bird)
|
|
22
|
-
@image_holder = Factory(:image_holder)
|
|
23
|
-
|
|
24
|
-
@request.env['HTTP_REFERER'] = "/admin/birds/edit/#{@bird.id}"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
should "work" do
|
|
28
|
-
assert_difference('@bird.image_holders.count') do
|
|
29
|
-
post :relate, { :id => @bird.id,
|
|
30
|
-
:related => { :model => 'ImageHolder',
|
|
31
|
-
:id => @image_holder.id,
|
|
32
|
-
:association_name => 'image_holders' } }
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
assert_response :redirect
|
|
36
|
-
assert_redirected_to @request.env['HTTP_REFERER']
|
|
37
|
-
assert_equal "Bird successfully updated.", flash[:notice]
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
What's being tested here?
|
|
6
|
-
|
|
7
|
-
- Single Table Inheritance Stuff
|
|
8
|
-
- Relate objects.
|
|
9
|
-
- Unrelate objects.
|
|
10
|
-
- Create (and relate objects).
|
|
11
|
-
|
|
12
|
-
=end
|
|
13
|
-
|
|
14
|
-
class Admin::CasesControllerTest < ActionController::TestCase
|
|
15
|
-
|
|
16
|
-
setup do
|
|
17
|
-
@typus_user = Factory(:typus_user)
|
|
18
|
-
@request.session[:typus_user_id] = @typus_user.id
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
require "test_helper"
|
|
2
|
-
|
|
3
|
-
=begin
|
|
4
|
-
|
|
5
|
-
What's being tested here?
|
|
6
|
-
|
|
7
|
-
- ActsAsList.
|
|
8
|
-
- Template Override (TODO: Centralize this!!!)
|
|
9
|
-
- Unrelate (Post#categories) (has_and_belongs_to_many)
|
|
10
|
-
|
|
11
|
-
=end
|
|
12
|
-
|
|
13
|
-
class Admin::CategoriesControllerTest < ActionController::TestCase
|
|
14
|
-
|
|
15
|
-
setup do
|
|
16
|
-
@request.session[:typus_user_id] = Factory(:typus_user).id
|
|
17
|
-
@request.env['HTTP_REFERER'] = '/admin/categories'
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "Categories Views" do
|
|
21
|
-
|
|
22
|
-
should_eventually "verify form partial can overrided by model" do
|
|
23
|
-
get :new
|
|
24
|
-
assert_match "categories#_form.html.erb", @response.body
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
context "Categories List" do
|
|
30
|
-
|
|
31
|
-
setup do
|
|
32
|
-
@first_category = Factory(:category, :position => 1)
|
|
33
|
-
@second_category = Factory(:category, :position => 2)
|
|
34
|
-
|
|
35
|
-
@second_category.name = nil
|
|
36
|
-
@second_category.save(:validate => false)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
should "verify referer" do
|
|
40
|
-
get :position, { :id => @first_category.id, :go => 'move_lower' }
|
|
41
|
-
assert_response :redirect
|
|
42
|
-
assert_redirected_to @request.env['HTTP_REFERER']
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
should "position item one step down" do
|
|
46
|
-
get :position, { :id => @first_category.id, :go => 'move_lower' }
|
|
47
|
-
assert_equal "Category successfully updated.", flash[:notice]
|
|
48
|
-
assert_equal 2, assigns(:item).position
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
should "position item one step up" do
|
|
52
|
-
get :position, { :id => @second_category.id, :go => 'move_higher' }
|
|
53
|
-
assert_equal 1, assigns(:item).position
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
should "position top item to bottom" do
|
|
57
|
-
get :position, { :id => @first_category.id, :go => 'move_to_bottom' }
|
|
58
|
-
assert_equal 2, assigns(:item).position
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
should "position bottom item to top" do
|
|
62
|
-
get :position, { :id => @second_category.id, :go => 'move_to_top' }
|
|
63
|
-
assert_equal 1, assigns(:item).position
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "Unrelate (has_and_belongs_to_many)" do
|
|
69
|
-
|
|
70
|
-
##
|
|
71
|
-
# We are in:
|
|
72
|
-
#
|
|
73
|
-
# /admin/posts/edit/1
|
|
74
|
-
#
|
|
75
|
-
# And we see a list of comments under it:
|
|
76
|
-
#
|
|
77
|
-
# /admin/categories/unrelate/1?resource=Post&resource_id=1
|
|
78
|
-
# /admin/categories/unrelate/2?resource=Post&resource_id=1
|
|
79
|
-
##
|
|
80
|
-
|
|
81
|
-
setup do
|
|
82
|
-
@category = Factory(:category)
|
|
83
|
-
@category.posts << Factory(:post)
|
|
84
|
-
@request.env['HTTP_REFERER'] = "/admin/dashboard"
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
should "unrelate category from post" do
|
|
88
|
-
assert_difference('@category.posts.count', -1) do
|
|
89
|
-
post :unrelate, :id => @category.id, :resource => 'Post', :resource_id => @category.posts.first
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
assert_response :redirect
|
|
93
|
-
assert_redirected_to @request.env['HTTP_REFERER']
|
|
94
|
-
assert_equal "Post successfully updated.", flash[:notice]
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
##
|
|
100
|
-
# Basically we verify Admin::ResourcesController#create_with_back_to works
|
|
101
|
-
# as expected for STI models.
|
|
102
|
-
#
|
|
103
|
-
# We are editing a Case (which is an STI model). And we click on "Add New"
|
|
104
|
-
# to add a new category. Once create, we will be redirected and the new
|
|
105
|
-
# category will be assigned to the current case. Easy right?
|
|
106
|
-
#
|
|
107
|
-
# /admin/categories/new?back_to=%2Fadmin%2Fcases%2Fedit%1F2&resource=Case&resource_id=2
|
|
108
|
-
#
|
|
109
|
-
context "Relate using Add New on STI models" do
|
|
110
|
-
|
|
111
|
-
setup do
|
|
112
|
-
@category = { :name => "Category Name" }
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
context "when editing an item" do
|
|
116
|
-
|
|
117
|
-
setup do
|
|
118
|
-
@case = Factory(:case)
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
should "create new category and redirect to case" do
|
|
122
|
-
assert_difference('@case.categories.count') do
|
|
123
|
-
post :create, { :category => @category,
|
|
124
|
-
:resource => "Case", :resource_id => @case.id }
|
|
125
|
-
end
|
|
126
|
-
assert_response :redirect
|
|
127
|
-
assert_redirected_to "/admin/cases/edit/#{@case.id}"
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
end
|