Skip to content

Commit

Permalink
[api] Remove Event::Project
Browse files Browse the repository at this point in the history
`Event::Package` is a class with almost nothing that is used as
superclass for:

- `Event::CommentForProject`
- `Event::CreateProject`
- `Event::DeleteProject`
- `Event::UndeleteProject`
- `Event::UpdateProjectConfig`
- `Event::UpdateProject`

The `Event::Project` causes problem as we also have a `Project` model
in the root level. So once one of the two projects models is loaded,
Rails doens't look for the second one, which lead to uses of the wrong
model. To avoid that Rails uses the `Project` in the root level in
`Event::Project` subclasses we can call the Project specifying the
module. But for the other case there is nothing we can do. This is all
caused because we shouldn't have models with repeated names even if
they are in different levels. As the `Event::Project` is useless, we can
just remove it and add its data directly to the subclasses.
  • Loading branch information
Ana06 committed Dec 6, 2017
1 parent ee7a109 commit a571bb9
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 38 deletions.
4 changes: 3 additions & 1 deletion src/api/app/models/event/comment_for_project.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Event
class CommentForProject < Project
class CommentForProject < Base
include CommentEvent
self.description = 'Project was touched'
payload_keys :project
receiver_roles :maintainer, :watcher
after_create_commit :send_to_bus

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/event/create_project.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Event
class CreateProject < Project
class CreateProject < Base
self.description = 'Project is created'
payload_keys :sender
payload_keys :project, :sender
after_create_commit :send_to_bus

def self.message_bus_routing_key
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/event/delete_project.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Event
class DeleteProject < Project
class DeleteProject < Base
self.description = 'Project was deleted'
payload_keys :comment, :requestid, :sender
payload_keys :project, :comment, :requestid, :sender
after_create_commit :send_to_bus

def self.message_bus_routing_key
Expand Down
27 changes: 0 additions & 27 deletions src/api/app/models/event/project.rb

This file was deleted.

4 changes: 2 additions & 2 deletions src/api/app/models/event/undelete_project.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Event
class UndeleteProject < Project
class UndeleteProject < Base
self.description = 'Project was undeleted'
payload_keys :comment, :sender
payload_keys :project, :comment, :sender
after_create_commit :send_to_bus

def self.message_bus_routing_key
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/event/update_project.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Event
class UpdateProject < Project
class UpdateProject < Base
self.description = 'Project meta was updated'
payload_keys :sender
payload_keys :project, :sender
after_create_commit :send_to_bus

def self.message_bus_routing_key
Expand Down
4 changes: 2 additions & 2 deletions src/api/app/models/event/update_project_config.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Event
class UpdateProjectConfig < Project
class UpdateProjectConfig < Base
self.description = 'Project _config was updated'
payload_keys :sender, :files, :comment
payload_keys :project, :sender, :files, :comment
after_create_commit :send_to_bus

def self.message_bus_routing_key
Expand Down

0 comments on commit a571bb9

Please sign in to comment.