Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix survey activity log entries #9173

Merged
merged 2 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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