Commit f6c482c06f48449e7dcff34455b5bbdfbd8f6c7b
1 parent
d9027df5
Exists in
master
and in
4 other branches
User can create group
Showing
12 changed files
with
117 additions
and
31 deletions
Show diff stats
app/controllers/groups_controller.rb
| 1 | class GroupsController < ApplicationController | 1 | class GroupsController < ApplicationController |
| 2 | respond_to :html | 2 | respond_to :html |
| 3 | - layout 'group' | 3 | + layout 'group', except: [:new, :create] |
| 4 | 4 | ||
| 5 | - before_filter :group | ||
| 6 | - before_filter :projects | 5 | + before_filter :group, except: [:new, :create] |
| 7 | 6 | ||
| 8 | # Authorize | 7 | # Authorize |
| 9 | - before_filter :authorize_read_group! | 8 | + before_filter :authorize_read_group!, except: [:new, :create] |
| 9 | + | ||
| 10 | + # Load group projects | ||
| 11 | + before_filter :projects, except: [:new, :create] | ||
| 12 | + | ||
| 13 | + def new | ||
| 14 | + @group = Group.new | ||
| 15 | + end | ||
| 16 | + | ||
| 17 | + def create | ||
| 18 | + @group = Group.new(params[:group]) | ||
| 19 | + @group.path = @group.name.dup.parameterize if @group.name | ||
| 20 | + @group.owner = current_user | ||
| 21 | + | ||
| 22 | + if @group.save | ||
| 23 | + redirect_to @group, notice: 'Group was successfully created.' | ||
| 24 | + else | ||
| 25 | + render action: "new" | ||
| 26 | + end | ||
| 27 | + end | ||
| 10 | 28 | ||
| 11 | def show | 29 | def show |
| 12 | @events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0) | 30 | @events = Event.in_projects(project_ids).limit(20).offset(params[:offset] || 0) |
app/helpers/tab_helper.rb
| @@ -39,7 +39,12 @@ module TabHelper | @@ -39,7 +39,12 @@ module TabHelper | ||
| 39 | # Returns a list item element String | 39 | # Returns a list item element String |
| 40 | def nav_link(options = {}, &block) | 40 | def nav_link(options = {}, &block) |
| 41 | if path = options.delete(:path) | 41 | if path = options.delete(:path) |
| 42 | - c, a, _ = path.split('#') | 42 | + if path.respond_to?(:each) |
| 43 | + c = path.map { |p| p.split('#').first } | ||
| 44 | + a = path.map { |p| p.split('#').last } | ||
| 45 | + else | ||
| 46 | + c, a, _ = path.split('#') | ||
| 47 | + end | ||
| 43 | else | 48 | else |
| 44 | c = options.delete(:controller) | 49 | c = options.delete(:controller) |
| 45 | a = options.delete(:action) | 50 | a = options.delete(:action) |
app/models/user.rb
app/views/dashboard/_groups.html.haml
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | (#{groups.count}) | 5 | (#{groups.count}) |
| 6 | - if current_user.can_create_group? | 6 | - if current_user.can_create_group? |
| 7 | %span.right | 7 | %span.right |
| 8 | - = link_to new_admin_group_path, class: "btn very_small info" do | 8 | + = link_to new_group_path, class: "btn very_small info" do |
| 9 | %i.icon-plus | 9 | %i.icon-plus |
| 10 | New Group | 10 | New Group |
| 11 | %ul.well-list | 11 | %ul.well-list |
| @@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
| 1 | +%h3.page_title New Group | ||
| 2 | +%hr | ||
| 3 | += form_for @group do |f| | ||
| 4 | + - if @group.errors.any? | ||
| 5 | + .alert-message.block-message.error | ||
| 6 | + %span= @group.errors.full_messages.first | ||
| 7 | + .clearfix | ||
| 8 | + = f.label :name do | ||
| 9 | + Group name is | ||
| 10 | + .input | ||
| 11 | + = f.text_field :name, placeholder: "Ex. OpenSource", class: "xxlarge left" | ||
| 12 | + | ||
| 13 | + = f.submit 'Create group', class: "btn primary" | ||
| 14 | + %hr | ||
| 15 | + .padded | ||
| 16 | + %ul | ||
| 17 | + %li Group is kind of directory for several projects | ||
| 18 | + %li All created groups are private | ||
| 19 | + %li People within a group see only projects they have access to | ||
| 20 | + %li All projects of group will be stored in group directory | ||
| 21 | + %li You will be able to move existing projects into group |
app/views/layouts/_head_panel.html.haml
| @@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
| 17 | = link_to new_project_path, title: "Create New Project", class: 'has_bottom_tooltip', 'data-original-title' => 'New project' do | 17 | = link_to new_project_path, title: "Create New Project", class: 'has_bottom_tooltip', 'data-original-title' => 'New project' do |
| 18 | %i.icon-plus | 18 | %i.icon-plus |
| 19 | %li | 19 | %li |
| 20 | - = link_to profile_path, title: "Your Profile", class: 'has_bottom_tooltip', 'data-original-title' => 'Your profile' do | 20 | + = link_to profile_path, title: "My Profile", class: 'has_bottom_tooltip', 'data-original-title' => 'Your profile' do |
| 21 | %i.icon-user | 21 | %i.icon-user |
| 22 | %li.separator | 22 | %li.separator |
| 23 | %li | 23 | %li |
app/views/projects/_new_form.html.haml
| @@ -15,6 +15,12 @@ | @@ -15,6 +15,12 @@ | ||
| 15 | %span Namespace | 15 | %span Namespace |
| 16 | .input | 16 | .input |
| 17 | = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen'} | 17 | = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user), {}, {class: 'chosen'} |
| 18 | + - elsif current_user.can_create_group? | ||
| 19 | + .clearfix | ||
| 20 | + .input.light | ||
| 21 | + Need a group for several projects? | ||
| 22 | + = link_to new_group_path, class: "btn very_small" do | ||
| 23 | + Create a group | ||
| 18 | %hr | 24 | %hr |
| 19 | %p.padded | 25 | %p.padded |
| 20 | New projects are private by default. You choose who can see the project and commit to repository. | 26 | New projects are private by default. You choose who can see the project and commit to repository. |
| @@ -0,0 +1,23 @@ | @@ -0,0 +1,23 @@ | ||
| 1 | +.ui-box | ||
| 2 | + %h5.title | ||
| 3 | + Profile | ||
| 4 | + %ul.well-list | ||
| 5 | + %li | ||
| 6 | + %strong Email | ||
| 7 | + %span.right= mail_to @user.email | ||
| 8 | + - unless @user.skype.blank? | ||
| 9 | + %li | ||
| 10 | + %strong Skype | ||
| 11 | + %span.right= @user.skype | ||
| 12 | + - unless @user.linkedin.blank? | ||
| 13 | + %li | ||
| 14 | + %strong LinkedIn | ||
| 15 | + %span.right= @user.linkedin | ||
| 16 | + - unless @user.twitter.blank? | ||
| 17 | + %li | ||
| 18 | + %strong Twitter | ||
| 19 | + %span.right= @user.twitter | ||
| 20 | + - unless @user.bio.blank? | ||
| 21 | + %li | ||
| 22 | + %strong Bio | ||
| 23 | + %span.right= @user.bio |
app/views/users/show.html.haml
| @@ -3,6 +3,11 @@ | @@ -3,6 +3,11 @@ | ||
| 3 | %h3.page_title | 3 | %h3.page_title |
| 4 | = image_tag gravatar_icon(@user.email, 90), class: "avatar s90" | 4 | = image_tag gravatar_icon(@user.email, 90), class: "avatar s90" |
| 5 | = @user.name | 5 | = @user.name |
| 6 | + - if @user == current_user | ||
| 7 | + .right | ||
| 8 | + = link_to profile_path, class: 'btn small' do | ||
| 9 | + %i.icon-edit | ||
| 10 | + Edit Profile | ||
| 6 | %br | 11 | %br |
| 7 | %small @#{@user.username} | 12 | %small @#{@user.username} |
| 8 | %br | 13 | %br |
| @@ -12,26 +17,5 @@ | @@ -12,26 +17,5 @@ | ||
| 12 | %h5 Recent events | 17 | %h5 Recent events |
| 13 | = render @events | 18 | = render @events |
| 14 | .span4 | 19 | .span4 |
| 15 | - .ui-box | ||
| 16 | - %h5.title Profile | ||
| 17 | - %ul.well-list | ||
| 18 | - %li | ||
| 19 | - %strong Email | ||
| 20 | - %span.right= mail_to @user.email | ||
| 21 | - - unless @user.skype.blank? | ||
| 22 | - %li | ||
| 23 | - %strong Skype | ||
| 24 | - %span.right= @user.skype | ||
| 25 | - - unless @user.linkedin.blank? | ||
| 26 | - %li | ||
| 27 | - %strong LinkedIn | ||
| 28 | - %span.right= @user.linkedin | ||
| 29 | - - unless @user.twitter.blank? | ||
| 30 | - %li | ||
| 31 | - %strong Twitter | ||
| 32 | - %span.right= @user.twitter | ||
| 33 | - - unless @user.bio.blank? | ||
| 34 | - %li | ||
| 35 | - %strong Bio | ||
| 36 | - %span.right= @user.bio | 20 | + = render 'profile' |
| 37 | = render 'projects' | 21 | = render 'projects' |
config/routes.rb
| @@ -112,7 +112,7 @@ Gitlab::Application.routes.draw do | @@ -112,7 +112,7 @@ Gitlab::Application.routes.draw do | ||
| 112 | # | 112 | # |
| 113 | # Groups Area | 113 | # Groups Area |
| 114 | # | 114 | # |
| 115 | - resources :groups, constraints: { id: /[^\/]+/ }, only: [:show] do | 115 | + resources :groups, constraints: { id: /[^\/]+/ }, only: [:show, :new, :create] do |
| 116 | member do | 116 | member do |
| 117 | get :issues | 117 | get :issues |
| 118 | get :merge_requests | 118 | get :merge_requests |
| @@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
| 1 | +Feature: Groups | ||
| 2 | + Background: | ||
| 3 | + Given I sign in as a user | ||
| 4 | + | ||
| 5 | + Scenario: Create a group from dasboard | ||
| 6 | + Given I have group with projects | ||
| 7 | + And I visit dashboard page | ||
| 8 | + When I click new group link | ||
| 9 | + And submit form with new group info | ||
| 10 | + Then I should be redirected to group page | ||
| 11 | + And I should see newly created group |
features/steps/group/group.rb
| @@ -64,6 +64,24 @@ class Groups < Spinach::FeatureSteps | @@ -64,6 +64,24 @@ class Groups < Spinach::FeatureSteps | ||
| 64 | author: current_user | 64 | author: current_user |
| 65 | end | 65 | end |
| 66 | 66 | ||
| 67 | + When 'I click new group link' do | ||
| 68 | + click_link "New Group" | ||
| 69 | + end | ||
| 70 | + | ||
| 71 | + And 'submit form with new group info' do | ||
| 72 | + fill_in 'group_name', :with => 'Samurai' | ||
| 73 | + click_button "Create group" | ||
| 74 | + end | ||
| 75 | + | ||
| 76 | + Then 'I should see newly created group' do | ||
| 77 | + page.should have_content "Samurai" | ||
| 78 | + page.should have_content "You will only see events from projects in this group" | ||
| 79 | + end | ||
| 80 | + | ||
| 81 | + Then 'I should be redirected to group page' do | ||
| 82 | + current_path.should == group_path(Group.last) | ||
| 83 | + end | ||
| 84 | + | ||
| 67 | protected | 85 | protected |
| 68 | 86 | ||
| 69 | def current_group | 87 | def current_group |