Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-08-24 20:28:00 +0300
committerRuben Davila <rdavila84@gmail.com>2016-08-25 01:38:35 +0300
commit7c9afd19b752cc7d775c7062f7078e230532156a (patch)
treea3b46e04fd1ba78e7470dbdbf45ce020eabefa8a /spec
parentf7a4dfe517036b1dfd62d3dd8c51c2254a0b0fa3 (diff)
Merge branch '20254-create-mr-for-new-branch' into 'master'
last_push_event widget considers fork events on the main project Push events on the fork of the current project are considered to be shown besides the push events on the current project. Before we just consider fork events if exists a fork so we miss current project events if the current user has a fork. Closes #20254 See merge request !5978
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/projects_helper_spec.rb38
-rw-r--r--spec/models/user_spec.rb10
2 files changed, 48 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 604204cca0a..284b58d8d5c 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -136,4 +136,42 @@ describe ProjectsHelper do
expect(sanitize_repo_path(project, import_error)).to eq('Could not clone [REPOS PATH]/namespace/test.git')
end
end
+
+ describe '#last_push_event' do
+ let(:user) { double(:user, fork_of: nil) }
+ let(:project) { double(:project, id: 1) }
+
+ before do
+ allow(helper).to receive(:current_user).and_return(user)
+ helper.instance_variable_set(:@project, project)
+ end
+
+ context 'when there is no current_user' do
+ let(:user) { nil }
+
+ it 'returns nil' do
+ expect(helper.last_push_event).to eq(nil)
+ end
+ end
+
+ it 'returns recent push on the current project' do
+ event = double(:event)
+ expect(user).to receive(:recent_push).with([project.id]).and_return(event)
+
+ expect(helper.last_push_event).to eq(event)
+ end
+
+ context 'when current user has a fork of the current project' do
+ let(:fork) { double(:fork, id: 2) }
+
+ it 'returns recent push considering fork events' do
+ expect(user).to receive(:fork_of).with(project).and_return(fork)
+
+ event_on_fork = double(:event)
+ expect(user).to receive(:recent_push).with([project.id, fork.id]).and_return(event_on_fork)
+
+ expect(helper.last_push_event).to eq(event_on_fork)
+ end
+ end
+ end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 51e4780e2b1..8eb0c5033c9 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -920,6 +920,16 @@ describe User, models: true do
expect(subject.recent_push).to eq(nil)
end
+
+ it "includes push events on any of the provided projects" do
+ expect(subject.recent_push(project1)).to eq(nil)
+ expect(subject.recent_push(project2)).to eq(push_event)
+
+ push_data1 = Gitlab::DataBuilder::Push.build_sample(project1, subject)
+ push_event1 = create(:event, action: Event::PUSHED, project: project1, target: project1, author: subject, data: push_data1)
+
+ expect(subject.recent_push([project1, project2])).to eq(push_event1) # Newest
+ end
end
describe '#authorized_groups' do