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:
authorHannes Rosenögger <123haynes@gmail.com>2015-03-13 13:39:26 +0300
committerHannes Rosenögger <123haynes@gmail.com>2015-03-18 10:42:42 +0300
commit9e5738b0072f8715d52801f3469be9f3742beb97 (patch)
treee6f83c4c42e05309ef20150796aefe372026e68f /spec
parentdbd347bfa00e133da8ac178612ed8c30ef871ca4 (diff)
Extend the commit calendar to show the actual commits for a date
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/users_controller_spec.rb48
-rw-r--r--spec/models/repository_spec.rb19
2 files changed, 57 insertions, 10 deletions
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 44225c054f2..7962bcdde71 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -1,27 +1,59 @@
require 'spec_helper'
describe UsersController do
- let(:user) { create(:user, username: "user1", name: "User 1", email: "user1@gitlab.com") }
+ let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') }
before do
sign_in(user)
end
- describe "GET #show" do
+ describe 'GET #show' do
render_views
- it "renders the show template" do
+ it 'renders the show template' do
get :show, username: user.username
expect(response.status).to eq(200)
- expect(response).to render_template("show")
+ expect(response).to render_template('show')
end
end
- describe "GET #calendar" do
- it "renders calendar" do
+ describe 'GET #calendar' do
+ it 'renders calendar' do
get :calendar, username: user.username
- expect(response).to render_template("calendar")
+ expect(response).to render_template('calendar')
end
end
-end
+ describe 'GET #calendar_activities' do
+ include RepoHelpers
+ let(:project) { create(:project) }
+ let(:calendar_user) { create(:user, email: sample_commit.author_email) }
+ let(:commit1) { '0ed8c6c6752e8c6ea63e7b92a517bf5ac1209c80' }
+ let(:commit2) { '7d3b0f7cff5f37573aea97cebfd5692ea1689924' }
+
+ before do
+ allow_any_instance_of(User).to receive(:contributed_projects_ids).and_return([project.id])
+ project.team << [user, :developer]
+ end
+
+ it 'assigns @commit_count' do
+ get :calendar_activities, username: calendar_user.username, date: '2014-07-31'
+ expect(assigns(:commit_count)).to eq(2)
+ end
+
+ it 'assigns @calendar_date' do
+ get :calendar_activities, username: calendar_user.username, date: '2014-07-31'
+ expect(assigns(:calendar_date)).to eq(Date.parse('2014-07-31'))
+ end
+
+ it 'assigns @calendar_activities' do
+ get :calendar_activities, username: calendar_user.username, date: '2014-07-31'
+ expect(assigns(:calendar_activities).values.flatten.map(&:id)).to eq([commit1, commit2])
+ end
+
+ it 'renders calendar_activities' do
+ get :calendar_activities, username: calendar_user.username
+ expect(response).to render_template('calendar_activities')
+ end
+ end
+end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index b3a38f6c5b9..0e3e0b167d7 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -29,7 +29,7 @@ describe Repository do
subject { repository.timestamps_by_user_log(user) }
- it { is_expected.to eq(["2014-08-06", "2014-07-31", "2014-07-31"]) }
+ it { is_expected.to eq(['2014-08-06', '2014-07-31', '2014-07-31']) }
end
describe 'multiple emails for user' do
@@ -38,7 +38,22 @@ describe Repository do
subject { repository.timestamps_by_user_log(user) }
- it { is_expected.to eq(["2015-01-10", "2014-08-06", "2014-07-31", "2014-07-31"]) }
+ it { is_expected.to eq(['2015-01-10', '2014-08-06', '2014-07-31', '2014-07-31']) }
+ end
+ end
+
+ context :commits_by_user_on_date_log do
+
+ describe 'single e-mail for user' do
+ let(:user) { create(:user, email: sample_commit.author_email) }
+ let(:commit1) { '0ed8c6c6752e8c6ea63e7b92a517bf5ac1209c80' }
+ let(:commit2) { '7d3b0f7cff5f37573aea97cebfd5692ea1689924' }
+
+ subject { repository.commits_by_user_on_date_log(user,Date.new(2014, 07, 31)) }
+
+ it 'contains the exepected commits' do
+ expect(subject.flatten.map(&:id)).to eq([commit1, commit2])
+ end
end
end
end