summaryrefslogtreecommitdiff
path: root/spec/requests/api/internal_spec.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-10-05 16:41:32 +0200
committerRémy Coutable <remy@rymai.me>2017-04-14 15:20:55 +0200
commit2951a8543ef97ceb1bcaca5f5140d822729c950b (patch)
treeff02540e813cd93e8df8a438c9b22cdacc96982e /spec/requests/api/internal_spec.rb
parentb61199ce0ccdfcd11a338778ce300cd15e5f2a43 (diff)
downloadgitlab-ce-2951a8543ef97ceb1bcaca5f5140d822729c950b.tar.gz
Add user activity service and spec. Also added relevant - NOT offline - migration
It uses a user activity table instead of a column in users. Tested with mySQL and postgreSQL
Diffstat (limited to 'spec/requests/api/internal_spec.rb')
-rw-r--r--spec/requests/api/internal_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb
index 4be67df5a00..63f566da7a8 100644
--- a/spec/requests/api/internal_spec.rb
+++ b/spec/requests/api/internal_spec.rb
@@ -151,6 +151,11 @@ describe API::Internal, api: true do
context "access granted" do
before do
project.team << [user, :developer]
+ Timecop.freeze
+ end
+
+ after do
+ Timecop.return
end
context 'with env passed as a JSON' do
@@ -176,6 +181,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy
expect(json_response["repository_path"]).to eq(project.wiki.repository.path_to_repo)
+ expect(key.user.reload.last_activity_at.to_i).to eq(Time.now.to_i)
end
end
@@ -186,6 +192,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy
expect(json_response["repository_path"]).to eq(project.wiki.repository.path_to_repo)
+ expect(key.user.reload.last_activity_at.to_i).to eq(Time.now.to_i)
end
end
@@ -196,6 +203,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy
expect(json_response["repository_path"]).to eq(project.repository.path_to_repo)
+ expect(key.user.reload.last_activity_at.to_i).to eq(Time.now.to_i)
end
end
@@ -206,6 +214,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_truthy
expect(json_response["repository_path"]).to eq(project.repository.path_to_repo)
+ expect(key.user.reload.last_activity_at.to_i).to eq(Time.now.to_i)
end
context 'project as /namespace/project' do
@@ -241,6 +250,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey
+ expect(key.user.reload.last_activity_at).to be_nil
end
end
@@ -250,6 +260,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey
+ expect(key.user.reload.last_activity_at).to be_nil
end
end
end
@@ -267,6 +278,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey
+ expect(key.user.reload.last_activity_at).to be_nil
end
end
@@ -276,6 +288,7 @@ describe API::Internal, api: true do
expect(response).to have_http_status(200)
expect(json_response["status"]).to be_falsey
+ expect(key.user.reload.last_activity_at).to be_nil
end
end
end