Class: Decidim::DummyResources::DummyResource

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasAttachments

#attachment_context

Methods included from Amendable

#add_author, #amendable?, #amendable_fields, #amendable_form, #amendment, #emendation?, #linked_promoted_resource, #notifiable_identities, #process_amendment_state_change!, #state, #visible_amendments_for, #visible_emendations_for

Methods included from Searchable

searchable_resources, searchable_resources_of_type_comment, searchable_resources_of_type_component, searchable_resources_of_type_participant, searchable_resources_of_type_participatory_space

Methods included from Publicable

#publish!, #published?, #unpublish!

Methods included from Followable

#followers

Class Method Details

.export_serializerObject


127
128
129
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 127

def self.export_serializer
  DummySerializer
end

.newsletter_participant_ids(component) ⇒ Object


131
132
133
134
135
136
137
138
139
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 131

def self.newsletter_participant_ids(component)
  authors_ids = 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))
  (authors_ids + commentators_ids).flatten.compact.uniq
end

.user_collection(user) ⇒ Object


123
124
125
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 123

def self.user_collection(user)
  where(decidim_author_id: user.id, decidim_author_type: "Decidim::User")
end

Instance Method Details

#allow_resource_permissions?Boolean

Returns:

  • (Boolean)

104
105
106
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 104

def allow_resource_permissions?
  component.settings.resources_permissions_enabled
end

#commentable?Boolean

Public: Overrides the `commentable?` Commentable concern method.

Returns:

  • (Boolean)

109
110
111
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 109

def commentable?
  component.settings.comments_enabled?
end

#reported_attributesObject


96
97
98
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 96

def reported_attributes
  [:title]
end

#reported_content_urlObject


92
93
94
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 92

def reported_content_url
  ResourceLocatorPresenter.new(self).url
end

#reported_searchable_content_extrasObject


100
101
102
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 100

def reported_searchable_content_extras
  [normalized_author.name]
end

#user_allowed_to_comment?(user) ⇒ Boolean

Public: Whether the object can have new comments or not.

Returns:

  • (Boolean)

114
115
116
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 114

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.

Returns:

  • (Boolean)

119
120
121
# File 'decidim-dev/lib/decidim/dev/test/rspec_support/component.rb', line 119

def user_allowed_to_vote_comment?(user)
  component.can_participate_in_space?(user)
end