Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: gitlabhq/gitlabhq
...
head fork: gitlabhq/gitlabhq
  • 9 commits
  • 39 files changed
  • 2 commit comments
  • 3 contributors
Showing with 134 additions and 197 deletions.
  1. +1 −1  app/assets/stylesheets/main.scss
  2. +2 −2 app/assets/stylesheets/sections/tree.scss
  3. +7 −17 app/controllers/application_controller.rb
  4. +1 −6 app/controllers/blame_controller.rb
  5. +1 −6 app/controllers/blob_controller.rb
  6. +1 −5 app/controllers/commit_controller.rb
  7. +1 −5 app/controllers/commits_controller.rb
  8. +1 −5 app/controllers/compare_controller.rb
  9. +1 −8 app/controllers/deploy_keys_controller.rb
  10. +0 −2  app/controllers/errors_controller.rb
  11. +1 −5 app/controllers/hooks_controller.rb
  12. +1 −7 app/controllers/issues_controller.rb
  13. +1 −7 app/controllers/labels_controller.rb
  14. +1 −6 app/controllers/merge_requests_controller.rb
  15. +1 −6 app/controllers/milestones_controller.rb
  16. +1 −5 app/controllers/notes_controller.rb
  17. +0 −1  app/controllers/profile_controller.rb
  18. +5 −0 app/controllers/project_resource_controller.rb
  19. +4 −19 app/controllers/projects_controller.rb
  20. +1 −6 app/controllers/protected_branches_controller.rb
  21. +4 −8 app/controllers/refs_controller.rb
  22. +1 −6 app/controllers/repositories_controller.rb
  23. +1 −6 app/controllers/snippets_controller.rb
  24. +1 −5 app/controllers/team_members_controller.rb
  25. +1 −6 app/controllers/tree_controller.rb
  26. +1 −4 app/controllers/wikis_controller.rb
  27. +1 −0  app/models/event.rb
  28. 0  app/views/layouts/{error.html.haml → errors.html.haml}
  29. 0  app/views/layouts/{project.html.haml → project_resource.html.haml}
  30. +4 −0 config/application.rb
  31. +5 −0 features/profile/profile.feature
  32. +21 −0 features/project/hooks.feature
  33. +8 −0 features/steps/profile/profile.rb
  34. +36 −0 features/steps/project/project_hooks.rb
  35. +4 −0 features/steps/shared/authentication.rb
  36. +4 −0 features/steps/shared/paths.rb
  37. +4 −0 features/steps/shared/project.rb
  38. +6 −0 spec/factories.rb
  39. +0 −43 spec/requests/hooks_spec.rb
2  app/assets/stylesheets/main.scss
View
@@ -5,7 +5,7 @@
$link_color:#3A89A3;
$blue_link: #2fa0bb;
$style_color: #474d57;
-$hover: #fdf5d9;
+$hover: #D9EDF7;
/** GitLab Fonts **/
@font-face { font-family: Korolev; src: url('korolev-medium-compressed.otf'); }
4 app/assets/stylesheets/sections/tree.scss
View
@@ -31,8 +31,8 @@
&:hover {
td {
background: $hover;
- border-top:1px solid #FEA;
- border-bottom:1px solid #FEA;
+ border-top:1px solid #ADF;
+ border-bottom:1px solid #ADF;
}
cursor:pointer;
}
24 app/controllers/application_controller.rb
View
@@ -10,19 +10,17 @@ class ApplicationController < ActionController::Base
helper_method :abilities, :can?
rescue_from Gitlab::Gitolite::AccessDenied do |exception|
- render "errors/gitolite", layout: "error", status: 500
+ render "errors/gitolite", layout: "errors", status: 500
end
rescue_from Encoding::CompatibilityError do |exception|
- render "errors/encoding", layout: "error", status: 500
+ render "errors/encoding", layout: "errors", status: 500
end
rescue_from ActiveRecord::RecordNotFound do |exception|
- render "errors/not_found", layout: "error", status: 404
+ render "errors/not_found", layout: "errors", status: 404
end
- layout :layout_by_resource
-
protected
def reject_blocked!
@@ -43,14 +41,6 @@ def after_sign_in_path_for resource
end
end
- def layout_by_resource
- if devise_controller?
- "devise_layout"
- else
- "application"
- end
- end
-
def set_current_user_for_mailer
MailerObserver.current_user = current_user
end
@@ -68,7 +58,7 @@ def can?(object, action, subject)
end
def project
- @project ||= current_user.projects.find_by_code(params[:project_id])
+ @project ||= current_user.projects.find_by_code(params[:project_id] || params[:id])
@project || render_404
end
@@ -85,15 +75,15 @@ def authorize_code_access!
end
def access_denied!
- render "errors/access_denied", layout: "error", status: 404
+ render "errors/access_denied", layout: "errors", status: 404
end
def not_found!
- render "errors/not_found", layout: "error", status: 404
+ render "errors/not_found", layout: "errors", status: 404
end
def git_not_found!
- render "errors/git_not_found", layout: "error", status: 404
+ render "errors/git_not_found", layout: "errors", status: 404
end
def method_missing(method_sym, *arguments, &block)
7 app/controllers/blame_controller.rb
View
@@ -1,13 +1,8 @@
# Controller for viewing a file's blame
-class BlameController < ApplicationController
+class BlameController < ProjectResourceController
include ExtractsPath
- layout "project"
-
- before_filter :project
-
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
7 app/controllers/blob_controller.rb
View
@@ -1,14 +1,9 @@
# Controller for viewing a file's blame
-class BlobController < ApplicationController
+class BlobController < ProjectResourceController
include ExtractsPath
include Gitlab::Encode
- layout "project"
-
- before_filter :project
-
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
6 app/controllers/commit_controller.rb
View
@@ -1,12 +1,8 @@
# Controller for a specific Commit
#
# Not to be confused with CommitsController, plural.
-class CommitController < ApplicationController
- before_filter :project
- layout "project"
-
+class CommitController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
6 app/controllers/commits_controller.rb
View
@@ -1,13 +1,9 @@
require "base64"
-class CommitsController < ApplicationController
- before_filter :project
- layout "project"
-
+class CommitsController < ProjectResourceController
include ExtractsPath
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
6 app/controllers/compare_controller.rb
View
@@ -1,9 +1,5 @@
-class CompareController < ApplicationController
- before_filter :project
- layout "project"
-
+class CompareController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
9 app/controllers/deploy_keys_controller.rb
View
@@ -1,16 +1,9 @@
-class DeployKeysController < ApplicationController
+class DeployKeysController < ProjectResourceController
respond_to :html
- layout "project"
- before_filter :project
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_admin_project!
- def project
- @project ||= Project.find_by_code(params[:project_id])
- end
-
def index
@keys = @project.deploy_keys.all
end
2  app/controllers/errors_controller.rb
View
@@ -1,6 +1,4 @@
class ErrorsController < ApplicationController
- layout "error"
-
def githost
render "errors/gitolite"
end
6 app/controllers/hooks_controller.rb
View
@@ -1,9 +1,5 @@
-class HooksController < ApplicationController
- before_filter :project
- layout "project"
-
+class HooksController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_admin_project!, only: [:new, :create, :destroy]
8 app/controllers/issues_controller.rb
View
@@ -1,14 +1,8 @@
-class IssuesController < ApplicationController
- before_filter :project
+class IssuesController < ProjectResourceController
before_filter :module_enabled
before_filter :issue, only: [:edit, :update, :destroy, :show]
helper_method :issues_filter
- layout "project"
-
- # Authorize
- before_filter :add_project_abilities
-
# Allow read any issue
before_filter :authorize_read_issue!
8 app/controllers/labels_controller.rb
View
@@ -1,12 +1,6 @@
-class LabelsController < ApplicationController
- before_filter :project
+class LabelsController < ProjectResourceController
before_filter :module_enabled
- layout "project"
-
- # Authorize
- before_filter :add_project_abilities
-
# Allow read any issue
before_filter :authorize_read_issue!
7 app/controllers/merge_requests_controller.rb
View
@@ -1,13 +1,8 @@
-class MergeRequestsController < ApplicationController
- before_filter :project
+class MergeRequestsController < ProjectResourceController
before_filter :module_enabled
before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw]
before_filter :validates_merge_request, only: [:show, :diffs, :raw]
before_filter :define_show_vars, only: [:show, :diffs]
- layout "project"
-
- # Authorize
- before_filter :add_project_abilities
# Allow read any merge_request
before_filter :authorize_read_merge_request!
7 app/controllers/milestones_controller.rb
View
@@ -1,11 +1,6 @@
-class MilestonesController < ApplicationController
- before_filter :project
+class MilestonesController < ProjectResourceController
before_filter :module_enabled
before_filter :milestone, only: [:edit, :update, :destroy, :show]
- layout "project"
-
- # Authorize
- before_filter :add_project_abilities
# Allow read any milestone
before_filter :authorize_read_milestone!
6 app/controllers/notes_controller.rb
View
@@ -1,9 +1,5 @@
-class NotesController < ApplicationController
- before_filter :project
-
+class NotesController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
-
before_filter :authorize_read_note!
before_filter :authorize_write_note!, only: [:create]
1  app/controllers/profile_controller.rb
View
@@ -1,5 +1,4 @@
class ProfileController < ApplicationController
- layout "profile"
before_filter :user
def show
5 app/controllers/project_resource_controller.rb
View
@@ -0,0 +1,5 @@
+class ProjectResourceController < ApplicationController
+ before_filter :project
+ # Authorize
+ before_filter :add_project_abilities
+end
23 app/controllers/projects_controller.rb
View
@@ -1,15 +1,15 @@
require Rails.root.join('lib', 'gitlab', 'graph_commit')
-class ProjectsController < ApplicationController
- before_filter :project, except: [:index, :new, :create]
- layout :determine_layout
+class ProjectsController < ProjectResourceController
+ skip_before_filter :project, only: [:new, :create]
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!, except: [:index, :new, :create]
before_filter :authorize_admin_project!, only: [:edit, :update, :destroy]
before_filter :require_non_empty_project, only: [:blob, :tree, :graph]
+ layout 'application', only: [:new, :create]
+
def new
@project = Project.new
end
@@ -93,19 +93,4 @@ def destroy
format.html { redirect_to root_path }
end
end
-
- protected
-
- def project
- @project ||= Project.find_by_code(params[:id])
- @project || render_404
- end
-
- def determine_layout
- if @project && !@project.new_record?
- "project"
- else
- "application"
- end
- end
end
7 app/controllers/protected_branches_controller.rb
View
@@ -1,15 +1,10 @@
-class ProtectedBranchesController < ApplicationController
- before_filter :project
-
+class ProtectedBranchesController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :require_non_empty_project
before_filter :authorize_admin_project!, only: [:destroy, :create]
- layout "project"
-
def index
@branches = @project.protected_branches.all
@protected_branch = @project.protected_branches.new
12 app/controllers/refs_controller.rb
View
@@ -1,9 +1,7 @@
-class RefsController < ApplicationController
+class RefsController < ProjectResourceController
include Gitlab::Encode
- before_filter :project
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
@@ -11,11 +9,9 @@ class RefsController < ApplicationController
before_filter :ref
before_filter :define_tree_vars, only: [:blob, :logs_tree]
- layout "project"
-
- def switch
- respond_to do |format|
- format.html do
+ def switch
+ respond_to do |format|
+ format.html do
new_path = if params[:destination] == "tree"
project_tree_path(@project, @ref)
else
7 app/controllers/repositories_controller.rb
View
@@ -1,14 +1,9 @@
-class RepositoriesController < ApplicationController
- before_filter :project
-
+class RepositoriesController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
- layout "project"
-
def show
@activities = @project.commits_with_refs(20)
end
7 app/controllers/snippets_controller.rb
View
@@ -1,10 +1,5 @@
-class SnippetsController < ApplicationController
- before_filter :project
+class SnippetsController < ProjectResourceController
before_filter :snippet, only: [:show, :edit, :destroy, :update, :raw]
- layout "project"
-
- # Authorize
- before_filter :add_project_abilities
# Allow read any snippet
before_filter :authorize_read_snippet!
6 app/controllers/team_members_controller.rb
View
@@ -1,9 +1,5 @@
-class TeamMembersController < ApplicationController
- before_filter :project
- layout "project"
-
+class TeamMembersController < ProjectResourceController
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_admin_project!, except: [:index, :show]
7 app/controllers/tree_controller.rb
View
@@ -1,13 +1,8 @@
# Controller for viewing a repository's file structure
-class TreeController < ApplicationController
+class TreeController < ProjectResourceController
include ExtractsPath
- layout "project"
-
- before_filter :project
-
# Authorize
- before_filter :add_project_abilities
before_filter :authorize_read_project!
before_filter :authorize_code_access!
before_filter :require_non_empty_project
5 app/controllers/wikis_controller.rb
View
@@ -1,10 +1,7 @@
-class WikisController < ApplicationController
- before_filter :project
- before_filter :add_project_abilities
+class WikisController < ProjectResourceController
before_filter :authorize_read_wiki!
before_filter :authorize_write_wiki!, only: [:edit, :create, :history]
before_filter :authorize_admin_wiki!, only: :destroy
- layout "project"
def pages
@wikis = @project.wikis.group(:slug).order("created_at")
1  app/models/event.rb
View
@@ -20,6 +20,7 @@ class Event < ActiveRecord::Base
delegate :title, to: :issue, prefix: true, allow_nil: true
delegate :title, to: :merge_request, prefix: true, allow_nil: true
+ belongs_to :author, class_name: "User"
belongs_to :project
belongs_to :target, polymorphic: true
0  app/views/layouts/error.html.haml → app/views/layouts/errors.html.haml
View
File renamed without changes
0  app/views/layouts/project.html.haml → app/views/layouts/project_resource.html.haml
View
File renamed without changes
4 config/application.rb
View
@@ -53,5 +53,9 @@ class Application < Rails::Application
# Add fonts
config.assets.paths << "#{Rails.root}/app/assets/fonts"
+
+ config.to_prepare do
+ Devise::SessionsController.layout 'devise_layout'
+ end
end
end
5 features/profile/profile.feature
View
@@ -20,3 +20,8 @@ Feature: Profile
Given I visit profile account page
Then I reset my token
And I should see new token
+
+ Scenario: I visit history tab
+ Given I have activity
+ When I visit profile history page
+ Then I should see my activity
21 features/project/hooks.feature
View
@@ -0,0 +1,21 @@
+Feature: Project Hooks
+ Background:
+ Given I sign in as a user
+ And I own project "Shop"
+
+ Scenario: I should see hook list
+ Given project has hook
+ When I visit project hooks page
+ Then I should see project hook
+
+ Scenario: I add new hook
+ Given I visit project hooks page
+ When I submit new hook
+ Then I should see newly created hook
+
+ Scenario: I test hook
+ Given project has hook
+ And I visit project hooks page
+ When I click test hook button
+ Then hook should be triggered
+
8 features/steps/profile/profile.rb
View
@@ -41,4 +41,12 @@ class Profile < Spinach::FeatureSteps
find("#token").value.should_not == @old_token
find("#token").value.should == @user.reload.private_token
end
+
+ Given 'I have activity' do
+ Factory :closed_issue_event, author: current_user
+ end
+
+ Then 'I should see my activity' do
+ page.should have_content "#{current_user.name} closed issue"
+ end
end
36 features/steps/project/project_hooks.rb
View
@@ -0,0 +1,36 @@
+class ProjectHooks < Spinach::FeatureSteps
+ include SharedAuthentication
+ include SharedProject
+ include SharedPaths
+ include RSpec::Matchers
+ include RSpec::Mocks::ExampleMethods
+
+ Given 'project has hook' do
+ @hook = Factory :project_hook, project: current_project
+ end
+
+ Then 'I should see project hook' do
+ page.should have_content @hook.url
+ end
+
+ When 'I submit new hook' do
+ @url = Faker::Internet.uri("http")
+ fill_in "hook_url", with: @url
+ expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1)
+ end
+
+ Then 'I should see newly created hook' do
+ page.current_path.should == project_hooks_path(current_project)
+ page.should have_content(@url)
+ end
+
+ When 'I click test hook button' do
+ test_hook_context = double(execute: true)
+ TestHookContext.should_receive(:new).and_return(test_hook_context)
+ click_link 'Test Hook'
+ end
+
+ Then 'hook should be triggered' do
+ page.current_path.should == project_hooks_path(current_project)
+ end
+end
4 features/steps/shared/authentication.rb
View
@@ -11,4 +11,8 @@ module SharedAuthentication
Given 'I sign in as an admin' do
login_as :admin
end
+
+ def current_user
+ @user || User.first
+ end
end
4 features/steps/shared/paths.rb
View
@@ -125,6 +125,10 @@ module SharedPaths
visit project_wiki_path(@project, :index)
end
+ When 'I visit project hooks page' do
+ visit project_hooks_path(@project)
+ end
+
# ----------------------------------------
# "Shop" Project
# ----------------------------------------
4 features/steps/shared/project.rb
View
@@ -12,4 +12,8 @@ module SharedProject
@project = Factory :project, :name => "Shop"
@project.add_access(@user, :admin)
end
+
+ def current_project
+ @project ||= Project.first
+ end
end
6 spec/factories.rb
View
@@ -78,6 +78,12 @@ def self.attributes(type, *args)
end
factory :event do
+ factory :closed_issue_event do
+ project
+ action Event::Closed
+ target factory: :closed_issue
+ author factory: :user
+ end
end
factory :key do
43 spec/requests/hooks_spec.rb
View
@@ -1,43 +0,0 @@
-require 'spec_helper'
-
-describe "Hooks" do
- before do
- login_as :user
- @project = Factory :project
- @project.add_access(@user, :read, :admin)
- end
-
- describe "GET index" do
- it "should be available" do
- @hook = Factory :project_hook, project: @project
- visit project_hooks_path(@project)
- page.should have_content "Hooks"
- page.should have_content @hook.url
- end
- end
-
- describe "New Hook" do
- before do
- @url = Faker::Internet.uri("http")
- visit project_hooks_path(@project)
- fill_in "hook_url", with: @url
- expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1)
- end
-
- it "should open new team member popup" do
- page.current_path.should == project_hooks_path(@project)
- page.should have_content(@url)
- end
- end
-
- describe "Test" do
- before do
- @hook = Factory :project_hook, project: @project
- stub_request(:post, @hook.url)
- visit project_hooks_path(@project)
- click_link "Test Hook"
- end
-
- it { page.current_path.should == project_hooks_path(@project) }
- end
-end

Showing you all comments on commits in this comparison.

Robert Speicher

This is unnecessary. author is aliased to the user factory already. See https://github.com/gitlabhq/gitlabhq/blob/9cabe04368024f44881e4269a008156f1629ab86/spec/factories.rb#L30

Dmitriy Zaporozhets
Owner

@tsigo thank you. didnt know about aliases in factories :)

Something went wrong with that request. Please try again.