REFACTOR: Remove extra param for group mentionable and messableable route.
This commit is contained in:
parent
d069f4ecba
commit
a83ab01264
|
@ -262,11 +262,11 @@ Group.reopenClass({
|
|||
},
|
||||
|
||||
mentionable(name) {
|
||||
return ajax(`/groups/${name}/mentionable`, { data: { name } });
|
||||
return ajax(`/groups/${name}/mentionable`);
|
||||
},
|
||||
|
||||
messageable(name) {
|
||||
return ajax(`/groups/${name}/messageable`, { data: { name } });
|
||||
return ajax(`/groups/${name}/messageable`);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def mentionable
|
||||
group = find_group(:name, ensure_can_see: false)
|
||||
group = find_group(:group_id, ensure_can_see: false)
|
||||
|
||||
if group
|
||||
render json: { mentionable: Group.mentionable(current_user).where(id: group.id).present? }
|
||||
|
@ -292,7 +292,7 @@ class GroupsController < ApplicationController
|
|||
end
|
||||
|
||||
def messageable
|
||||
group = find_group(:name, ensure_can_see: false)
|
||||
group = find_group(:group_id, ensure_can_see: false)
|
||||
|
||||
if group
|
||||
render json: { messageable: Group.messageable(current_user).where(id: group.id).present? }
|
||||
|
|
|
@ -380,17 +380,19 @@ describe GroupsController do
|
|||
describe '#mentionable' do
|
||||
it "should return the right response" do
|
||||
sign_in(user)
|
||||
group.update_attributes!(name: 'test')
|
||||
|
||||
get "/groups/test/mentionable.json", params: { name: group.name }
|
||||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response).to be_success
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
expect(response_body["mentionable"]).to eq(false)
|
||||
|
||||
group.update_attributes!(mentionable_level: Group::ALIAS_LEVELS[:everyone], visibility_level: Group.visibility_levels[:staff])
|
||||
group.update_attributes!(
|
||||
mentionable_level: Group::ALIAS_LEVELS[:everyone],
|
||||
visibility_level: Group.visibility_levels[:staff]
|
||||
)
|
||||
|
||||
get "/groups/test/mentionable.json", params: { name: group.name }
|
||||
get "/groups/#{group.name}/mentionable.json"
|
||||
expect(response).to be_success
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
|
@ -401,17 +403,19 @@ describe GroupsController do
|
|||
describe '#messageable' do
|
||||
it "should return the right response" do
|
||||
sign_in(user)
|
||||
group.update_attributes!(name: 'test')
|
||||
|
||||
get "/groups/test/messageable.json", params: { name: group.name }
|
||||
get "/groups/#{group.name}/messageable.json"
|
||||
expect(response).to be_success
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
expect(response_body["messageable"]).to eq(false)
|
||||
|
||||
group.update_attributes!(messageable_level: Group::ALIAS_LEVELS[:everyone], visibility_level: Group.visibility_levels[:staff])
|
||||
group.update!(
|
||||
messageable_level: Group::ALIAS_LEVELS[:everyone],
|
||||
visibility_level: Group.visibility_levels[:staff]
|
||||
)
|
||||
|
||||
get "/groups/test/messageable.json", params: { name: group.name }
|
||||
get "/groups/#{group.name}/messageable.json"
|
||||
expect(response).to be_success
|
||||
|
||||
response_body = JSON.parse(response.body)
|
||||
|
|
Loading…
Reference in New Issue