Skip to content

Commit f9e456b

Browse files
committed
remove useless network/post_types/rep_changes cache clearing in clear_cache! (unused)
1 parent 78c1f6e commit f9e456b

2 files changed

Lines changed: 30 additions & 15 deletions

File tree

app/controllers/post_types_controller.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def new
2121
end
2222

2323
def create
24-
@type = PostType.new post_type_params
24+
@type = PostType.new(post_type_params)
2525
if @type.save
2626
clear_cache!
2727
redirect_to post_types_path
@@ -55,8 +55,6 @@ def post_type_params
5555
end
5656

5757
def clear_cache!
58-
# FIXME: this is likely not clearing cache for rep changes
59-
Rails.cache.delete 'network/post_types/rep_changes'
6058
PostType.clear_ids_cache
6159
current_community = RequestContext.community
6260
Community.all.each do |c|

test/controllers/post_types_controller_test.rb

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,19 @@ class PostTypesControllerTest < ActionController::TestCase
8989

9090
test 'can update post type' do
9191
sign_in users(:global_admin)
92-
data = { name: 'Test Type', description: 'words', icon_name: 'heart',
93-
has_answers: true, has_license: true, has_category: true,
94-
answer_type_id: Answer.post_type_id, has_reactions: false,
95-
has_only_specific_reactions: true }
96-
patch :update, params: { post_type: data,
97-
id: post_types(:question).id }
92+
93+
data = { name: 'Test Type',
94+
description: 'words',
95+
icon_name: 'heart',
96+
has_answers: true,
97+
has_license: true,
98+
has_category: true,
99+
answer_type_id: Answer.post_type_id,
100+
has_reactions: false,
101+
has_only_specific_reactions: true }
102+
103+
try_update_post_type(post_types(:question), **data)
104+
98105
assert_response(:found)
99106
assert_redirected_to post_types_path
100107

@@ -106,17 +113,27 @@ class PostTypesControllerTest < ActionController::TestCase
106113
end
107114

108115
test 'update requires auth' do
109-
patch :update, params: { post_type: { name: 'Test Type', description: 'words', icon_name: 'heart',
110-
has_answers: 'true', has_license: 'true', has_category: 'true' },
111-
id: post_types(:question).id }
116+
try_update_post_type(post_types(:question))
112117
assert_redirected_to_sign_in
113118
end
114119

115120
test 'update requires global admin' do
116121
sign_in users(:admin)
117-
patch :update, params: { post_type: { name: 'Test Type', description: 'words', icon_name: 'heart',
118-
has_answers: 'true', has_license: 'true', has_category: 'true' },
119-
id: post_types(:question).id }
122+
try_update_post_type(post_types(:question))
120123
assert_response(:not_found)
121124
end
125+
126+
private
127+
128+
# @param post_type [PostType] post type to update
129+
# @param opts
130+
def try_update_post_type(post_type, **opts)
131+
patch :update, params: { post_type: { name: 'Test Type',
132+
description: 'words',
133+
icon_name: 'heart',
134+
has_answers: 'true',
135+
has_license: 'true',
136+
has_category: 'true' }.merge(opts),
137+
id: post_type.id }
138+
end
122139
end

0 commit comments

Comments
 (0)