OSDN Git Service

Merge branch 'deploy_keys'
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Sat, 14 Jan 2012 19:26:35 +0000 (21:26 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Sat, 14 Jan 2012 19:26:35 +0000 (21:26 +0200)
Conflicts:
app/views/layouts/project.html.haml
db/schema.rb

1  2 
app/controllers/deploy_keys_controller.rb
app/models/project.rb
app/views/deploy_keys/index.html.haml
app/views/layouts/project.html.haml
app/views/repositories/_head.html.haml
config/routes.rb
db/schema.rb
spec/requests/projects_deploy_keys_spec.rb

index 0000000,7bbf6a3..36e4278
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,44 +1,44 @@@
 -  respond_to :js
+ class DeployKeysController < ApplicationController
++  respond_to :js, :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
+   def show
+     @key = @project.deploy_keys.find(params[:id])
+   end
+   def new
+     @key = @project.deploy_keys.new
+     respond_with(@key)
+   end
+   def create
+     @key = @project.deploy_keys.new(params[:key])
+     @key.save
+     respond_with(@key)
+   end
+   def destroy
+     @key = @project.deploy_keys.find(params[:id])
+     @key.destroy
+     respond_to do |format|
+       format.html { redirect_to project_deploy_keys_url }
+       format.js { render :nothing => true }
+     end
+   end
+ end
Simple merge
index 0000000,9cd28de..d3feadb
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,16 +1,11 @@@
 -%h2.icon
 -  %span>
 -  SSH Keys
 -%div#new-key-holder.right
 -  = link_to "Add new", new_project_deploy_key_path, :remote => true, :class => "grey-button"
 -%br
++= render "repositories/head"
+ %div#keys-table{ :class => "update-data ui-box ui-box-small ui-box-big" }
+   .data
+     - @keys.each do |key|
+       = render(:partial => 'show', :locals => {:key => key})
+ :javascript
+   $('.delete-key').live('ajax:success', function() {
+     $(this).closest('.update-item').fadeOut(); });
                  - if @project.common_notes.today.count > 0
                    %span{ :class => "number" }= @project.common_notes.today.count
                = link_to project_merge_requests_path(@project), :class => (controller.controller_name == "merge_requests") ? "current" : nil do
 -                Merge Requests
 -                - if @project.merge_requests.opened.count > 0
 +                Requests
 +                -#- if @project.merge_requests.opened.count > 0
                    %span{ :class => "number" }= @project.merge_requests.opened.count
 -              = link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do
 -                Snippets
 -                - if @project.snippets.non_expired.count > 0
 -                  %span{ :class => "number" }= @project.snippets.non_expired.count
  
 -              - if can? current_user, :admin_project, @project
 -                = link_to "Admin", edit_project_path(@project), :class => (current_page?(edit_project_path(@project))) ? "current" : nil
 -                = link_to "Deploy keys", project_deploy_keys_path(@project), :class => (current_page?(project_deploy_keys_path(@project))) ? "current" : nil
  
 -            .medium-tags{:style => 'padding: 10px 0 0 10px; width: 210px;'}= tag_list @project
          .project-content
            = yield
index 53af050,0000000..82a2280
mode 100644,000000..100644
--- /dev/null
@@@ -1,23 -1,0 +1,28 @@@
-   -#= link_to "#", :class => "tab" do 
-     %span
-     Deploy Keys
 +.merge-tabs.repository
 +  = link_to project_repository_path(@project), :class => "activities-tab tab #{'active' if current_page?(project_repository_path(@project)) }" do 
 +    %span
 +    Activities
 +  = link_to branches_project_repository_path(@project), :class => "tab #{'active' if current_page?(branches_project_repository_path(@project)) }" do 
 +    %span
 +    Branches
 +  = link_to tags_project_repository_path(@project), :class => "tab #{'active' if current_page?(tags_project_repository_path(@project)) }" do 
 +    %span 
 +    Tags
 +  = link_to project_hooks_path, :class => "tab #{'active' if controller.controller_name == "hooks" }" do 
 +    %span
 +    Hooks
++  - if can? current_user, :admin_project, @project
++    = link_to project_deploy_keys_path(@project), :class => "tab #{'active' if controller.controller_name == "deploy_keys"}" do 
++      %span
++      Deploy Keys
 +
 +  - if current_page?(project_hooks_path(@project))
 +    - if can? current_user, :admin_project, @project
 +      = link_to new_project_hook_path(@project), :class => "add_new", :title => "New Web Hook" do 
 +        = image_tag "add_new.png", :width => 14
 +
++  - if current_page?(project_deploy_keys_path(@project))
++    - if can? current_user, :admin_project, @project
++      = link_to new_project_deploy_key_path(@project), :class => "add_new", :title => "New Deploy Key", :remote => true do 
++        = image_tag "add_new.png", :width => 14
 +
@@@ -42,17 -42,10 +42,19 @@@ Gitlab::Application.routes.draw d
        get "team"
        get "wall"
        get "graph"
 +      get "info"
 +      get "files"
 +    end
 +
 +    resource :repository do 
 +      member do 
 +        get "branches"
 +        get "tags"
 +      end
      end
  
+     resources :deploy_keys
      resources :refs, :only => [], :path => "/" do 
        collection do 
          get "switch"
diff --cc db/schema.rb
Simple merge
index 0000000,8099124..8258f26
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,68 +1,68 @@@
 -      click_link "Add new"
+ require 'spec_helper'
+ describe "Projects", "DeployKeys" do
+   let(:project) { Factory :project }
+   before do
+     login_as :user
+     project.add_access(@user, :read, :write, :admin)
+   end
+   describe "GET /keys" do
+     before do
+       @key = Factory :key, :project => project
+       visit project_deploy_keys_path(project)
+     end
+     subject { page }
+     it { should have_content(@key.title) }
+     describe "Destroy" do
+       before { visit project_deploy_key_path(project, @key) }
+       it "should remove entry" do
+         expect {
+           click_link "Remove"
+         }.to change { project.deploy_keys.count }.by(-1)
+       end
+     end
+   end
+   describe "New key", :js => true do
+     before do
+       visit project_deploy_keys_path(project)
++      click_link "New Deploy Key"
+     end
+     it "should open new key popup" do
+       page.should have_content("Add new public key")
+     end
+     describe "fill in" do
+       before do
+         fill_in "key_title", :with => "laptop"
+         fill_in "key_key", :with => "publickey234="
+       end
+       it { expect { click_button "Save" }.to change {Key.count}.by(1) }
+       it "should add new key to table" do
+         click_button "Save"
+         page.should_not have_content("Add new public key")
+         page.should have_content "laptop"
+       end
+     end
+   end
+   describe "Show page" do 
+     before do
+       @key = Factory :key, :project => project
+       visit project_deploy_key_path(project, @key) 
+     end
+     
+     it { page.should have_content @key.title }
+     it { page.should have_content @key.key[0..10] }
+   end
+ end