Skip to content

Commit 268ace8

Browse files
committed
Fix collaboration box not loading
1 parent 8990e7b commit 268ace8

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

app/controllers/collaborations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def get_resource
3838
if name.end_with?('_id')
3939
c = name.chomp('_id').classify.constantize rescue NameError
4040
if c.method_defined?(:collaborations)
41-
@resource = c.method_defined?(:friendly) ? c.friendly.find(value) : c.find(value)
41+
@resource = c.respond_to?(:friendly) ? c.friendly.find(value) : c.find(value)
4242
end
4343
end
4444
end

test/controllers/collaborations_controller_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ class CollaborationsControllerTest < ActionController::TestCase
8686
assert_response :forbidden
8787
end
8888

89+
test "should list collaborations for resource that supports friendly ID" do
90+
lp = learning_paths(:one)
91+
lp.save!
92+
lp.collaborators << users(:another_regular_user)
93+
94+
sign_in(lp.user)
95+
96+
get :index, params: { format: :json, learning_path_id: lp.slug }
97+
assert_response :success
98+
collaborations = JSON.parse(@response.body)
99+
100+
assert_equal 1, collaborations.length
101+
assert_includes collaborations.map { |e| e['user']['id'] }, users(:another_regular_user).id
102+
end
103+
89104
test "should list collaborations for resource that does not support friendly ID" do
90105
lpt = learning_path_topics(:good_and_bad)
91106
lpt.collaborators << users(:another_regular_user)

0 commit comments

Comments
 (0)