LearningOutcome model: Don't translate names of keys

Fixes CNVS-18252

Test Plan:

    - Assess a student using an outcome
    - try to change the calculation_method and verify you get back
      a message that contains 'calculation_method'
    - repeat for 'calculation_int'

Change-Id: I0f7a74911936a7cca8fa3e84cff96614c9c08a37
Reviewed-on: https://gerrit.instructure.com/47965
Tested-by: Jenkins
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Adam Stone <astone@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
This commit is contained in:
Benjamin Porter 2015-01-29 13:06:29 -07:00
parent 6ff48eb015
commit 120b052e7a
4 changed files with 21 additions and 15 deletions

View File

@ -87,14 +87,16 @@ class LearningOutcome < ActiveRecord::Base
# if we've been used to assess a student, refuse to accept any changes to our calculation options
if calculation_method_changed?
errors.add(:calculation_method, t(
"This outcome has been used to assess a student. Calculation method is fixed at %{old_value}",
"This outcome has been used to assess a student. '%{calc_int_method_name}' is fixed at %{old_value}",
:calc_int_method_name => "calculation_method",
:old_value => calculation_method_was
))
end
if calculation_int_changed?
errors.add(:calculation_int, t(
"This outcome has been used to assess a student. Calculation integer is fixed at %{old_value}",
"This outcome has been used to assess a student. '%{calc_int_key_name}' is fixed at %{old_value}",
:calc_int_key_name => "calculation_int",
:old_value => calculation_int_was
))
end
@ -104,13 +106,17 @@ class LearningOutcome < ActiveRecord::Base
unless valid_calculation_int?(calculation_int, calculation_method)
if valid_calculation_ints.to_a.empty?
errors.add(:calculation_int, t(
"'calculation_int' is not used with calculation_method '%{calculation_method}'",
"'%{calc_int_key_name}' is not used with '%{calc_method_key_name}' '%{calculation_method}'",
:calc_int_key_name => "calculation_int",
:calc_method_key_name => "calculation_method",
:calculation_method => calculation_method,
))
else
errors.add(:calculation_int, t(
"'%{calculation_int}' is not a valid calculation_int for calculation_method of '%{calculation_method}'. Valid range is '%{valid_calculation_ints}'",
"'%{calculation_int}' is not a valid '%{calc_int_key_name}' for '%{calc_method_key_name}' of '%{calculation_method}'. Valid range is '%{valid_calculation_ints}'",
:calculation_int => calculation_int,
:calc_int_key_name => "calculation_int",
:calc_method_key_name => "calculation_method",
:calculation_method => calculation_method,
:valid_calculation_ints => valid_calculation_ints
))

View File

@ -1026,9 +1026,9 @@ describe "Outcome Groups API", type: :request do
expect(json["errors"]["calculation_int"][0]).not_to be_nil
expect(json["errors"]["calculation_int"][0]["message"]).not_to be_nil
if %w[highest latest].include?(method)
expect(json["errors"]["calculation_int"][0]["message"]).to include("'calculation_int' is not used with calculation_method")
expect(json["errors"]["calculation_int"][0]["message"]).to include("'calculation_int' is not used with 'calculation_method'")
else
expect(json["errors"]["calculation_int"][0]["message"]).to include("not a valid calculation_int")
expect(json["errors"]["calculation_int"][0]["message"]).to include("not a valid 'calculation_int'")
end
end
end

View File

@ -554,8 +554,8 @@ describe "Outcomes API", type: :request do
"highest" => nil,
"latest" => nil,
}
norm_error_message = "not a valid calculation_int"
no_calc_int_error_message = "'calculation_int' is not used with calculation_method"
norm_error_message = "not a valid 'calculation_int'"
no_calc_int_error_message = "'calculation_int' is not used with 'calculation_method'"
bad_calc_int = 1500
method_to_int.each do |method, int|

View File

@ -503,7 +503,7 @@ describe LearningOutcome do
@outcome.save
expect(@outcome).to have(1).error_on(:calculation_int)
expect(@outcome).to have(1).errors
expect(outcome_errors(:calculation_int).first).to include("not a valid calculation_int")
expect(outcome_errors(:calculation_int).first).to include("not a valid 'calculation_int'")
@outcome.reload
expect(@outcome.calculation_method).to eq(method)
expect(@outcome.calculation_int).to eq(4)
@ -581,9 +581,9 @@ describe LearningOutcome do
expect(@outcome).to have(1).error
expect(@outcome).to have(1).error_on(:calculation_int)
if %w[highest latest].include?(method)
expect(outcome_errors(:calculation_int).first).to include("calculation_int' is not used with calculation_method")
expect(outcome_errors(:calculation_int).first).to include("'calculation_int' is not used with 'calculation_method'")
else
expect(outcome_errors(:calculation_int).first).to include("not a valid calculation_int")
expect(outcome_errors(:calculation_int).first).to include("not a valid 'calculation_int'")
end
@outcome = LearningOutcome.new(
@ -595,9 +595,9 @@ describe LearningOutcome do
expect(@outcome).to have(1).error
expect(@outcome).to have(1).error_on(:calculation_int)
if %w[highest latest].include?(method)
expect(outcome_errors(:calculation_int).first).to include("calculation_int' is not used with calculation_method")
expect(outcome_errors(:calculation_int).first).to include("'calculation_int' is not used with 'calculation_method'")
else
expect(outcome_errors(:calculation_int).first).to include("not a valid calculation_int")
expect(outcome_errors(:calculation_int).first).to include("not a valid 'calculation_int'")
end
end
end
@ -776,9 +776,9 @@ describe LearningOutcome do
expect(@outcome).to have(1).error_on(:calculation_int)
expect(@outcome).to have(1).errors
if %w[highest latest].include? method
expect(outcome_errors(:calculation_int).first).to include("calculation_int' is not used with calculation_method")
expect(outcome_errors(:calculation_int).first).to include("'calculation_int' is not used with 'calculation_method'")
else
expect(outcome_errors(:calculation_int).first).to include("not a valid calculation_int")
expect(outcome_errors(:calculation_int).first).to include("not a valid 'calculation_int'")
end
@outcome.reload
expect(@outcome.calculation_method).to eq(method)