closes #4414
authorRadhika Chippada <radhika@curoverse.com>
Fri, 12 Dec 2014 21:29:50 +0000 (16:29 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Fri, 12 Dec 2014 21:29:50 +0000 (16:29 -0500)
Merge branch '4414-add-new-in-project-dropdown'

apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/views/application/_projects_tree_menu.html.erb
apps/workbench/app/views/layouts/body.html.erb
apps/workbench/test/integration/projects_test.rb

index 6fea62563d2828e66278b31af5632ca3a8bf9811..c7575176dec97fa4762bb3d730fd3ec0ef95b7ca 100644 (file)
@@ -322,6 +322,7 @@ class ApplicationController < ActionController::Base
     @new_resource_attrs ||= {}
     @new_resource_attrs.reject! { |k,v| k.to_s == 'uuid' }
     @object ||= model_class.new @new_resource_attrs, params["options"]
+
     if @object.save
       show
     else
index 600c6ab96fcfca4f8a5980746e9a7fca8ffa75e9..4a49184aaf409805dcd3df2dd41e3ab632fefb33 100644 (file)
@@ -1,3 +1,8 @@
+              <li>
+                <%= link_to projects_path(options: {ensure_unique_name: true}), method: :post, class: 'btn btn-xs btn-default pull-right' do %>
+                  <i class="fa fa-plus"></i> Add a new project
+                <% end %>
+              </li>
               <li>
                 <%= project_link_to.call({object: current_user, depth: 0}) do %>
                   <span style="padding-left: 0"></span>Home
index 035d147f0458411517130da0d6899dfaa56926a1..07b536b8e366fcef537ad7f3f869c90462787566 100644 (file)
               <span class="caret"></span>
             </a>
             <ul class="dropdown-menu" role="menu">
-            <%= render partial: "projects_tree_menu", locals: {
+              <%= render partial: "projects_tree_menu", locals: {
                   :project_link_to => Proc.new do |pnode, &block|
                     link_to(project_path(pnode[:object].uuid),
                       data: { 'object-uuid' => pnode[:object].uuid,
                               'name' => 'name' },
                       &block)
                   end,
-                  :top_button => Proc.new do %>
-                    <% link_to projects_path, method: :post, class: 'btn btn-xs btn-default pull-right' do %>
-                      <i class="fa fa-plus"></i> New project
-                    <% end %>
-                  <% end %>
-            <% } %>
+              } %>
             </ul>
           </li>
           <% if @name_link or @object %>
index 0ed2624d8dd0ba41eb2a80db4b24d577946b37ac..97e1a542bafcfad5f7a7e930c48c21f9417ec149 100644 (file)
@@ -147,7 +147,6 @@ class ProjectsTest < ActionDispatch::IntegrationTest
     find(".dropdown-menu a", text: "Home").click
     find('.btn', text: "Add a subproject").click
 
-    # within('.editable', text: 'New project') do
     within('h2') do
       find('.fa-pencil').click
       find('.editable-input input').set('Project 1234')
@@ -728,4 +727,21 @@ class ProjectsTest < ActionDispatch::IntegrationTest
     end
   end
 
+  test "add new project using projects dropdown" do
+    # verify that selection options are disabled on the project until an item is selected
+    visit page_with_token 'active', '/'
+
+    # Add a new project
+    find("#projects-menu").click
+    click_link 'Add a new project'
+    assert_text 'New project'
+    assert_text 'No description provided'
+
+    # Add one more new project
+    find("#projects-menu").click
+    click_link 'Add a new project'
+    match = /New project \(\d\)/.match page.text
+    assert match, 'Expected project name not found'
+    assert_text 'No description provided'
+  end
 end