From 072883fd08d2c15498ef12f96090ec14529a0bbc Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Tue, 12 Mar 2013 13:26:45 +0400 Subject: [PATCH 1/4] Search projects on dashboard was not worked. Fixed --- app/controllers/dashboard_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 9fd477dcdb..91a6798571 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -34,6 +34,7 @@ class DashboardController < ApplicationController @projects end + @projects = @projects.search(params[:search]) if params[:search].present? @projects = @projects.page(params[:page]).per(30) end From 23f8f13ea442cc878a2a4fc61b7ff9f492517c27 Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Tue, 12 Mar 2013 13:33:27 +0400 Subject: [PATCH 2/4] Search fields were have same id's. Fixed --- app/views/dashboard/_filter.html.haml | 2 +- app/views/dashboard/projects.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/dashboard/_filter.html.haml b/app/views/dashboard/_filter.html.haml index 82e679d592..df4447cd20 100644 --- a/app/views/dashboard/_filter.html.haml +++ b/app/views/dashboard/_filter.html.haml @@ -1,6 +1,6 @@ = form_tag dashboard_filter_path(entity), method: 'get' do %fieldset.dashboard-search-filter - = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'search-text-input' } + = search_field_tag "search", params[:search], { id: 'filter_search', placeholder: 'Search', class: 'search-text-input' } = button_tag type: 'submit', class: 'btn' do %i.icon-search diff --git a/app/views/dashboard/projects.html.haml b/app/views/dashboard/projects.html.haml index 8e21b0c7e0..e211fc34d1 100644 --- a/app/views/dashboard/projects.html.haml +++ b/app/views/dashboard/projects.html.haml @@ -24,7 +24,7 @@ = form_tag projects_dashboard_path, method: 'get' do %fieldset.dashboard-search-filter = hidden_field_tag "scope", params[:scope] - = search_field_tag "search", params[:search], { placeholder: 'Search', class: 'left input-xxlarge' } + = search_field_tag "search", params[:search], { id: 'dashboard_projects_search', placeholder: 'Search', class: 'left input-xxlarge'} = button_tag type: 'submit', class: 'btn' do %i.icon-search From 804ae05c58984badf9041509fb01e950d02a71e1 Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Tue, 12 Mar 2013 13:40:54 +0400 Subject: [PATCH 3/4] Tests improved --- features/dashboard/projects.feature | 8 +++++++- .../steps/dashboard/dashboard_projects.rb | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 features/steps/dashboard/dashboard_projects.rb diff --git a/features/dashboard/projects.feature b/features/dashboard/projects.feature index 17022dab54..852252715c 100644 --- a/features/dashboard/projects.feature +++ b/features/dashboard/projects.feature @@ -4,5 +4,11 @@ Feature: Dashboard And I own project "Shop" And I visit dashboard projects page - Scenario: I should see issues list + Scenario: I should see projects list Then I should see projects list + + Scenario: I should see project I am looking for + Given I search for "Sho" + Then I should see "Shop" project link + + diff --git a/features/steps/dashboard/dashboard_projects.rb b/features/steps/dashboard/dashboard_projects.rb new file mode 100644 index 0000000000..9b9d4a53c5 --- /dev/null +++ b/features/steps/dashboard/dashboard_projects.rb @@ -0,0 +1,20 @@ +class Dashboard < Spinach::FeatureSteps + include SharedAuthentication + include SharedPaths + include SharedProject + + Then 'I should see projects list' do + @user.authorized_projects.all.each do |project| + page.should have_link project.name_with_namespace + end + end + + Given 'I search for "Sho"' do + fill_in "dashboard_projects_search", with: "Sho" + click_button "Search" + end + + Then 'I should see "Shop" project link' do + page.should have_link "Shop" + end +end From fce22dfa2fe8dd0f551f0a24dae4a52d4096c6f1 Mon Sep 17 00:00:00 2001 From: Andrew8xx8 Date: Tue, 12 Mar 2013 15:15:14 +0400 Subject: [PATCH 4/4] Tests for dashboard projects fixed --- features/dashboard/projects.feature | 8 +++----- features/steps/dashboard/dashboard_projects.rb | 5 ++++- features/steps/shared/project.rb | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/features/dashboard/projects.feature b/features/dashboard/projects.feature index 852252715c..7e617bd1bf 100644 --- a/features/dashboard/projects.feature +++ b/features/dashboard/projects.feature @@ -1,4 +1,4 @@ -Feature: Dashboard +Feature: Dashboard projects Background: Given I sign in as a user And I own project "Shop" @@ -8,7 +8,5 @@ Feature: Dashboard Then I should see projects list Scenario: I should see project I am looking for - Given I search for "Sho" - Then I should see "Shop" project link - - + Given I search for "Sho" + Then I should see "Shop" project link diff --git a/features/steps/dashboard/dashboard_projects.rb b/features/steps/dashboard/dashboard_projects.rb index 9b9d4a53c5..de471ebd8c 100644 --- a/features/steps/dashboard/dashboard_projects.rb +++ b/features/steps/dashboard/dashboard_projects.rb @@ -11,7 +11,10 @@ class Dashboard < Spinach::FeatureSteps Given 'I search for "Sho"' do fill_in "dashboard_projects_search", with: "Sho" - click_button "Search" + + within ".dashboard-search-filter" do + find('button').click + end end Then 'I should see "Shop" project link' do diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 5e61a4132c..81863a54f3 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -9,7 +9,8 @@ module SharedProject # Create a specific project called "Shop" And 'I own project "Shop"' do - @project = create(:project, name: "Shop") + @project = Project.find_by_name "Shop" + @project ||= create(:project, name: "Shop") @project.team << [@user, :master] end