Merge branch 'release/5.0' into dev

pull/6827/head
Christian Ratz 11 years ago
commit f4aa3567e3
  1. 6
      app/controllers/hourly_rates_controller.rb
  2. 5
      app/views/hourly_rates/_rate.html.erb
  3. 4
      app/views/hourly_rates/edit.html.erb
  4. 3
      config/locales/de.yml
  5. 3
      config/locales/en.yml
  6. 3
      doc/CHANGELOG.md
  7. 7
      features/cost_types/deletion.feature
  8. 23
      features/step_definitions/cost_type_steps.rb
  9. 2
      lib/open_project/costs/patches/user_patch.rb
  10. 50
      spec/controllers/hourly_rates_controller_spec.rb

@ -89,15 +89,13 @@ class HourlyRatesController < ApplicationController
if @user.save
flash[:notice] = l(:notice_successful_update)
if @project.nil?
redirect_back_or_default(:action => 'show', :id => @user)
redirect_back_or_default(:controller => 'users', :action => 'edit', :id => @user)
else
redirect_back_or_default(:action => 'show', :id => @user, :project_id => @project)
end
else
if @project.nil?
@rates = DefaultHourlyRate.all(
:conditions => {:user_id => @user},
:order => "#{DefaultHourlyRate.table_name}.valid_from desc")
@rates = @user.default_rates
@rates << @user.default_rates.build({:valid_from => Date.today}) if @rates.empty?
else
@rates = @user.rates.select{|r| r.project_id == @project.id}.sort { |a,b| b.valid_from <=> a.valid_from }

@ -26,13 +26,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
id_prefix = "user_#{new_or_existing}_rate_attributes_#{id_or_index}"
name_prefix = "user[#{new_or_existing}_rate_attributes][#{id_or_index}]"
classes ||= ""
@rate = rate
error_messages = error_messages_for 'rate'
-%>
<% unless error_messages.blank? %><tr><td colspan="3"><%= error_messages %></td></tr><% end %>
<%= fields_for prefix, rate do |rate_form| %>
<tr class="<%= classes %>" id="<%= id_prefix %>">
<td>

@ -36,6 +36,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
<%= labelled_tabular_form_for @user, :url => {:action => 'update', :project_id => @project}, :method => :put do |f| %>
<%= back_url_hidden_field_tag %>
<%= error_messages_for 'user' %>
<%- @rates.each do |rate| -%>
<%- @rate = rate -%>
<%= error_messages_for 'rate' %>
<%- end -%>
<table class="list" style="width:auto">
<thead><tr>
<th><%= Rate.human_attribute_name(:valid_from) %></th>

@ -203,3 +203,6 @@ de:
x_entries:
one: "1 Eintrag"
other: "%{count} Einträge"
js:
text_are_you_sure: "Sind Sie sicher?"

@ -203,3 +203,6 @@ en:
x_entries:
one: "1 Entry"
other: "%{count} Entries"
js:
text_are_you_sure: "Are you sure?"

@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Changelog
* `#8230` Missing Translation when deleting Cost Type
* `#8233` Changing the default rate with invalid values
## 5.0.4
* `#4024` Fix: Subpages have no unique page titles

@ -36,3 +36,10 @@ Feature: Cost type deletion
Then the cost type "cost_type1" should be listed as deleted on the index page
@javascript
Scenario: Click on the "delete" link for a cost type
When I go to the index page of cost types
Then I expect to click "OK" on a confirmation box saying "Are you sure?"
And I click the delete link for the cost type "cost_type1"
And the confirmation box should have been displayed

@ -47,6 +47,29 @@ When(/^I delete the cost type "(.*?)"$/) do |name|
end
end
When(/^I click the delete link for the cost type "(.*?)"$/) do |name|
ct = CostType.find_by_name name
within ("#delete_cost_type_#{ct.id}") do
find('a.submit_cost_type').click
end
end
When /^I expect to click "([^"]*)" on a confirmation box saying "([^"]*)"$/ do |option, message|
retval = (option == 'OK') ? 'true' : 'false'
page.evaluate_script("window.confirm = function (msg) {
document.cookie = msg
return #{retval}
}")
@expected_message = message.gsub("\\n", "\n")
end
When /^the confirmation box should have been displayed$/ do
assert page.evaluate_script('document.cookie').include?(@expected_message),
"Expected confirm box with message: '#{@expected_message}'" +
" got: '#{page.evaluate_script('document.cookie')}'"
end
Then(/^the cost type "(.*?)" should not be listed on the index page$/) do |name|
if has_css?(".cost_types")

@ -90,7 +90,7 @@ module OpenProject::Costs::Patches::UserPatch
def save_rates
(default_rates + rates).each do |rate|
rate.save(:validate => false)
return false if !rate.save
end
end

@ -0,0 +1,50 @@
#-- copyright
# OpenProject Costs Plugin
#
# Copyright (C) 2009 - 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.
#++
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper.rb")
describe HourlyRatesController do
let(:user) { FactoryGirl.create(:user) }
let(:admin) { FactoryGirl.create(:admin) }
let(:default_rate) { FactoryGirl.create(:default_hourly_rate, :user => user) }
describe "PUT update" do
describe "WHEN trying to update with an invalid rate value" do
let(:params) {
{
:id => user.id,
:user => {"existing_rate_attributes" => {"#{default_rate.id}" => {"valid_from" => "#{default_rate.valid_from}", "rate" => "2d5" }}}
}
}
before do
as_logged_in_user admin do
post :update, params
end
end
it "should render the edit template" do
expect(response).to render_template("edit")
end
it "should display an error message" do
expect(assigns(:user).default_rates.first.errors.messages[:rate].first).to eq("is not a number")
end
end
end
end
Loading…
Cancel
Save