Clear filters when selecting work packages index item and add integration test

pull/758/head
Till Breuer 11 years ago committed by Christian Ratz
parent d763278dde
commit 7e372f9cbf
  1. 8
      lib/redmine.rb
  2. 39
      spec/features/work_packages/select_query_spec.rb
  3. 34
      spec/features/work_packages/work_packages_page.rb

@ -293,10 +293,10 @@ Redmine::MenuManager.map :project_menu do |menu|
:if => Proc.new { |p| p.shared_versions.any? }, :if => Proc.new { |p| p.shared_versions.any? },
:html => {:class => "icon2 icon-new-planning-element"} :html => {:class => "icon2 icon-new-planning-element"}
menu.push :work_packages, { :controller => '/work_packages', :action => 'index' }, menu.push :work_packages, { controller: '/work_packages', action: 'index', set_filter: 1 },
:param => :project_id, param: :project_id,
:caption => :label_work_package_plural, caption: :label_work_package_plural,
:html => {:class => "icon2 icon-copy"} html: {class: "icon2 icon-copy"}
menu.push :new_work_package, { :controller => '/work_packages', :action => 'new'}, menu.push :new_work_package, { :controller => '/work_packages', :action => 'new'},
:param => :project_id, :param => :project_id,

@ -0,0 +1,39 @@
# encoding: utf-8
require 'spec_helper'
require 'features/work_packages/work_packages_page'
describe 'Query selection' do
let(:project) { FactoryGirl.create :project, identifier: 'test_project', is_public: false }
let(:role) { FactoryGirl.create :role, :permissions => [:view_work_packages] }
let(:current_user) { FactoryGirl.create :user, member_in_project: project,
member_through_role: role }
let(:filter_name) { 'done_ratio' }
let!(:query) do
query = FactoryGirl.build(:query, project: project, is_public: true)
query.filters = [Queries::WorkPackages::Filter.new(filter_name, operator: ">=", values: [10]) ]
query.save and return query
end
let(:work_packages_page) { WorkPackagesPage.new(project) }
before do
User.stub(:current).and_return current_user
end
context 'when a query is selected' do
before do
work_packages_page.visit_index
work_packages_page.select_query query
end
context 'and the work packages menu item is clicked' do
before { work_packages_page.click_work_packages_menu_item }
it 'clears selected queries' do
work_packages_page.should_not have_selected_filter(filter_name)
end
end
end
end

@ -0,0 +1,34 @@
class WorkPackagesPage
include Rails.application.routes.url_helpers
include Capybara::DSL
def initialize(project=nil)
@project = project
end
def visit_index
visit index_path
end
def click_work_packages_menu_item
find('#main-menu .work-packages').click
end
def select_query(query)
visit query_path(query);
end
def has_selected_filter?(filter_name)
find(".filter-fields #cb_#{filter_name}", visible: false).checked?
end
private
def index_path
@project ? project_work_packages_path(@project) : work_packages_path
end
def query_path(query)
"#{index_path}?query_id=#{query.id}"
end
end
Loading…
Cancel
Save