Class: Decidim::DummyResources::DummyResource
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Decidim::DummyResources::DummyResource
- Includes:
- Amendable, Authorable, Comments::Commentable, Decidim::DataPortability, Endorsable, HasAttachments, NewsletterParticipant, ShareableWithToken, TranslatableResource, Followable, HasCategory, HasComponent, HasReference, Paddable, Publicable, Reportable, Resourceable, ScopableResource, Searchable, Traceable
- Defined in:
- lib/decidim/dev/test/rspec_support/component.rb
Class Method Summary collapse
- .export_serializer ⇒ Object
- .newsletter_participant_ids(component) ⇒ Object
- .user_collection(user) ⇒ Object
Instance Method Summary collapse
- #allow_resource_permissions? ⇒ Boolean
-
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
- #reported_attributes ⇒ Object
- #reported_content_url ⇒ Object
- #reported_searchable_content_extras ⇒ Object
-
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
-
#user_allowed_to_vote_comment?(user) ⇒ Boolean
Public: Whether the object can have new comment votes or not.
Class Method Details
.export_serializer ⇒ Object
153 154 155 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 153 def self.export_serializer DummySerializer end |
.newsletter_participant_ids(component) ⇒ Object
157 158 159 160 161 162 163 164 165 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 157 def self.(component) = Decidim::DummyResources::DummyResource.where(component: component) .where(decidim_author_type: Decidim::UserBaseEntity.name) .where.not(author: nil) .group(:decidim_author_id) .pluck(:decidim_author_id) commentators_ids = Decidim::Comments::Comment.user_commentators_ids_in(Decidim::DummyResources::DummyResource.where(component: component)) ( + commentators_ids).flatten.compact.uniq end |
.user_collection(user) ⇒ Object
149 150 151 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 149 def self.user_collection(user) where(decidim_author_id: user.id, decidim_author_type: "Decidim::User") end |
Instance Method Details
#allow_resource_permissions? ⇒ Boolean
130 131 132 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 130 def component.settings. end |
#commentable? ⇒ Boolean
Public: Overrides the ‘commentable?` Commentable concern method.
135 136 137 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 135 def commentable? component.settings.comments_enabled? end |
#reported_attributes ⇒ Object
122 123 124 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 122 def reported_attributes [:title] end |
#reported_content_url ⇒ Object
118 119 120 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 118 def reported_content_url ResourceLocatorPresenter.new(self).url end |
#reported_searchable_content_extras ⇒ Object
126 127 128 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 126 def reported_searchable_content_extras [.name] end |
#user_allowed_to_comment?(user) ⇒ Boolean
Public: Whether the object can have new comments or not.
140 141 142 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 140 def user_allowed_to_comment?(user) component.can_participate_in_space?(user) end |
#user_allowed_to_vote_comment?(user) ⇒ Boolean
Public: Whether the object can have new comment votes or not.
145 146 147 |
# File 'lib/decidim/dev/test/rspec_support/component.rb', line 145 def user_allowed_to_vote_comment?(user) component.can_participate_in_space?(user) end |