summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-29 09:43:09 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-01-29 09:43:09 -0800
commitd54f80980432d781b8730c672576e5e47620f502 (patch)
tree6e6b69d39631b339cfa6f26f84c419e9cef89954
parentb5b9b67ea58bd37871a62c228536594bea9902bc (diff)
parent152a6b863de7f0e87ad941c60ceab652b6da9023 (diff)
downloadgitlab-ce-d54f80980432d781b8730c672576e5e47620f502.tar.gz
Merge branch 'master' of dev.gitlab.org:gitlab/gitlabhq
-rw-r--r--app/controllers/users_controller.rb33
-rw-r--r--app/views/users/calendar.html.haml (renamed from app/views/users/_calendar.html.haml)1
-rw-r--r--app/views/users/show.html.haml10
-rw-r--r--config/routes.rb7
-rw-r--r--spec/controllers/users_controller_spec.rb10
5 files changed, 39 insertions, 22 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 9e5ea6cfa45..ff5e31067fb 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,14 +1,9 @@
class UsersController < ApplicationController
- skip_before_filter :authenticate_user!, only: [:show, :activities]
+ skip_before_filter :authenticate_user!
+ before_filter :set_user
layout :determine_layout
def show
- @user = User.find_by_username!(params[:username])
-
- unless current_user || @user.public_profile?
- return authenticate_user!
- end
-
# Projects user can view
visible_projects = ProjectsFinder.new.execute(current_user)
authorized_projects_ids = visible_projects.pluck(:id)
@@ -25,6 +20,15 @@ class UsersController < ApplicationController
@title = @user.name
+ respond_to do |format|
+ format.html
+ format.atom { render layout: false }
+ end
+ end
+
+ def calendar
+ visible_projects = ProjectsFinder.new.execute(current_user)
+
# Get user repositories and collect timestamps for commits
user_repositories = visible_projects.map(&:repository)
calendar = Gitlab::CommitsCalendar.new(user_repositories, @user)
@@ -32,10 +36,7 @@ class UsersController < ApplicationController
@starting_year = (Time.now - 1.year).strftime("%Y")
@starting_month = Date.today.strftime("%m").to_i
- respond_to do |format|
- format.html
- format.atom { render layout: false }
- end
+ render 'calendar', layout: false
end
def determine_layout
@@ -45,4 +46,14 @@ class UsersController < ApplicationController
'public_users'
end
end
+
+ private
+
+ def set_user
+ @user = User.find_by_username!(params[:username])
+
+ unless current_user || @user.public_profile?
+ return authenticate_user!
+ end
+ end
end
diff --git a/app/views/users/_calendar.html.haml b/app/views/users/calendar.html.haml
index b16a7305a32..727faf23679 100644
--- a/app/views/users/_calendar.html.haml
+++ b/app/views/users/calendar.html.haml
@@ -1,3 +1,4 @@
+%h4 Calendar:
#cal-heatmap.calendar
:javascript
new calendar(
diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml
index c248a280475..445f43cd500 100644
--- a/app/views/users/show.html.haml
+++ b/app/views/users/show.html.haml
@@ -19,8 +19,9 @@
= render 'groups', groups: @groups
%hr
- %h4 Calendar:
- %div= render 'calendar'
+ .user-calendar
+ %h4.center.light
+ %i.fa.fa-spinner.fa-spin
%hr
%h4
User Activity:
@@ -36,3 +37,8 @@
= render 'profile', user: @user
- if @projects.present?
= render 'projects', projects: @projects
+
+
+:coffeescript
+ $ ->
+ $(".user-calendar").load("#{user_calendar_path}")
diff --git a/config/routes.rb b/config/routes.rb
index 5d61de29b9a..e122777314a 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -157,10 +157,9 @@ Gitlab::Application.routes.draw do
end
end
- # route for commits used by the cal-heatmap
- get 'u/:username/activities' => 'users#activities', as: :user_activities,
- constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
- via: :get
+ get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
+ constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
+
get '/u/:username' => 'users#show', as: :user,
constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index 0c537a552c2..44225c054f2 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -9,18 +9,18 @@ describe UsersController do
describe "GET #show" do
render_views
- before do
- get :show, username: user.username
- end
it "renders the show template" do
+ get :show, username: user.username
expect(response.status).to eq(200)
expect(response).to render_template("show")
end
+ end
+ describe "GET #calendar" do
it "renders calendar" do
- controller.prepend_view_path 'app/views/users'
- expect(response).to render_template("_calendar")
+ get :calendar, username: user.username
+ expect(response).to render_template("calendar")
end
end
end