git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1526 7926756e-e54e-46e6-9721-ed318f58905epull/6827/head
parent
cdf2636053
commit
4da42ee78a
@ -0,0 +1,34 @@ |
||||
Feature: Cost Reporting Calculations |
||||
|
||||
Scenario: Different Rates are calculated differently |
||||
Given there is a standard cost control project named "Cost Project" |
||||
And there is 1 hourly rate with the following: |
||||
| rate | 1 | |
||||
| user | manager | |
||||
| valid from | 1 year ago | |
||||
And there is 1 hourly rate with the following: |
||||
| rate | 5 | |
||||
| user | manager | |
||||
| valid from | 2 years ago | |
||||
And there is 1 default hourly rate with the following: |
||||
| rate | 10 | |
||||
| user | manager | |
||||
| valid from | 3 years ago | |
||||
And the project "Cost Project" has 1 time entry with the following: |
||||
| hours | 10 | |
||||
| user | manager | |
||||
| spent on | 0.5 years ago | |
||||
And the project "Cost Project" has 1 time entry with the following: |
||||
| hours | 10 | |
||||
| user | manager | |
||||
| spent on | 1.5 years ago | |
||||
And the project "Cost Project" has 1 time entry with the following: |
||||
| hours | 10 | |
||||
| user | manager | |
||||
| spent on | 2.5 years ago | |
||||
And I am logged in as "manager" |
||||
And I am on the cost reports page for the project called "Cost Project" |
||||
Then I should see "10.00" # 1 EUR x 10 (hours) |
||||
And I should see "50.00" # 5 EUR x 10 (hours) |
||||
And I should see "100.00" # 10 EUR x 10 (hours) |
||||
And I should see "160.00" |
@ -0,0 +1,56 @@ |
||||
Feature: Cost Reporting Linkage |
||||
|
||||
Scenario: Coming to the cost report for the first time, I should see no entries that are not my own |
||||
Given there is a standard cost control project named "Some Project" |
||||
And there is 1 cost type with the following: |
||||
| name | Translation | |
||||
And the user "manager" has one cost entry |
||||
And I am admin |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should see "Const Entry Attributes" |
||||
And I should see "User" |
||||
And I should see "<< me >>" |
||||
And I should see "No data to display" |
||||
And I should not see "0.00" |
||||
|
||||
Scenario: Coming to the cost report for the first time, I should see my entries |
||||
Given there is a standard cost control project named "Standard Project" |
||||
And the user "manager" has: |
||||
| hourly rate | 10 | |
||||
| default rate | 10 | |
||||
And the user "manager" has 1 issue with: |
||||
| subject | manager issue | |
||||
And the issue "manager issue" has 1 time entry with the following: |
||||
| user | manager | |
||||
| hours | 10 | |
||||
And there is 1 cost type with the following: |
||||
| name | word | |
||||
| cost rate | 10 | |
||||
And the user "manager" has 1 cost entry with the following: |
||||
| units | 5 | |
||||
And I am logged in as "manager" |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should see "50.00" # 5 (units) x 10 EUR |
||||
And I should see "100.00" # 10 (hours) x 10 EUR |
||||
And I should see "150.00" # 100 EUR + 50 EUR |
||||
And I should not see "No data to display" |
||||
|
||||
Scenario: Going from an Issue to the cost report should set the filter on this issue |
||||
Given there is a standard cost control project named "Standard Project" |
||||
And the user "manager" has: |
||||
| default rate | 10 | |
||||
And the user "manager" has 1 issue with: |
||||
| subject | manager issue | |
||||
And the user "manager" has 1 issue with: |
||||
| subject | another issue | |
||||
And the issue "manager issue" has 1 time entry with the following: |
||||
| user | manager | |
||||
| hours | 10 | |
||||
And the issue "another issue" has 1 time entry with the following: |
||||
| user | manager | |
||||
| hours | 5 | |
||||
And I am logged in as "manager" |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should see "100.00" # 10 EUR x 10 (hours) |
||||
And I should not see "50.00" # 10 EUR x 5 (hours) |
||||
And I should not see "150.00" |
@ -0,0 +1,129 @@ |
||||
Feature: Permissions |
||||
|
||||
Scenario: Anonymous user sees no costs |
||||
Given I am not logged in |
||||
And there is 1 Project with the following: |
||||
| Name | Test | |
||||
And the project "Test" has 1 cost entry |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should see "Login:" |
||||
And I should see "Password:" |
||||
|
||||
Scenario: Admin user sees everything |
||||
Given I am admin |
||||
And there is 1 project with the following: |
||||
| Name | Test | |
||||
And there is 1 cost type with the following: |
||||
| name | Translation | |
||||
And the project "Test" has 1 cost entry with the following: |
||||
| units | 4242 | |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should not see "No data to display" |
||||
And I should see "Translation" |
||||
And I should see "4242" |
||||
|
||||
Scenario: User who can see own costs, ONLY sees own costs |
||||
Given I am not logged in |
||||
And there is 1 project with the following: |
||||
| Name | Test | |
||||
And there is 1 User with: |
||||
| Login | bob | |
||||
| Firstname | Bob | |
||||
| Lastname | Bobbit | |
||||
And the user "bob" is a "Developer" in the project "Test" |
||||
And the role "Developer" may have the following rights: |
||||
| View own cost entries | |
||||
And there is 1 cost type with the following: |
||||
| name | Translation | |
||||
And the user "bob" has 1 cost entry |
||||
And there is 1 cost type with the following: |
||||
| name | Hidden Costs | |
||||
And the project "Test" has 2 cost entries with the following: |
||||
| units | 128128 | |
||||
And I am logged in as "bob" |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should not see "No data to display" |
||||
And I should see "Translation" |
||||
And I should see "Bob Bobbit" |
||||
And I should not see "Hidden Costs" |
||||
And I should not see "128128" |
||||
And I should not see "Redmine Admin" |
||||
|
||||
Scenario: User who can see own time entries, ONLY sees own time entries |
||||
Given I am not logged in |
||||
And there is 1 project with the following: |
||||
| Name | Test | |
||||
And there is 1 User with: |
||||
| Login | bob | |
||||
| Firstname | Bob | |
||||
| Lastname | Bobbit | |
||||
| default rate | 20.0 | |
||||
And the user "Bob" is a "Developer" in the project "Test" |
||||
And the role "Developer" may have the following rights: |
||||
| View own time entries | |
||||
And the user "Bob" has 1 time entry |
||||
And the project "Test" has 2 time entries with the following: |
||||
| hours | 11 | |
||||
And I am logged in as "bob" |
||||
And I am on the Cost Reports page for the project called Test |
||||
Then I should not see "No data to display" |
||||
And I should see "Bob Bobbit" |
||||
And I should not see "11" |
||||
And I should not see "220.0" |
||||
And I should not see "Redmine Admin"Scenario: Users that by set permission are only allowed to see their own rates, can not see the rates of others. |
||||
Given there is a standard cost control project named "Standard Project" |
||||
And the role "Supplier" may have the following rights: |
||||
| view_own_hourly_rate | |
||||
| view_issues | |
||||
| view_own_time_entries | |
||||
| view_own_cost_entries | |
||||
| view_cost_rates | |
||||
And there is 1 User with: |
||||
| Login | testuser | |
||||
| Firstname | Bob | |
||||
| Lastname | Bobbit | |
||||
| default rate | 10.00 | |
||||
And the user "testuser" is a "Supplier" in the project "Standard Project" |
||||
And the project "Standard Project" has 1 issue with the following: |
||||
| subject | test_issue | |
||||
And the issue "test_issue" has 1 time entry with the following: |
||||
| hours | 1.00 | |
||||
| user | testuser | |
||||
And there is 1 cost type with the following: |
||||
| name | Translation | |
||||
| cost rate | 7.00 | |
||||
And the issue "test_issue" has 1 cost entry with the following: |
||||
| units | 2.00 | |
||||
| user | testuser | |
||||
| cost type | Translation | |
||||
And the user "manager" has: |
||||
| hourly rate | 11.00 | |
||||
And the issue "test_issue" has 1 time entry with the following: |
||||
| hours | 3.00 | |
||||
| user | manager | |
||||
And the issue "test_issue" has 1 cost entry with the following: |
||||
| units | 5.00 | |
||||
| user | manager | |
||||
| cost type | Translation | |
||||
And I am logged in as "testuser" |
||||
And I am on the page for the issue "test_issue" |
||||
Then I should see "1.00 hour" |
||||
And I should see "2.0 Translations" |
||||
And I should see "24.00 EUR" |
||||
And I should not see "33.00 EUR" # labour costs only of Manager |
||||
And I should not see "35.00 EUR" # material costs only of Manager |
||||
And I should not see "43.00 EUR" # labour costs of me and Manager |
||||
And I should not see "49.00 EUR" # material costs of me and Manager |
||||
And I am on the issues page for the project called "Standard Project" |
||||
And I finish these definitions |
||||
And I select to see column "overall costs" |
||||
And I select to see column "labour costs" |
||||
And I select to see column "material costs" |
||||
Then I should see "24.00 EUR" |
||||
And I should see "10.00 EUR" |
||||
And I should see "14.00 EUR" |
||||
And I should not see "33.00 EUR" # labour costs only of Manager |
||||
And I should not see "35.00 EUR" # material costs only of Manager |
||||
And I should not see "43.00 EUR" # labour costs of me and Manager |
||||
And I should not see "49.00 EUR" # material costs of me and Manager |
||||
|
@ -0,0 +1,178 @@ |
||||
# Try to find a user with the login or roletype and log in using that user |
||||
Given /^I am(?: a)? "([^\"]*)"$/ do |login_or_role| |
||||
User.current = User.find_by_login(login_or_role) or Role.find_by_name(login_or_role).members.first.user |
||||
steps %Q{ |
||||
Given I am logged in as "#{u.login}" |
||||
} |
||||
end |
||||
|
||||
# If the named or current user is not already a member of the project, add him with his |
||||
# primary role |
||||
Given /^(?:the user "([^\"]+)" is|I am)(?: a)? member of "([^\"]+)"$/ do |username, projectname| |
||||
p = Project.find_by_name(projectname) |
||||
user = username ? User.find_by_login(username) : User.current |
||||
unless p.members.detect {|m| m.user == user} |
||||
steps %Q{ |
||||
The user #{user.login} is a "#{user.roles.first.name}" in project "#{projectname}" |
||||
} |
||||
end |
||||
end |
||||
|
||||
Given /^(?:the user "([^\"]+)" is|I am)(?: a)? member of "([^\"]+)":$/ do |username, projectname, table| |
||||
steps %Q{ |
||||
The user #{user.login} is a "#{user.roles.first.name}" in project "#{projectname}" |
||||
} |
||||
user = username ? User.find_by_login(username) : User.current |
||||
p = Project.find_by_name(projectname) |
||||
if tables[/[hH]ourly [rR]ate/] |
||||
hr = HourlyRate.new.tap do |r| |
||||
r.project = p |
||||
r.user = user |
||||
r.valid_from = 1.year.ago |
||||
r.rate = tables[/[hH]ourly [rR]ate/][1].to_i |
||||
r.save! |
||||
end |
||||
end |
||||
end |
||||
|
||||
# Add a "material" cost entry (which is just our standard cost entry) or a time entry to the last issue |
||||
Given /^(?:this issue|the issue "([^\"]+)") has (\d+) (?:([Tt]ime)|(?:(?:[Mm]aterial\s?)?[cC]ost))\s?[eE]?ntry with the following:$/ do |time, type, count| |
||||
owner = subject ? Issue.find_by_subject(subject) : Issue.last |
||||
klass = time ? TimeEntry : CostEntry |
||||
count.times do |
||||
ce = klass.spawn |
||||
table.rows_hash.each do |key, value| |
||||
if key =~ /[uU]ser/ |
||||
ce.user = value =~ /me|I|myself/ ? User.current : User.find_by_login(value) |
||||
elsif key =~ /[cC]ost\s?[tT]ype/ |
||||
ce.cost_type = CostType.find_by_name(value) |
||||
else |
||||
ce.send(:"#{key}=", value) |
||||
end |
||||
end |
||||
ce.project = owner.project |
||||
ce.save! |
||||
owner.cost_entries << ce |
||||
end |
||||
end |
||||
|
||||
# Possibly add the current user to the project and set his hourly rate |
||||
Given /^I am(?: a)? member of "([^\"]+)":$/ do |projectname, fields| |
||||
steps %Q{ |
||||
Given I am a member of "#{projectname}" |
||||
} |
||||
fields.rows_hash.each do |key, value| |
||||
if key.gsub(" ", "_").underscore == "hourly_rate" |
||||
HourlyRate.create! :rate => value, |
||||
:user => User.find(5), |
||||
:project => Project.first, |
||||
:valid_from => Date.today |
||||
end |
||||
end |
||||
end |
||||
|
||||
Given /^the (?:([Uu]ser)|([Pp]roject))(?: named| with(?: the)? name| called)? "([^\"]*)" has (only )?(\d+|[a-z]+) [cC]ost\s?[eE]ntr(?:y|ies)$/ do |user, project, name, do_delete_all, count| |
||||
steps %Q{ |
||||
Given the #{"user" if user}#{"project" if project} "#{name}" has #{"only " if do_delete_all}#{count} cost entries with the following: |
||||
| | |
||||
} |
||||
end |
||||
|
||||
Given /^the (?:([Uu]ser)|([Pp]roject))(?: named| with(?: the)? name| called)? "([^\"]*)" has (only )?(\d+|[a-z]+) [cC]ost\s?[eE]ntr(?:y|ies) with the following:$/ do |user, project, name, do_delete_all, count, table| |
||||
count = 1 if count == "one" |
||||
count = (count || 1).to_i |
||||
|
||||
u = user ? User.find_by_login(name) : u = User.find_by_login("admin") |
||||
p = project ? Project.find_by_name(name) : u.members.last.project |
||||
|
||||
if do_delete_all |
||||
CostEntry.find(:all, :conditions => ["project_id = #{p.id}"]).each do |c| |
||||
c.destroy |
||||
end |
||||
end |
||||
|
||||
count.times do |
||||
as_admin do |
||||
CostEntry.spawn.tap do |i| |
||||
i.project = p |
||||
i.issue = Issue.generate_for_project!(p) |
||||
i.user = u |
||||
unless table.raw.first.first.blank? # if we get an empty table, ignore that |
||||
table.rows_hash.each do |field,value| |
||||
field = field.gsub(" ", "_").underscore.to_sym |
||||
old_val = i.send(field) |
||||
i.send(:"#{field}=", value) |
||||
i.send(:"#{field}=", old_val) unless i.save |
||||
end |
||||
end |
||||
end.save! |
||||
end |
||||
end |
||||
end |
||||
|
||||
Given /^the (?:project|Project)(?: named| with(?: the)? name| called)? "([^\"]*)" has (only )?(\d+|[a-z]+) [cC]ost\s?[eE]ntr(?:y|ies)$/ do |name, do_delete_all, count| |
||||
steps %Q{ |
||||
Given the project "#{name}" has #{"only " if do_delete_all}#{count} cost entries with the following: |
||||
| | |
||||
} |
||||
end |
||||
|
||||
Given /^there (?:is|are)( only)? (\d+) [Uu]ser[s]? with:$/ do |do_delete_all, count, fields| |
||||
rate_regex = /[dD]efault\s?[rR]ate/ |
||||
new_table = fields.reject_key(rate_regex) |
||||
if do_delete_all |
||||
admin = User.find_by_login("admin") |
||||
anonymous = AnonymousUser.first |
||||
User.delete_all |
||||
admin.save! |
||||
anonymous.save! |
||||
end |
||||
users = create_some_objects(count, false, "User", new_table) |
||||
users.each do |u| |
||||
u.hashed_password = User.hash_password("admin") |
||||
unless new_table.raw.length == fields.raw.length |
||||
fields.rows_hash.each do |k,v| |
||||
if k =~ rate_regex |
||||
rate = DefaultHourlyRate.new.tap do |r| |
||||
r.valid_from = Date.today |
||||
r.rate = v |
||||
r.user = u |
||||
end |
||||
rate.save! |
||||
end |
||||
end |
||||
end |
||||
u.save! |
||||
end |
||||
end |
||||
|
||||
Given /^there is a standard cost control project named "([^\"]*)"$/ do |name| |
||||
steps %Q{ |
||||
Given there is 1 project with the following: |
||||
| Name | #{name} | |
||||
And the project "#{name}" has 1 subproject |
||||
And the role "Manager" may have the following rights: |
||||
| View own cost entries | |
||||
And the role "Controller" may have the following rights: |
||||
| View own cost entries | |
||||
And the role "Developer" may have the following rights: |
||||
| View own cost entries | |
||||
And the role "Reporter" may have the following rights: |
||||
| Create issues | |
||||
And the role "Supplier" may have the following rights: |
||||
| View own hourly rate | |
||||
| View own cost entries | |
||||
And there is 1 user with: |
||||
| Login | manager | |
||||
And the user "manager" is a "Manager" in the project called "#{name}" |
||||
And there is 1 user with: |
||||
| Login | controller | |
||||
And the user "controller" is a "Controller" in the project called "#{name}" |
||||
And there is 1 user with: |
||||
| Login | developer | |
||||
And the user "developer" is a "Developer" in the project called "#{name}" |
||||
And there is 1 user with: |
||||
| Login | reporter | |
||||
And the user "reporter" is a "Reporter" in the project called "#{name}" |
||||
} |
||||
end |
Loading…
Reference in new issue