Skip to content

Commit

Permalink
Fix survey activity log entries (#9173)
Browse files Browse the repository at this point in the history
* Register survey resources

* Dont make surveys searchable
  • Loading branch information
lahdeero authored and andreslucena committed May 6, 2022
1 parent 498ae41 commit 5f8eae1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions decidim-surveys/app/models/decidim/surveys/survey.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class Survey < Surveys::ApplicationRecord

component_manifest_name "surveys"

delegate :title, to: :questionnaire

validates :questionnaire, presence: true

def clean_after_publish?
Expand Down
4 changes: 4 additions & 0 deletions decidim-surveys/lib/decidim/surveys/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
raise "Can't destroy this component when there are survey answers" if survey_answers_for_component.any?
end

component.register_resource(:survey) do |resource|
resource.model_class_name = "Decidim::Surveys::Survey"
end

component.register_stat :surveys_count do |components, start_at, end_at|
surveys = Decidim::Surveys::Survey.where(component: components)
surveys = surveys.where("created_at >= ?", start_at) if start_at.present?
Expand Down
11 changes: 11 additions & 0 deletions decidim-surveys/spec/system/survey_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@
end
end

context "when survey has action log entry" do
let!(:action_log) { create(:action_log, user: user, organization: component.organization, resource: survey, component: component, participatory_space: component.participatory_space, visibility: "all") }
let(:router) { Decidim::EngineRouter.main_proxy(component) }

it "shows action log entry" do
page.visit decidim.profile_activity_path(nickname: user.nickname)
expect(page).to have_content("New survey at #{translated(survey.component.participatory_space.title)}")
expect(page).to have_link(translated(survey.questionnaire.title), href: router.survey_path(survey))
end
end

def questionnaire_public_path
main_component_path(component)
end
Expand Down

0 comments on commit 5f8eae1

Please sign in to comment.