parent
d763278dde
commit
7e372f9cbf
@ -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…
Reference in new issue