diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index accc35f..acbb10e 100755 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -16,6 +16,7 @@ class Api::V1::UsersController < Api::V1::BaseController time_zone: @user.time_zone, avatar: @user.profile.avatar.url, admin: @user.admin?, + moderator: @user.gather_moderator?, steam: @user.steamid.nil? ? nil : { id: @user.steamid, url: @steam.nil? ? nil : @steam.base_url, diff --git a/spec/controllers/api/v1/users_controller_spec.rb b/spec/controllers/api/v1/users_controller_spec.rb index c2a7059..7bf091e 100755 --- a/spec/controllers/api/v1/users_controller_spec.rb +++ b/spec/controllers/api/v1/users_controller_spec.rb @@ -19,6 +19,7 @@ describe Api::V1::UsersController do expect(json["country"]).to eq(@user.country) expect(json["time_zone"]).to eq(@user.time_zone) expect(json["admin"]).to eq(@user.admin?) + expect(json["moderator"]).to eq(@user.gather_moderator?) expect(json).to have_key("steam") expect(json["steam"]).to have_key("id") expect(json["steam"]).to have_key("url") @@ -39,6 +40,13 @@ describe Api::V1::UsersController do expect(json["steam"]).to be_nil 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 expect { get :show, id: -1