mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-14 22:01:28 +00:00
Return moderator status with users api
This commit is contained in:
parent
95deb32e05
commit
bfc79cddcb
2 changed files with 9 additions and 0 deletions
|
@ -16,6 +16,7 @@ class Api::V1::UsersController < Api::V1::BaseController
|
||||||
time_zone: @user.time_zone,
|
time_zone: @user.time_zone,
|
||||||
avatar: @user.profile.avatar.url,
|
avatar: @user.profile.avatar.url,
|
||||||
admin: @user.admin?,
|
admin: @user.admin?,
|
||||||
|
moderator: @user.gather_moderator?,
|
||||||
steam: @user.steamid.nil? ? nil : {
|
steam: @user.steamid.nil? ? nil : {
|
||||||
id: @user.steamid,
|
id: @user.steamid,
|
||||||
url: @steam.nil? ? nil : @steam.base_url,
|
url: @steam.nil? ? nil : @steam.base_url,
|
||||||
|
|
|
@ -19,6 +19,7 @@ describe Api::V1::UsersController do
|
||||||
expect(json["country"]).to eq(@user.country)
|
expect(json["country"]).to eq(@user.country)
|
||||||
expect(json["time_zone"]).to eq(@user.time_zone)
|
expect(json["time_zone"]).to eq(@user.time_zone)
|
||||||
expect(json["admin"]).to eq(@user.admin?)
|
expect(json["admin"]).to eq(@user.admin?)
|
||||||
|
expect(json["moderator"]).to eq(@user.gather_moderator?)
|
||||||
expect(json).to have_key("steam")
|
expect(json).to have_key("steam")
|
||||||
expect(json["steam"]).to have_key("id")
|
expect(json["steam"]).to have_key("id")
|
||||||
expect(json["steam"]).to have_key("url")
|
expect(json["steam"]).to have_key("url")
|
||||||
|
@ -39,6 +40,13 @@ describe Api::V1::UsersController do
|
||||||
expect(json["steam"]).to be_nil
|
expect(json["steam"]).to be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns gather moderator status" do
|
||||||
|
group = create :group, :gather_moderator
|
||||||
|
create :grouper, user: @user, group: group
|
||||||
|
get :show, id: @user.id
|
||||||
|
expect(json["moderator"]).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
it "returns 404 if user does not exist" do
|
it "returns 404 if user does not exist" do
|
||||||
expect {
|
expect {
|
||||||
get :show, id: -1
|
get :show, id: -1
|
||||||
|
|
Loading…
Reference in a new issue