mxabierto / consulta

Fork :fork_and_knife: mexicano de Cónsul
GNU Affero General Public License v3.0
0 stars 0 forks source link

Specs truenan por responsible_name en proposals #33

Closed defvol closed 9 years ago

defvol commented 9 years ago
  48) Proposal#editable? should be true if proposal has less than limit votes
      Failure/Error: let(:proposal) { create(:proposal) }
      ActiveRecord::RecordInvalid:
        Validation failed: Responsible name can't be blank, Responsible name is 
too short (minimum is 6 characters)
      # ./spec/models/proposal_spec.rb:132:in `block (3 levels) in <top (require
d)>'
      # ./spec/models/proposal_spec.rb:141:in `block (3 levels) in <top (require
d)>'

Parece que responsible name se queda en nil en los factories.

En el modelo se ve que Proposal tiene un protected method set_responsible_name que se invoca en el hook before_validation.

defvol commented 9 years ago

También me afecta el sandbox de rails console

quise hacer una simple operación de Update y falló por lo mismo

=> nil
irb(main):010:0> p.closing_date = Time.now
=> 2015-11-17 20:41:10 -0600
irb(main):011:0> p.save
   (0.4ms)  SAVEPOINT active_record_1
  ActsAsTaggableOn::Tag Load (1.8ms)  SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL)  [["taggable_id", 32], ["taggable_type", "Proposal"]]
  User Load (1.3ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 59]]
   (0.4ms)  ROLLBACK TO SAVEPOINT active_record_1
=> false
irb(main):012:0> p.errors
=> #<ActiveModel::Errors:0x007f93641884f0 @base=#<Proposal id: 32, title: "La ley Pawnee Indiana", description: "<ol>\r\n\t<li>And as of April 18th, 2013, volunteer s...", question: "¿Te late esta ley?", external_url: "", author_id: 59, hidden_at: nil, flags_count: 0, ignored_flag_at: nil, cached_votes_up: 0, comments_count: 1, confirmed_hide_at: nil, hot_score: 3110147962, confidence_score: 0, created_at: "2015-11-17 17:10:39", updated_at: "2015-11-17 17:17:12", responsible_name: nil, summary: "La ley de Pawnee Indiana tiene 7 mandamientos", video_url: "", physical_votes: 0, closing_date: "2015-11-18 02:41:10">, @messages={:responsible_name=>["no puede estar en blanco", "es demasiado corto (6 caracteres mínimo)"]}>
defvol commented 9 years ago

WTF

Trae responsible_name = "Ron Swanson"

irb(main):005:0> p
=> #<Proposal id: 32, title: "La ley Pawnee Indiana", description: "<ol>\r\n\t<l
i>And as of April 18th, 2013, volunteer s...", question: "¿Te late esta ley?", e
xternal_url: "", author_id: 59, hidden_at: nil, flags_count: 0, ignored_flag_at:
 nil, cached_votes_up: 0, comments_count: 1, confirmed_hide_at: nil, hot_score: 
3110147962, confidence_score: 0, created_at: "2015-11-17 17:10:39", updated_at: 
"2015-11-17 17:17:12", responsible_name: "Ron Swanson", summary: "La ley de Pawn
ee Indiana tiene 7 mandamientos", video_url: "", physical_votes: 0, closing_date
: nil>

Lo actualizo y me sale de error que responsible_name esta en nil

irb(main):007:0> p.closing_date = Time.now
=> 2015-11-17 20:46:38 -0600
irb(main):008:0> p.save
...=> false

irb(main):009:0> p.errors
=> #<ActiveModel::Errors:0x007f935c2d2a20 @base=#<Proposal id: 32, title: "La l$y Pawnee Indiana", description: "<ol>\r\n\t<li>And as of April 18th, 2013, volu$teer s...", question: "¿Te late esta ley?", external_url: "", author_id: 59, hi$den_at: nil, flags_count: 0, ignored_flag_at: nil, cached_votes_up: 0, comments$count: 1, confirmed_hide_at: nil, hot_score: 3110147962, confidence_score: 0, c$eated_at: "2015-11-17 17:10:39", updated_at: "2015-11-17 17:17:12", responsible_
name: nil, summary: "La ley de Pawnee Indiana tiene 7 mandamientos", video_url: 
"", physical_votes: 0, closing_date: "2015-11-18 02:46:38">, @messages={:respons
ible_name=>["no puede estar en blanco", "es demasiado corto (6 caracteres mínimo
)"]}>
irb(main):010:0> p.responsible_name
=> nil
defvol commented 9 years ago

Lo resuelve #41

Y ahora sólo fallan 6 en spec/models/proposal_spec.rb