Replace saving cuke

pull/6827/head
Oliver Günther 7 years ago
parent f4beadb3c7
commit f5a2aa306c
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 132
      features/saving.feature
  2. 57
      spec/features/saving_spec.rb
  3. 13
      spec/features/support/pages/cost_report_page.rb

@ -1,132 +0,0 @@
#-- copyright
# OpenProject Reporting Plugin
#
# Copyright (C) 2010 - 2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#++
Feature: Saving Queries
@javascript
Scenario: Reports can be saved as private
Given there is a standard cost control project named "First Project"
And the role "Controller" may have the following rights:
| view_own_hourly_rate |
| view_hourly_rates |
| view_cost_rates |
| view_own_time_entries |
| view_own_cost_entries |
| view_cost_entries |
| view_time_entries |
| save_cost_reports |
| save_private_cost_reports |
And I am already logged in as "controller"
And I am on the Cost Reports page for the project called "First Project"
Then I should see "Save" within "#query-icon-save-as"
And I click on "Clear"
And I group columns by "Work package"
And I group rows by "Project"
And I set the filter "user_id" to the user with the login "developer" with the operator "!"
And I click on "Save"
And I fill in "Testreport" for "query_name"
And I click on "Save" within "#save_as_form"
Then I should see "Testreport" within "#ur_caption"
And I should see "Testreport" within "#private_sidebar_report_list"
And I should see "Work package" in columns
And I should see "Project" in rows
And filter "user_id" should be visible
@javascript
Scenario: Reports can be saved as public
Given there is a standard cost control project named "First Project"
And the role "Controller" may have the following rights:
| view_own_hourly_rate |
| view_hourly_rates |
| view_cost_rates |
| view_own_time_entries |
| view_own_cost_entries |
| view_cost_entries |
| view_time_entries |
| save_cost_reports |
| save_private_cost_reports |
And I am already logged in as "controller"
And I am on the Cost Reports page for the project called "First Project"
Then I should see "Save" within "#query-icon-save-as"
And I click on "Clear"
And I group columns by "Work package"
And I group rows by "Project"
And I set the filter "user_id" to the user with the login "developer" with the operator "!"
And I click on "Save"
And I fill in "Testreport" for "query_name"
And I check "Public"
And I click on "Save" within "#save_as_form"
Then I should see "Testreport" within "#ur_caption"
And I should see "Testreport" within "#public_sidebar_report_list"
And I should see "Work package" in columns
And I should see "Project" in rows
And filter "user_id" should be visible
@javascript
Scenario: Reports can't be saved by users without permissions
Given there is a standard permission test project named "Permission_Test"
And the role "Testuser" may have the following rights:
| view_hourly_rates |
| view_time_entries |
And I am already logged in as "testuser"
And I am on the Cost Reports page for the project called "Permission_Test"
Then I should not see "Save" within ".buttons"
@javascript
Scenario: Public Reports can't be saved by users allowed to save private queries
Given there is a standard permission test project named "Permission_Test"
And the role "Testuser" may have the following rights:
| view_hourly_rates |
| view_time_entries |
| save_private_cost_reports |
And I am already logged in as "testuser"
And I am on the Cost Reports page for the project called "Permission_Test"
Then I should see "Save"
And I click on "Save"
Then I should not see "Public"
And I fill in "Testreport" for "query_name"
And I click on "Save" within "#save_as_form"
Then I should see "Testreport" within "#ur_caption"
And I should see "Testreport" within "#private_sidebar_report_list"
@javascript
Scenario: Users that can save cost reports can save either public or private
Given there is a standard permission test project named "Permission_Test"
And the role "Testuser" may have the following rights:
| view_hourly_rates |
| view_time_entries |
| save_cost_reports |
And I am already logged in as "testuser"
And I am on the Cost Reports page for the project called "Permission_Test"
Then I should see "Save" within "#query-icon-save-as"
And I click on "Save"
Then I should see "Public"
And I fill in "Testreport" for "query_name"
And I click on "Save" within "#save_as_form"
Then I should see "Testreport" within "#ur_caption"
And I should see "Testreport" within "#private_sidebar_report_list"
Then I should see "Save" within "#query-icon-save-as"
And I click on "Save report as..."
Then I should see "Public"
And I check "Public"
And I fill in "Testreport2" for "query_name"
And I follow "Save" within "#save_as_form"
Then I should see "Testreport2" within "#ur_caption"
And I should see "Testreport2" within "#public_sidebar_report_list"
And I should see "Testreport" within "#private_sidebar_report_list"

@ -0,0 +1,57 @@
require 'spec_helper'
require_relative 'support/pages/cost_report_page'
describe 'Cost report saving', type: :feature, js: true do
let(:project) { FactoryGirl.create :project }
let(:user) { FactoryGirl.create :admin }
let(:report_page) { ::Pages::CostReportPage.new project}
before do
login_as(user)
visit cost_reports_path(project)
end
it 'can save reports privately' do
report_page.clear
report_page.add_to_columns 'Work package'
report_page.add_to_rows 'Project'
report_page.save as: 'Testreport'
expect(page).to have_selector('#ur_caption', text: 'Testreport')
expect(page).to have_selector('#private_sidebar_report_list', text: 'Testreport')
report_page.expect_column_element 'Work package'
report_page.expect_row_element 'Project'
end
it 'can save reports publicly' do
report_page.clear
report_page.add_to_columns 'Work package'
report_page.add_to_rows 'Project'
report_page.save as: 'Public report', public: true
expect(page).to have_selector('#ur_caption', text: 'Public report')
expect(page).to have_selector('#public_sidebar_report_list', text: 'Public report')
report_page.expect_column_element 'Work package'
report_page.expect_row_element 'Project'
end
context 'as user without permissions' do
let(:role) { FactoryGirl.create :role, permissions: %i(view_time_entries) }
let!(:user) do
FactoryGirl.create :user,
member_in_project: project,
member_through_role: role
end
it 'cannot save reports' do
expect(page).to have_no_selector('.buttons', text: 'Save')
end
end
end

@ -10,6 +10,19 @@ module Pages
click_on 'Clear'
end
def save(as:, public: false)
click_on 'Save'
fill_in 'query_name', with: as
if public
check 'Public'
end
page.within('#save_as_form') do
click_on 'Save'
end
end
def switch_to_type(label)
choose label
apply

Loading…
Cancel
Save