Commit 3c5150a1 authored by James Lopez's avatar James Lopez

add more specs and grape entity stuff

parent 2f808329
......@@ -18,6 +18,11 @@ module API
expose :bio, :location, :skype, :linkedin, :twitter, :website_url, :organization
end
class UserActivity < Grape::Entity
expose :username
expose :date
end
class Identity < Grape::Entity
expose :provider, :extern_uid
end
......
......@@ -456,6 +456,23 @@ module API
email.destroy
current_user.update_secondary_emails!
end
desc 'Get a list of user activities' do
success Entities::UserBasic
end
params do
optional :due_date, type: String, desc: 'Date time string in the format YEAR-MONTH-DAY'
use :pagination
end
get ":activities" do
authenticated_as_admin!
user_activities = Gitlab::UserActivities.query(from: params[:from],
page: params[:page],
per_page: params[:per_page])
present paginate(user_activities), with: Entities::UserActivity
end
end
end
end
......@@ -5,7 +5,7 @@ describe Gitlab::UserActivities, :redis, lib: true do
it 'shows the last user activities' do
Timecop.freeze do
Users::ActivityService.new(user, 'type').execute
user.record_activity
expect(described_class.query).to eq({ username: user.username,
last_activity: DateTime.now })
......@@ -17,7 +17,7 @@ describe Gitlab::UserActivities, :redis, lib: true do
Timecop.scale(3600)
7.times do
Users::ActivityService.new(create(:user), 'type').execute
create(:user).record_activity
end
end
......
......@@ -1101,16 +1101,16 @@ describe API::Users, api: true do
end
end
context "user activities" do
context "user activities", :redis do
it_behaves_like 'a paginated resources' do
let(:request) { get api("/users/activities", user) }
end
context 'last activities' do
it 'returns the last activities' do
Users::ActivityService.new(user, 'type').execute
user.record_activity
get api("/users/activities", user)
get api("/users/activities", admin)
activity = json_response.first
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment