redu / apps

Redu's application repository
2 stars 2 forks source link

Avaliar casos em que validações falham no Untied::Zombificator #156

Open guiocavalcanti opened 11 years ago

guiocavalcanti commented 11 years ago

Ao criar um curso pelo passo a passo do core, o seguinte evento chega pelo Untied:

Untied::Processor: processing event after_create from core with payload {"course"=>{"destroy_soon"=>false, "path"=>"novo", "name"=>"novo", "created_at"=>"2012-12-03T18:20:01-02:00", "workload"=>nil, "environment_id"=>nil, "blocked"=>false, "published"=>true, "user_id"=>1, "subscription_type"=>1, "description"=>nil, "id"=>5, "updated_at"=>"2012-12-03T18:20:01-02:00"}}

O Course não possui Environment, pois o mesmo é criado via accepts_nested_attributes_for :course no core. Quando o callback after_create de Course é chamando, o environment que está na memória não possui o ID [1].

Como há uma validação de environment_id no portal de aplicativos, o mesmo não é salvo quando o esperado é que fosse salvo.

A solução ideal seria garantir que o core seja capaz de gerar eventos com entidades válidas/consistentes.

[1] http://stackoverflow.com/questions/2226747/rails-accepts-nested-attributes-for-child-doesnt-have-parent-set-when-validatin

O log completo de apps:

Untied::Processor: processing event after_create from core with payload {"user_environment_association"=>{"created_at"=>"2012-12-03T18:20:01-02:00", "environment_id"=>5, "user_id"=>1, "role"=>3, "id"=>5, "updated_at"=>"2012-12-03T18:20:01-02:00"}}
  User Load (0.8ms)  SELECT `users`.* FROM `users` WHERE `users`.`core_id` = 1 LIMIT 1
  Environment Load (0.4ms)  SELECT `environments`.* FROM `environments` WHERE `environments`.`core_id` = 5 LIMIT 1
   (0.2ms)  BEGIN
  SQL (0.4ms)  INSERT INTO `environments` (`core_id`, `created_at`, `name`, `thumbnail_content_type`, `thumbnail_file_name`, `thumbnail_file_size`, `thumbnail_updated_at`, `updated_at`, `user_id`, `zombie`) VALUES (5, '2012-12-03 20:20:02', NULL, NULL, NULL, NULL, NULL, '2012-12-03 20:20:02', NULL, 1)
[paperclip] Saving attachments.
   (0.6ms)  COMMIT
  UserEnvironmentAssociation Load (0.4ms)  SELECT `user_environment_associations`.* FROM `user_environment_associations` WHERE `user_environment_associations`.`core_id` = 5 LIMIT 1
   (0.2ms)  BEGIN
  SQL (0.4ms)  INSERT INTO `user_environment_associations` (`core_id`, `created_at`, `environment_id`, `updated_at`, `user_id`, `zombie`) VALUES (5, '2012-12-03 20:20:02', 3, '2012-12-03 20:20:02', 1, 0)
   (0.4ms)  COMMIT
Untied::Processor: processing event after_create from core with payload {"course"=>{"destroy_soon"=>false, "path"=>"novo", "name"=>"novo", "created_at"=>"2012-12-03T18:20:01-02:00", "workload"=>nil, "environment_id"=>nil, "blocked"=>false, "published"=>true, "user_id"=>1, "subscription_type"=>1, "description"=>nil, "id"=>5, "updated_at"=>"2012-12-03T18:20:01-02:00"}}
  Environment Load (0.4ms)  SELECT `environments`.* FROM `environments` WHERE `environments`.`core_id` IS NULL LIMIT 1
  User Load (0.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`core_id` = 1 LIMIT 1
  Course Load (0.4ms)  SELECT `courses`.* FROM `courses` WHERE `courses`.`core_id` = 5 LIMIT 1
   (0.2ms)  BEGIN
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 AND (users.zombie is FALSE) LIMIT 1
  Environment Load (0.4ms)  SELECT `environments`.* FROM `environments` WHERE `environments`.`id` = 2 AND (environments.zombie is FALSE) LIMIT 1
  Course Exists (0.6ms)  SELECT 1 FROM `courses` WHERE `courses`.`core_id` = BINARY 5 LIMIT 1
   (0.2ms)  ROLLBACK
Untied::Processor: processing event after_create from core with payload {"user_course_association"=>{"course_id"=>5, "token"=>nil, "created_at"=>"2012-12-03T18:20:01-02:00", "email"=>nil, "user_id"=>1, "state"=>"waiting", "role"=>3, "id"=>8, "updated_at"=>"2012-12-03T18:20:01-02:00"}}
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`core_id` = 1 LIMIT 1
  Course Load (0.3ms)  SELECT `courses`.* FROM `courses` WHERE `courses`.`core_id` = 5 LIMIT 1
   (0.1ms)  BEGIN
  SQL (0.3ms)  INSERT INTO `courses` (`core_id`, `created_at`, `environment_id`, `name`, `updated_at`, `user_id`, `zombie`) VALUES (5, '2012-12-03 20:20:03', NULL, NULL, '2012-12-03 20:20:03', NULL, 1)
   (0.6ms)  COMMIT
  UserCourseAssociation Load (0.4ms)  SELECT `user_course_associations`.* FROM `user_course_associations` WHERE `user_course_associations`.`core_id` = 8 LIMIT 1
   (0.1ms)  BEGIN
  SQL (0.6ms)  INSERT INTO `user_course_associations` (`core_id`, `course_id`, `created_at`, `role_cd`, `updated_at`, `user_id`, `zombie`) VALUES (8, 2, '2012-12-03 20:20:03', 3, '2012-12-03 20:20:03', 1, 0)
   (2.6ms)  COMMIT
Untied::Processor: processing event after_update from core with payload {"user_course_association"=>{"course_id"=>5, "token"=>nil, "created_at"=>"2012-12-03T18:20:01-02:00", "email"=>nil, "user_id"=>1, "state"=>"approved", "role"=>3, "id"=>8, "updated_at"=>"2012-12-03T18:20:01-02:00"}}
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`core_id` = 1 LIMIT 1
  Course Load (0.3ms)  SELECT `courses`.* FROM `courses` WHERE `courses`.`core_id` = 5 LIMIT 1
  UserCourseAssociation Load (0.3ms)  SELECT `user_course_associations`.* FROM `user_course_associations` WHERE `user_course_associations`.`core_id` = 8 LIMIT 1
   (0.1ms)  BEGIN
   (0.1ms)  COMMIT
Untied::Processor: processing event after_update from core with payload {"course"=>{"destroy_soon"=>false, "path"=>"novo", "name"=>"novo", "created_at"=>"2012-12-03T18:20:01-02:00", "workload"=>nil, "environment_id"=>5, "blocked"=>false, "published"=>true, "user_id"=>1, "subscription_type"=>1, "description"=>nil, "id"=>5, "updated_at"=>"2012-12-03T18:20:01-02:00"}}
  Environment Load (0.4ms)  SELECT `environments`.* FROM `environments` WHERE `environments`.`core_id` = 5 LIMIT 1
  User Load (0.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`core_id` = 1 LIMIT 1
  Course Load (0.3ms)  SELECT `courses`.* FROM `courses` WHERE `courses`.`core_id` = 5 LIMIT 1
   (0.1ms)  BEGIN
  User Load (2.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 AND (users.zombie is FALSE) LIMIT 1
  Environment Load (0.3ms)  SELECT `environments`.* FROM `environments` WHERE `environments`.`id` = 3 AND (environments.zombie is FALSE) LIMIT 1
  Course Exists (0.6ms)  SELECT 1 FROM `courses` WHERE (`courses`.`core_id` = BINARY 5 AND `courses`.`id` != 2) LIMIT 1
   (0.1ms)  ROLLBACK
Untied::Processor: processing event after_create from core with payload {"environment"=>{"avatar_updated_at"=>nil, "destroy_soon"=>false, "path"=>"novo", "avatar_file_size"=>nil, "name"=>"novo", "created_at"=>"2012-12-03T18:20:01-02:00", "avatar_content_type"=>nil, "blocked"=>false, "published"=>true, "user_id"=>1, "initials"=>"sad", "avatar_file_name"=>nil, "description"=>nil, "id"=>5, "updated_at"=>"2012-12-03T18:20:01-02:00"}}
  User Load (8.1ms)  SELECT `users`.* FROM `users` WHERE `users`.`core_id` = 1 LIMIT 1
  Environment Load (0.4ms)  SELECT `environments`.* FROM `environments` WHERE `environments`.`core_id` = 5 LIMIT 1
   (0.1ms)  BEGIN
  Environment Exists (0.4ms)  SELECT 1 FROM `environments` WHERE (`environments`.`core_id` = BINARY 5 AND `environments`.`id` != 3) LIMIT 1
  User Load (0.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 AND (users.zombie is FALSE) LIMIT 1
   (0.4ms)  UPDATE `environments` SET `name` = 'novo', `user_id` = 1, `zombie` = 0, `updated_at` = '2012-12-03 20:20:03' WHERE `environments`.`id` = 3
[paperclip] Saving attachments.
   (0.4ms)  COMMIT

O log do core:

Started POST "/?step=4" for 127.0.0.1 at Mon Dec 03 18:43:54 -0300 2012
  Processing by EnvironmentsController#create as JS
  Parameters: {"plan"=>"free", "commit"=>"Finalizar", "environment"=>{"path"=>"dsadsa", "courses_attributes"=>{"0"=>{"path"=>"sadads", "name"=>"sadads"}}, "initials"=>"dsa", "name"=>"dsadsa"}, "step"=>"4", "utf8"=>"✓", "authenticity_token"=>"jTsmGN1IG9sCNePLlsQ4KR3VXybdgX18iWy89zfhpOg=", "locale"=>"pt-BR"}
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  Role Load (0.5ms)  SELECT id, name FROM `roles` WHERE (name like 'admin') ORDER BY id LIMIT 1
  SQL (0.2ms)  BEGIN
  SQL (0.5ms)  SELECT 1 FROM `courses` WHERE `courses`.`environment_id` IS NULL AND (`courses`.`name` = BINARY 'sadads') LIMIT 1
  SQL (0.7ms)  SELECT 1 FROM `courses` WHERE `courses`.`environment_id` IS NULL AND (`courses`.`path` = BINARY 'sadads') LIMIT 1
  SQL (1.0ms)  SELECT 1 FROM `environments` WHERE (`environments`.`name` = BINARY 'dsadsa') LIMIT 1
  SQL (0.4ms)  SELECT 1 FROM `environments` WHERE (`environments`.`path` = BINARY 'dsadsa') LIMIT 1
  AREL (0.5ms)  INSERT INTO `environments` (`avatar_content_type`, `updated_at`, `name`, `published`, `avatar_file_name`, `user_id`, `avatar_file_size`, `description`, `avatar_updated_at`, `created_at`, `initials`, `destroy_soon`, `blocked`, `path`) VALUES (NULL, '2012-12-03 21:43:54', 'dsadsa', 1, NULL, 1, NULL, NULL, NULL, '2012-12-03 21:43:54', 'dsa', 0, 0, 'dsadsa')
  Role Load (1.3ms)  SELECT id, name FROM `roles` WHERE (name like 'environment_admin') ORDER BY id LIMIT 1
  SQL (0.7ms)  SELECT 1 FROM `user_environment_associations` WHERE `user_environment_associations`.`environment_id` = 9 AND (`user_environment_associations`.`user_id` = 1) LIMIT 1
  AREL (0.5ms)  INSERT INTO `user_environment_associations` (`role`, `environment_id`, `updated_at`, `created_at`, `user_id`) VALUES (3, 9, '2012-12-03 21:43:54', '2012-12-03 21:43:54', 1)
Untied::Publisher: Producer intialized with options {:deliver_messages=>true, :service_name=>"core", :channel=>nil}
Using defined AMQP.channel
Publishing event #<Untied::Event:0x10eacea90 @name=:after_create, @config={:payload_representer=>nil}, @representable_attrs=[#<Representable::Definition:0x10c5ffe08 @name="name", @options={}>, #<Representable::Definition:0x10c5ffc50 @name="payload", @options={}>, #<Representable::Definition:0x10c5ffbd8 @name="origin", @options={}>], @origin="core", @payload=#<UserEnvironmentAssociation id: 9, user_id: 1, environment_id: 9, created_at: "2012-12-03 21:43:54", updated_at: "2012-12-03 21:43:54", role: 3>> with routing key untied.core
  Role Load (0.8ms)  SELECT id, name FROM `roles` WHERE (name like 'environment_admin') ORDER BY id LIMIT 1
  SQL (0.5ms)  SELECT 1 FROM `course_enrollments` WHERE `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`course_id` IS NULL AND (`course_enrollments`.`user_id` = 1) LIMIT 1
  SQL (0.4ms)  SELECT 1 FROM `courses` WHERE `courses`.`environment_id` IS NULL AND (`courses`.`name` = BINARY 'sadads') LIMIT 1
  SQL (0.4ms)  SELECT 1 FROM `courses` WHERE `courses`.`environment_id` IS NULL AND (`courses`.`path` = BINARY 'sadads') LIMIT 1
  AREL (0.5ms)  INSERT INTO `courses` (`destroy_soon`, `workload`, `created_at`, `published`, `updated_at`, `blocked`, `subscription_type`, `name`, `description`, `path`, `user_id`, `environment_id`) VALUES (0, NULL, '2012-12-03 21:43:54', 1, '2012-12-03 21:43:54', 0, 1, 'sadads', NULL, 'sadads', 1, NULL)
  AREL (1.2ms)  INSERT INTO `statuses` (`updated_at`, `user_id`, `logeable_type`, `compound_log_id`, `created_at`, `statusable_id`, `logeable_id`, `type`, `compound_visible_at`, `statusable_type`, `in_response_to_id`, `compound`, `in_response_to_type`, `text`, `action`) VALUES ('2012-12-03 21:43:54', 1, 'Course', NULL, '2012-12-03 21:43:54', 1, 9, 'Log', NULL, 'User', NULL, 0, NULL, '', 'create')
  SQL (0.4ms)  SELECT 1 FROM `status_user_associations` WHERE `status_user_associations`.`user_id` = 1 AND (`status_user_associations`.`status_id` = 51) LIMIT 1
  AREL (31.7ms)  INSERT INTO `status_user_associations` (`user_id`, `updated_at`, `status_id`, `created_at`) VALUES (1, '2012-12-03 21:43:54', 51, '2012-12-03 21:43:54')
  User Load (0.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  Status Load (0.4ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 51 LIMIT 1
  User Load (0.6ms)  SELECT `users`.*, users.id FROM `users` INNER JOIN `friendships` ON `users`.id = `friendships`.friend_id WHERE ((`friendships`.user_id = 1) AND ((friendships.status = 'accepted')))
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT `users`.*, users.id FROM `users` INNER JOIN `friendships` ON `users`.id = `friendships`.friend_id WHERE ((`friendships`.user_id = 1) AND ((friendships.status = 'accepted')))
  Course Load (0.3ms)  SELECT `courses`.* FROM `courses` WHERE `courses`.`id` = 9 LIMIT 1
Untied::Publisher: Producer intialized with options {:deliver_messages=>true, :service_name=>"core", :channel=>nil}
Using defined AMQP.channel
Publishing event #<Untied::Event:0x10e7a85f0 @name=:after_create, @config={:payload_representer=>nil}, @representable_attrs=[#<Representable::Definition:0x10c5ffe08 @name="name", @options={}>, #<Representable::Definition:0x10c5ffc50 @name="payload", @options={}>, #<Representable::Definition:0x10c5ffbd8 @name="origin", @options={}>], @origin="core", @payload=#<Course id: 9, name: "sadads", description: nil, path: "sadads", created_at: "2012-12-03 21:43:54", updated_at: "2012-12-03 21:43:54", environment_id: nil, workload: nil, subscription_type: 1, user_id: 1, published: true, destroy_soon: false, blocked: false>> with routing key untied.core
  AREL (0.6ms)  INSERT INTO `course_enrollments` (`token`, `updated_at`, `user_id`, `type`, `email`, `state`, `created_at`, `role`, `course_id`) VALUES (NULL, '2012-12-03 21:43:54', 1, 'UserCourseAssociation', NULL, 'waiting', '2012-12-03 21:43:54', 3, 9)
Untied::Publisher: Producer intialized with options {:deliver_messages=>true, :service_name=>"core", :channel=>nil}
Using defined AMQP.channel
Publishing event #<Untied::Event:0x10e6dd328 @name=:after_create, @config={:payload_representer=>nil}, @representable_attrs=[#<Representable::Definition:0x10c5ffe08 @name="name", @options={}>, #<Representable::Definition:0x10c5ffc50 @name="payload", @options={}>, #<Representable::Definition:0x10c5ffbd8 @name="origin", @options={}>], @origin="core", @payload=#<UserCourseAssociation id: 12, user_id: 1, course_id: 9, state: "approved", token: nil, email: nil, role: 3, type: "UserCourseAssociation", created_at: "2012-12-03 21:43:54", updated_at: "2012-12-03 21:43:54">> with routing key untied.core
  SQL (56.5ms)  SELECT 1 FROM `course_enrollments` WHERE `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`course_id` = 9 AND (`course_enrollments`.`user_id` = 1) AND (`course_enrollments`.id <> 12) LIMIT 1
  AREL (18.5ms)  UPDATE `course_enrollments` SET `updated_at` = '2012-12-03 21:43:55', `state` = 'approved' WHERE `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`id` = 12
  SQL (32.5ms)  SELECT COUNT(*) FROM `statuses` WHERE `statuses`.`type` = 'Log' AND (`statuses`.logeable_id = 12 AND `statuses`.logeable_type = 'CourseEnrollment')
  AREL (0.4ms)  INSERT INTO `statuses` (`updated_at`, `user_id`, `logeable_type`, `compound_log_id`, `created_at`, `statusable_id`, `logeable_id`, `type`, `compound_visible_at`, `statusable_type`, `in_response_to_id`, `compound`, `in_response_to_type`, `text`, `action`) VALUES ('2012-12-03 21:43:55', 1, 'CourseEnrollment', NULL, '2012-12-03 21:43:55', 9, 12, 'Log', NULL, 'Course', NULL, 0, NULL, 'ingressou no curso', 'create')
  Course Load (0.3ms)  SELECT `courses`.* FROM `courses` WHERE `courses`.`id` = 9 LIMIT 1
  Status Load (0.2ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`id` = 52 LIMIT 1
  User Load (42.5ms)  SELECT `users`.*, users.id FROM `users` INNER JOIN `course_enrollments` ON `users`.id = `course_enrollments`.user_id WHERE ((`course_enrollments`.course_id = 9) AND ((course_enrollments.state = 'approved') AND (`course_enrollments`.`type` = 'UserCourseAssociation')))
  SQL (0.6ms)  SHOW VARIABLES like 'max_allowed_packet';
  Class Create Many Without Validations Or Callbacks (0.3ms)  INSERT INTO `status_user_associations` (`id`,`user_id`,`status_id`,`created_at`,`updated_at`) VALUES (NULL,1,52,'2012-12-03 21:43:55','2012-12-03 21:43:55') ON DUPLICATE KEY UPDATE `status_user_associations`.`updated_at`=VALUES(`updated_at`)
  CourseEnrollment Load (0.5ms)  SELECT `course_enrollments`.* FROM `course_enrollments` WHERE `course_enrollments`.`id` = 12 LIMIT 1
  CompoundLog Load (1.0ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`type` = 'CompoundLog' AND `statuses`.`logeable_type` = 'UserCourseAssociation' AND `statuses`.`statusable_id` = 9 ORDER BY created_at DESC LIMIT 1
  AREL (0.4ms)  INSERT INTO `statuses` (`logeable_type`, `action`, `in_response_to_id`, `logeable_id`, `compound_log_id`, `in_response_to_type`, `compound_visible_at`, `created_at`, `updated_at`, `statusable_type`, `user_id`, `type`, `text`, `compound`, `statusable_id`) VALUES ('UserCourseAssociation', NULL, NULL, NULL, NULL, NULL, NULL, '2012-12-03 21:43:55', '2012-12-03 21:43:55', 'Course', 1, 'CompoundLog', NULL, 1, 9)
  Log Load (0.5ms)  SELECT `statuses`.* FROM `statuses` WHERE `statuses`.`type` = 'Log' AND `statuses`.`id` = 52 LIMIT 1
  StatusResource Load (0.6ms)  SELECT `status_resources`.* FROM `status_resources` WHERE (`status_resources`.status_id = 52)
  AREL (0.5ms)  UPDATE `statuses` SET `updated_at` = '2012-12-03 21:43:55', `compound_log_id` = 53 WHERE `statuses`.`type` = 'Log' AND `statuses`.`id` = 52
  SQL (7.2ms)  SELECT COUNT(*) FROM `statuses` WHERE `statuses`.`type` = 'Log' AND (`statuses`.compound_log_id = 53)
  AREL (0.4ms)  UPDATE `courses` SET `updated_at` = '2012-12-03 21:43:55' WHERE `courses`.`id` = 9
  UserCourseAssociation Load (0.6ms)  SELECT `course_enrollments`.* FROM `course_enrollments` WHERE `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`state` = 'invited' AND (`course_enrollments`.course_id = 9)
Untied::Publisher: Producer intialized with options {:deliver_messages=>true, :service_name=>"core", :channel=>nil}
Using defined AMQP.channel
Publishing event #<Untied::Event:0x10e5b9230 @name=:after_update, @config={:payload_representer=>nil}, @representable_attrs=[#<Representable::Definition:0x10c5ffe08 @name="name", @options={}>, #<Representable::Definition:0x10c5ffc50 @name="payload", @options={}>, #<Representable::Definition:0x10c5ffbd8 @name="origin", @options={}>], @origin="core", @payload=#<UserCourseAssociation id: 12, user_id: 1, course_id: 9, state: "approved", token: nil, email: nil, role: 3, type: "UserCourseAssociation", created_at: "2012-12-03 21:43:54", updated_at: "2012-12-03 21:43:55">> with routing key untied.core
  AREL (1.8ms)  UPDATE `courses` SET `updated_at` = '2012-12-03 21:43:55', `environment_id` = 9 WHERE `courses`.`id` = 9
  UserCourseAssociation Load (0.5ms)  SELECT `course_enrollments`.* FROM `course_enrollments` WHERE `course_enrollments`.`type` = 'UserCourseAssociation' AND `course_enrollments`.`state` = 'invited' AND (`course_enrollments`.course_id = 9)
Untied::Publisher: Producer intialized with options {:deliver_messages=>true, :service_name=>"core", :channel=>nil}
Using defined AMQP.channel
Publishing event #<Untied::Event:0x10e52e068 @name=:after_update, @config={:payload_representer=>nil}, @representable_attrs=[#<Representable::Definition:0x10c5ffe08 @name="name", @options={}>, #<Representable::Definition:0x10c5ffc50 @name="payload", @options={}>, #<Representable::Definition:0x10c5ffbd8 @name="origin", @options={}>], @origin="core", @payload=#<Course id: 9, name: "sadads", description: nil, path: "sadads", created_at: "2012-12-03 21:43:54", updated_at: "2012-12-03 21:43:55", environment_id: 9, workload: nil, subscription_type: 1, user_id: 1, published: true, destroy_soon: false, blocked: false>> with routing key untied.core
Untied::Publisher: Producer intialized with options {:deliver_messages=>true, :service_name=>"core", :channel=>nil}
Using defined AMQP.channel
[paperclip] Saving attachments.
Publishing event #<Untied::Event:0x10eb602d8 @name=:after_create, @config={:payload_representer=>nil}, @representable_attrs=[#<Representable::Definition:0x10c5ffe08 @name="name", @options={}>, #<Representable::Definition:0x10c5ffc50 @name="payload", @options={}>, #<Representable::Definition:0x10c5ffbd8 @name="origin", @options={}>], @origin="core", @payload=#<Environment id: 9, name: "dsadsa", description: nil, path: "dsadsa", avatar_file_name: nil, avatar_content_type: nil, avatar_file_size: nil, avatar_updated_at: nil, user_id: 1, published: true, created_at: "2012-12-03 21:43:54", updated_at: "2012-12-03 21:43:54", initials: "dsa", destroy_soon: false, blocked: false>> with routing key untied.core
  SQL (1.2ms)  COMMIT
  Plan Load (0.5ms)  SELECT `plans`.* FROM `plans` WHERE `plans`.`current` = 1 AND (`plans`.billable_id = 9 AND `plans`.billable_type = 'Course') LIMIT 1
  SQL (0.1ms)  BEGIN
  AREL (0.6ms)  INSERT INTO `plans` (`state`, `user_id`, `file_storage_limit`, `current`, `name`, `updated_at`, `video_storage_limit`, `membership_fee`, `billable_audit`, `type`, `yearly_price`, `billing_date`, `members_limit`, `billable_type`, `price`, `created_at`, `billable_id`) VALUES ('active', 1, 5242880, 1, 'Professor Grátis', '2012-12-03 21:43:55', 10485760, NULL, NULL, 'PackagePlan', 0.0, NULL, 60, 'Course', 0.0, '2012-12-03 21:43:55', 9)
  SQL (0.8ms)  COMMIT
  Plan Load (0.5ms)  SELECT `plans`.* FROM `plans` WHERE `plans`.`current` = 1 AND (`plans`.billable_id = 9 AND `plans`.billable_type = 'Course') LIMIT 1
  Quota Load (0.3ms)  SELECT `quotas`.* FROM `quotas` WHERE (`quotas`.billable_id = 9 AND `quotas`.billable_type = 'Course') LIMIT 1
  SQL (0.1ms)  BEGIN
  AREL (0.3ms)  INSERT INTO `quotas` (`billable_type`, `created_at`, `updated_at`, `billable_id`, `multimedia`, `files`) VALUES ('Course', '2012-12-03 21:43:55', '2012-12-03 21:43:55', 9, 0, 0)
  SQL (1.0ms)  COMMIT
Rendered environments/redirect.js.erb (0.8ms)
Completed 200 OK in 971ms (Views: 63.5ms | ActiveRecord: 217.2ms)