Merge branch 'master' into followable

This commit is contained in:
BertoCQ
2017-07-11 11:30:49 +02:00
committed by GitHub
85 changed files with 1251 additions and 664 deletions

View File

@@ -1,11 +1,260 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-11-25 13:34:56 +0100 using RuboCop version 0.45.0.
# on 2017-07-07 21:23:30 +0200 using RuboCop version 0.49.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 45
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash:
Exclude:
- 'app/controllers/officing/results_controller.rb'
- 'spec/controllers/legislation/annotations_controller_spec.rb'
- 'spec/features/admin/banners_spec.rb'
# Offense count: 50
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
Layout/AlignParameters:
Enabled: false
# Offense count: 11
# Cop supports --auto-correct.
Layout/ClosingParenthesisIndentation:
Exclude:
- 'spec/features/site_customization/custom_pages_spec.rb'
- 'spec/models/legislation/annotation_spec.rb'
- 'spec/rails_helper.rb'
# Offense count: 51
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/polls_controller.rb'
- 'app/controllers/admin/poll/recounts_controller.rb'
- 'app/controllers/officing/final_recounts_controller.rb'
- 'app/controllers/officing/recounts_controller.rb'
- 'app/controllers/officing/residence_controller.rb'
- 'app/controllers/officing/results_controller.rb'
- 'app/models/poll/officer.rb'
- 'app/models/tag_cloud.rb'
- 'app/models/verification/management/managed_user.rb'
- 'lib/merged_comment_tree.rb'
# Offense count: 8
# Cop supports --auto-correct.
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'bin/rspec'
- 'bin/spring'
- 'spec/features/debates_spec.rb'
- 'spec/features/proposal_ballots_spec.rb'
- 'spec/features/proposals_spec.rb'
- 'spec/mailers/devise_mailer_spec.rb'
- 'spec/models/debate_spec.rb'
- 'spec/models/proposal_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLines:
Exclude:
- 'app/controllers/admin/budget_investment_milestones_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/EmptyLinesAroundMethodBody:
Exclude:
- 'app/models/abilities/administrator.rb'
- 'lib/graph_ql/api_types_creator.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Exclude:
- 'spec/factories.rb'
- 'spec/models/proposal_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstParameterIndentation:
Exclude:
- 'app/controllers/users_controller.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/IndentArray:
EnforcedStyle: consistent
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/IndentHash:
Exclude:
- 'spec/controllers/legislation/annotations_controller_spec.rb'
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
Layout/IndentHeredoc:
Exclude:
- 'spec/factories.rb'
- 'spec/models/legislation/draft_version_spec.rb'
# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: normal, rails
Layout/IndentationConsistency:
Exclude:
- 'spec/features/tracks_spec.rb'
- 'spec/models/budget/investment_spec.rb'
- 'spec/models/legislation/draft_version_spec.rb'
- 'spec/models/proposal_spec.rb'
# Offense count: 23
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Enabled: false
# Offense count: 7
# Cop supports --auto-correct.
Layout/LeadingCommentSpace:
Exclude:
- 'Capfile'
- 'app/controllers/budgets/ballot/lines_controller.rb'
- 'spec/features/budgets/ballots_spec.rb'
- 'spec/features/comments/poll_questions_spec.rb'
- 'spec/features/officing/voters_spec.rb'
- 'spec/support/common_actions.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineArrayBraceLayout:
Exclude:
- 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/helpers/search_helper.rb'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineHashBraceLayout:
Exclude:
- 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/models/budget/investment.rb'
- 'app/models/debate.rb'
- 'app/models/proposal.rb'
- 'app/models/spending_proposal.rb'
# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'app/controllers/legislation/annotations_controller.rb'
- 'app/controllers/users_controller.rb'
- 'app/models/comment.rb'
- 'app/models/organization.rb'
- 'app/models/user.rb'
- 'spec/features/site_customization/custom_pages_spec.rb'
- 'spec/models/legislation/annotation_spec.rb'
- 'spec/rails_helper.rb'
# Offense count: 71
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/polls_controller.rb'
- 'app/controllers/admin/poll/recounts_controller.rb'
- 'app/controllers/officing/final_recounts_controller.rb'
- 'app/controllers/officing/recounts_controller.rb'
- 'app/controllers/officing/residence_controller.rb'
- 'app/controllers/officing/results_controller.rb'
- 'app/models/poll/officer.rb'
- 'app/models/tag_cloud.rb'
- 'app/models/verification/management/managed_user.rb'
- 'lib/merged_comment_tree.rb'
- 'spec/models/comment_spec.rb'
- 'spec/models/debate_spec.rb'
- 'spec/models/proposal_spec.rb'
- 'spec/models/user_spec.rb'
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'app/controllers/officing/results_controller.rb'
- 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_helper.rb'
- 'app/models/user.rb'
- 'app/models/verification/letter.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceAfterColon:
Exclude:
- 'spec/features/admin/site_customization/pages_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceBeforeFirstArg:
Exclude:
- 'spec/factories.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/SpaceInsideRangeLiteral:
Exclude:
- 'app/models/legislation/annotation.rb'
# Offense count: 38
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/controllers/comments_controller_spec.rb'
- 'spec/controllers/debates_controller_spec.rb'
- 'spec/controllers/legislation/annotations_controller_spec.rb'
- 'spec/controllers/legislation/answers_controller_spec.rb'
- 'spec/lib/cache_spec.rb'
- 'spec/models/comment_spec.rb'
- 'spec/models/debate_spec.rb'
- 'spec/models/proposal_spec.rb'
- 'spec/models/user_spec.rb'
# Offense count: 2
Lint/HandleExceptions:
Exclude:
- 'app/controllers/legislation/annotations_controller.rb'
- 'spec/lib/graphql_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -14,79 +263,122 @@ Lint/InheritException:
Exclude:
- 'app/controllers/concerns/feature_flags.rb'
# Offense count: 13
# Offense count: 1
Lint/LiteralInCondition:
Exclude:
- 'app/models/budget/investment.rb'
# Offense count: 51
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'spec/factories.rb'
- 'spec/features/admin/organizations_spec.rb'
- 'spec/features/budgets/investments_spec.rb'
- 'spec/features/campaigns_spec.rb'
- 'spec/features/debates_spec.rb'
- 'spec/features/management/managed_users_spec.rb'
- 'spec/features/management/proposals_spec.rb'
- 'spec/features/management/spending_proposals_spec.rb'
- 'spec/features/management/users_spec.rb'
- 'spec/features/proposals_spec.rb'
- 'spec/models/debate_spec.rb'
# Offense count: 4
# Offense count: 13
# Cop supports --auto-correct.
Lint/StringConversionInInterpolation:
Exclude:
- 'app/models/poll/final_recount.rb'
- 'app/models/poll/null_result.rb'
- 'app/models/poll/partial_result.rb'
- 'app/models/poll/recount.rb'
- 'app/models/poll/white_result.rb'
# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'app/controllers/admin/spending_proposals_controller.rb'
- 'app/models/ahoy/data_source.rb'
- 'lib/graph_ql/api_types_creator.rb'
- 'lib/graph_ql/query_type_creator.rb'
- 'spec/controllers/concerns/has_orders_spec.rb'
- 'spec/factories.rb'
- 'spec/spec_helper.rb'
# Offense count: 5
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'app/controllers/organizations/registrations_controller.rb'
- 'app/controllers/users/omniauth_callbacks_controller.rb'
- 'app/controllers/users/registrations_controller.rb'
- 'app/mailers/mailer.rb'
- 'app/models/abilities/everyone.rb'
- 'app/models/abilities/valuator.rb'
# Offense count: 135
# Offense count: 278
Lint/UselessAssignment:
Enabled: false
# Offense count: 41
Metrics/AbcSize:
Max: 44
# Offense count: 1
Lint/Void:
Exclude:
- 'app/controllers/polls_controller.rb'
# Offense count: 4
# Offense count: 74
Metrics/AbcSize:
Max: 54
# Offense count: 454
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/BlockLength:
Max: 1071
# Offense count: 8
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 205
Max: 256
# Offense count: 5
# Offense count: 10
Metrics/CyclomaticComplexity:
Max: 8
Max: 10
# Offense count: 52
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives.
# URISchemes: http, https
Metrics/LineLength:
Max: 307
# Offense count: 28
# Offense count: 53
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 38
Max: 49
# Offense count: 2
# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 193
Max: 214
# Offense count: 3
# Offense count: 7
Metrics/PerceivedComplexity:
Max: 11
# Offense count: 4
# Offense count: 6
# Cop supports --auto-correct.
Performance/RedundantMatch:
Exclude:
- 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/helpers/embed_videos_helper.rb'
# Offense count: 4
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent.
Rails/Blank:
Exclude:
- 'app/controllers/management/base_controller.rb'
# Offense count: 1
# Cop supports --auto-correct.
Rails/Delegate:
Exclude:
- 'app/models/poll/question.rb'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: Whitelist.
# Whitelist: find_by_sql
@@ -96,18 +388,38 @@ Rails/DynamicFindBy:
- 'app/controllers/users/registrations_controller.rb'
- 'spec/features/management/users_spec.rb'
# Offense count: 4
# Offense count: 2
Rails/FilePath:
Exclude:
- 'app/controllers/sandbox_controller.rb'
- 'spec/spec_helper.rb'
# Offense count: 16
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/FindBy:
Exclude:
- 'app/models/budget/ballot.rb'
- 'app/models/geozone.rb'
- 'app/models/legislation/question.rb'
- 'app/models/officing/residence.rb'
- 'app/models/poll/voter.rb'
- 'app/models/setting.rb'
- 'app/models/signature.rb'
- 'app/models/user.rb'
- 'app/models/verification/email.rb'
- 'app/models/verification/management/email.rb'
- 'app/models/verification/residence.rb'
# Offense count: 24
# Offense count: 1
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasAndBelongsToMany:
Exclude:
- 'app/models/poll.rb'
# Offense count: 37
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: spec/**/*, test/**/*
@@ -117,20 +429,40 @@ Rails/HttpPositionalArguments:
- 'spec/controllers/concerns/has_filters_spec.rb'
- 'spec/controllers/concerns/has_orders_spec.rb'
- 'spec/controllers/debates_controller_spec.rb'
- 'spec/controllers/graphql_controller_spec.rb'
- 'spec/controllers/legislation/annotations_controller_spec.rb'
- 'spec/controllers/legislation/answers_controller_spec.rb'
- 'spec/controllers/management/sessions_controller_spec.rb'
- 'spec/controllers/pages_controller_spec.rb'
- 'spec/controllers/users/registrations_controller_spec.rb'
# Offense count: 12
# Offense count: 20
Rails/OutputSafety:
Exclude:
- 'app/controllers/admin/legislation/draft_versions_controller.rb'
- 'app/controllers/admin/legislation/processes_controller.rb'
- 'app/controllers/admin/legislation/questions_controller.rb'
- 'app/controllers/budgets/investments_controller.rb'
- 'app/controllers/spending_proposals_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/text_with_links_helper.rb'
- 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_helper.rb'
# Offense count: 9
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank.
Rails/Present:
Exclude:
- 'app/controllers/management/document_verifications_controller.rb'
# Offense count: 70
# Configuration parameters: Blacklist.
# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters
Rails/SkipsModelValidations:
Enabled: false
# Offense count: 10
Style/AccessorMethodName:
Exclude:
- 'app/controllers/application_controller.rb'
@@ -138,34 +470,17 @@ Style/AccessorMethodName:
- 'app/controllers/management/proposals_controller.rb'
- 'app/controllers/management/spending_proposals_controller.rb'
- 'app/controllers/proposals_controller.rb'
- 'lib/merged_comment_tree.rb'
# Offense count: 30
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles.
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/AlignHash:
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Style/BracesAroundHashParameters:
Exclude:
- 'spec/features/admin/banners_spec.rb'
- 'app/models/concerns/searchable.rb'
# Offense count: 21
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: with_first_parameter, with_fixed_indentation
Layout/AlignParameters:
Exclude:
- 'app/helpers/search_helper.rb'
- 'app/models/verification/management/email.rb'
- 'bin/rspec'
- 'bin/spring'
- 'spec/features/admin/spending_proposals_spec.rb'
- 'spec/features/spending_proposals_spec.rb'
- 'spec/features/valuation/spending_proposals_spec.rb'
- 'spec/features/verification/verified_user_spec.rb'
- 'spec/i18n_spec.rb'
- 'spec/models/user_spec.rb'
- 'spec/rails_helper.rb'
# Offense count: 57
# Offense count: 119
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
@@ -178,32 +493,28 @@ Style/ClassVars:
- 'app/models/organization.rb'
- 'app/models/user.rb'
# Offense count: 1
# Offense count: 6
# Cop supports --auto-correct.
Layout/ClosingParenthesisIndentation:
Style/ColonMethodCall:
Exclude:
- 'spec/rails_helper.rb'
- 'spec/models/budget/investment_spec.rb'
# Offense count: 4
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'app/controllers/admin/poll/booth_assignments_controller.rb'
- 'app/controllers/admin/poll/officer_assignments_controller.rb'
- 'app/controllers/admin/poll/questions_controller.rb'
- 'app/controllers/comments_controller.rb'
- 'app/controllers/management/spending_proposals_controller.rb'
- 'app/controllers/officing/final_recounts_controller.rb'
- 'app/controllers/officing/recounts_controller.rb'
- 'app/controllers/spending_proposals_controller.rb'
- 'app/controllers/verification/sms_controller.rb'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'app/models/banner.rb'
- 'app/models/tag_cloud.rb'
- 'app/models/verification/management/managed_user.rb'
- 'lib/graph_ql/api_types_creator.rb'
# Offense count: 1
Style/DoubleNegation:
@@ -216,79 +527,46 @@ Style/EmptyCaseCondition:
Exclude:
- 'app/models/concerns/verification.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstParameterIndentation:
# Offense count: 2
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Style/FileName:
Exclude:
- 'app/controllers/users_controller.rb'
- 'Capfile'
- 'Gemfile'
# Offense count: 32
# Offense count: 56
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
# Offense count: 6
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Exclude:
- 'app/controllers/annotations_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/graphql_controller.rb'
- 'app/controllers/legislation/annotations_controller.rb'
- 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/verification/letter_controller.rb'
- 'app/controllers/welcome_controller.rb'
- 'app/helpers/embed_videos_helper.rb'
- 'app/mailers/mailer.rb'
- 'app/models/proposal.rb'
- 'app/models/spending_proposal.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/IndentArray:
EnforcedStyle: consistent
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/IndentHash:
EnforcedStyle: consistent
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: normal, rails
Layout/IndentationConsistency:
Exclude:
- 'spec/features/tracks_spec.rb'
- 'spec/models/proposal_spec.rb'
# Offense count: 11
# Cop supports --auto-correct.
# Configuration parameters: Width.
Layout/IndentationWidth:
Exclude:
- 'app/controllers/annotations_controller.rb'
- 'app/helpers/flags_helper.rb'
- 'app/mailers/devise_mailer.rb'
- 'app/mailers/mailer.rb'
- 'app/models/ahoy/data_source.rb'
- 'app/models/comment_notifier.rb'
- 'app/models/concerns/search_cache.rb'
- 'spec/features/comments/proposals_spec.rb'
- 'spec/features/moderation/users_spec.rb'
- 'spec/features/tracks_spec.rb'
- 'spec/features/verification/verified_user_spec.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: line_count_dependent, lambda, literal
Style/Lambda:
Exclude:
- 'app/models/banner.rb'
- 'app/models/comment.rb'
- 'app/models/direct_message.rb'
- 'app/models/vote.rb'
- 'lib/graph_ql/api_types_creator.rb'
# Offense count: 1
# Cop supports --auto-correct.
@@ -304,101 +582,58 @@ Style/MethodDefParentheses:
Exclude:
- 'spec/helpers/comments_helper_spec.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineArrayBraceLayout:
Exclude:
- 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/helpers/search_helper.rb'
# Offense count: 1
Style/MultilineBlockChain:
Exclude:
- 'app/controllers/valuation/spending_proposals_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/MultilineBlockLayout:
Exclude:
- 'app/models/banner.rb'
- 'spec/features/users_auth_spec.rb'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineHashBraceLayout:
Exclude:
- 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/models/debate.rb'
- 'app/models/proposal.rb'
- 'app/models/spending_proposal.rb'
# Offense count: 2
# Offense count: 1
# Cop supports --auto-correct.
Style/MultilineIfThen:
Exclude:
- 'app/controllers/management/users_controller.rb'
- 'lib/census_api.rb'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'app/controllers/users_controller.rb'
- 'app/models/comment.rb'
- 'app/models/organization.rb'
- 'app/models/user.rb'
- 'spec/rails_helper.rb'
# Offense count: 33
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'app/models/banner.rb'
- 'app/models/tag_cloud.rb'
- 'app/models/verification/management/managed_user.rb'
- 'spec/models/comment_spec.rb'
- 'spec/models/debate_spec.rb'
- 'spec/models/proposal_spec.rb'
- 'spec/models/user_spec.rb'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_helper.rb'
- 'app/models/verification/letter.rb'
# Offense count: 5
# Offense count: 15
# Cop supports --auto-correct.
Style/MutableConstant:
Exclude:
- 'app/models/activity.rb'
- 'app/models/budget/reclassified_vote.rb'
- 'app/models/legislation/draft_version.rb'
- 'app/models/poll/null_result.rb'
- 'app/models/poll/partial_result.rb'
- 'app/models/poll/white_result.rb'
- 'app/models/proposal.rb'
- 'app/models/signature_sheet.rb'
- 'app/models/site_customization/content_block.rb'
- 'app/models/site_customization/image.rb'
- 'app/models/site_customization/page.rb'
- 'lib/graph_ql/api_types_creator.rb'
- 'lib/tag_sanitizer.rb'
- 'lib/wysiwyg_sanitizer.rb'
# Offense count: 17
# Offense count: 29
# Cop supports --auto-correct.
Style/NestedParenthesizedCalls:
Exclude:
- 'spec/features/debates_spec.rb'
- 'spec/features/emails_spec.rb'
- 'spec/features/valuation/budget_investments_spec.rb'
- 'spec/features/valuation/spending_proposals_spec.rb'
- 'spec/helpers/settings_helper_spec.rb'
- 'spec/helpers/verification_helper_spec.rb'
# Offense count: 12
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
# SupportedStyles: skip_modifier_ifs, always
Style/Next:
Exclude:
- 'app/controllers/officing/results_controller.rb'
# Offense count: 54
# Cop supports --auto-correct.
# Configuration parameters: Strict.
Style/NumericLiterals:
MinDigits: 9
@@ -414,9 +649,9 @@ Style/NumericPredicate:
- 'app/helpers/banners_helper.rb'
- 'app/helpers/debates_helper.rb'
- 'app/helpers/votes_helper.rb'
- 'app/models/budget/ballot.rb'
- 'app/models/concerns/conflictable.rb'
- 'app/models/concerns/taggable.rb'
- 'app/models/concerns/verification.rb'
- 'app/models/debate.rb'
- 'app/models/lock.rb'
- 'app/models/user.rb'
@@ -439,7 +674,7 @@ Style/ParenthesesAroundCondition:
- 'app/models/debate.rb'
- 'app/models/proposal.rb'
# Offense count: 6
# Offense count: 11
# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist.
# NamePrefix: is_, has_, have_
# NamePrefixBlacklist: is_, has_, have_
@@ -451,10 +686,11 @@ Style/PredicateName:
- 'app/controllers/concerns/has_orders.rb'
- 'app/helpers/banners_helper.rb'
- 'app/helpers/debates_helper.rb'
- 'app/models/budget/ballot.rb'
- 'app/models/user.rb'
- 'lib/census_api.rb'
# Offense count: 3
# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: compact, exploded
@@ -462,18 +698,20 @@ Style/RaiseArgs:
Exclude:
- 'app/controllers/management/base_controller.rb'
- 'app/controllers/users/omniauth_callbacks_controller.rb'
- 'app/controllers/valuation/budget_investments_controller.rb'
- 'app/controllers/valuation/spending_proposals_controller.rb'
# Offense count: 16
# Offense count: 2
# Cop supports --auto-correct.
Style/RedundantBegin:
Exclude:
- 'app/controllers/graphql_controller.rb'
- 'app/models/legislation/annotation.rb'
# Offense count: 55
# Cop supports --auto-correct.
Style/RedundantParentheses:
Exclude:
- 'app/controllers/admin/settings_controller.rb'
- 'app/helpers/proposals_helper.rb'
- 'spec/features/admin/organizations_spec.rb'
- 'spec/features/debates_spec.rb'
- 'spec/features/proposals_spec.rb'
- 'spec/models/debate_spec.rb'
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
@@ -484,43 +722,54 @@ Style/RegexpLiteral:
- 'app/helpers/embed_videos_helper.rb'
- 'spec/customization_engine_spec.rb'
# Offense count: 2
# Offense count: 6
# Cop supports --auto-correct.
Style/RescueModifier:
Exclude:
- 'app/controllers/concerns/commentable_actions.rb'
- 'app/controllers/budgets/investments_controller.rb'
- 'app/controllers/concerns/search.rb'
- 'app/controllers/verification/sms_controller.rb'
- 'app/models/concerns/measurable.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: ConvertCodeThatCanStartToReturnNil.
Style/SafeNavigation:
Exclude:
- 'app/models/signature.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiteralsInInterpolation:
Exclude:
- 'spec/features/budgets/investments_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Exclude:
- 'app/controllers/legislation/answers_controller.rb'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
# IgnoredMethods: respond_to, define_method
Style/SymbolProc:
Exclude:
- 'app/controllers/admin/settings_controller.rb'
- 'app/controllers/notifications_controller.rb'
- 'app/controllers/organizations/registrations_controller.rb'
- 'lib/manager_authenticator.rb'
- 'spec/factories.rb'
# Offense count: 13
# Configuration parameters: SupportedStyles.
# SupportedStyles: snake_case, camelCase
Style/VariableName:
EnforcedStyle: snake_case
# Offense count: 107
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: snake_case, normalcase, non_integer
Style/VariableNumber:
EnforcedStyle: normalcase
Enabled: false
# Offense count: 9
# Offense count: 31
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles, WordRegex.
# SupportedStyles: percent, brackets
Style/WordArray:
EnforcedStyle: percent
MinSize: 3
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: braces, no_braces, context_dependent
Style/BracesAroundHashParameters:
Exclude:
- 'app/models/concerns/searchable.rb'
MinSize: 9

View File

@@ -1,22 +1,74 @@
# Contributor Code of Conduct
# Contributor Covenant Code of Conduct
As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
## Our Pledge
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
* Other unethical or unprofessional conduct.
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.
## Our Responsibilities
This code of conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at consul@madrid.es. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

162
Gemfile
View File

@@ -1,117 +1,91 @@
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.9'
# Use PostgreSQL
gem 'pg', '~> 0.20.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0', '>= 5.0.4'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '~> 3.2.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2.1'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails', '~> 4.3.1'
gem 'jquery-ui-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Fix sprockets on the
gem 'sprockets', '~> 3.7.1'
gem 'devise', '~> 3.5.7'
gem 'devise_security_extension'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook', '~> 4.0.0'
gem 'omniauth-google-oauth2', '~> 0.4.0'
gem 'kaminari', '~> 1.0.1'
gem 'acts-as-taggable-on', '~> 4.0.0'
gem 'acts_as_votable', '~> 0.10.0'
gem 'ahoy_matey', '~> 1.6.0'
gem 'ancestry', '~> 2.2.2'
gem 'acts-as-taggable-on'
gem 'responders', '~> 2.4.0'
gem 'browser', '~> 2.3.0'
gem 'cancancan', '~> 1.16.0'
gem 'ckeditor', '~> 4.2.3'
gem 'cocoon', '~> 1.2.9'
gem 'coffee-rails', '~> 4.2.1'
gem 'daemons', '~> 1.2.4'
gem 'dalli', '~> 2.7.6'
gem 'delayed_job_active_record', '~> 4.1.0'
gem 'devise', '~> 3.5.7'
gem 'devise-async', '~> 0.10.2'
gem 'devise_security_extension', '~> 0.10.0'
gem 'foundation-rails', '~> 6.2.4.0'
gem 'foundation_rails_helper', '~> 2.0.0'
gem 'acts_as_votable'
gem 'ckeditor', '~> 4.2.3'
gem 'invisible_captcha', '~> 0.9.2'
gem 'cancancan', '~> 1.16.0'
gem 'social-share-button', '~> 0.10'
gem 'initialjs-rails', '0.2.0.4'
gem 'unicorn', '~> 5.3.0'
gem 'paranoia', '~> 2.3.1'
gem 'rinku', '~> 2.0.2', require: 'rails_rinku'
gem 'savon'
gem 'dalli'
gem 'rollbar', '~> 2.14.1'
gem 'delayed_job_active_record', '~> 4.1.0'
gem 'daemons'
gem 'devise-async'
gem 'newrelic_rpm', '~> 4.1.0.333'
gem 'whenever', require: false
gem 'pg_search'
gem 'sitemap_generator', '~> 5.3.1'
gem 'ahoy_matey', '~> 1.6.0'
gem 'groupdate', '~> 3.2.0' # group temporary data
gem 'tolk', '~> 2.0.0' # Web interface for translations
gem 'browser'
gem 'turnout', '~> 2.4.0'
gem 'redcarpet', '~> 3.4.0'
gem 'rubyzip', '~> 1.2.0'
gem 'paperclip'
gem 'rails-assets-markdown-it', source: 'https://rails-assets.org'
gem 'cocoon'
gem 'graphql', '~> 1.6.3'
gem 'graphiql-rails', '~> 1.4.1'
gem 'graphql', '~> 1.6.3'
gem 'groupdate', '~> 3.2.0'
gem 'initialjs-rails', '~> 0.2.0.5'
gem 'invisible_captcha', '~> 0.9.2'
gem 'jquery-rails', '~> 4.3.1'
gem 'jquery-ui-rails', '~> 6.0.1'
gem 'kaminari', '~> 1.0.1'
gem 'newrelic_rpm', '~> 4.1.0.333'
gem 'omniauth', '~> 1.6.1'
gem 'omniauth-facebook', '~> 4.0.0'
gem 'omniauth-google-oauth2', '~> 0.4.0'
gem 'omniauth-twitter', '~> 1.4.0'
gem 'paperclip', '~> 5.1.0'
gem 'paranoia', '~> 2.3.1'
gem 'pg', '~> 0.20.0'
gem 'pg_search', '~> 2.0.1'
gem 'rails-assets-markdown-it', '~> 8.2.1', source: 'https://rails-assets.org'
gem 'redcarpet', '~> 3.4.0'
gem 'responders', '~> 2.4.0'
gem 'rinku', '~> 2.0.2', require: 'rails_rinku'
gem 'rollbar', '~> 2.14.1'
gem 'rubyzip', '~> 1.2.0'
gem 'sass-rails', '~> 5.0', '>= 5.0.4'
gem 'savon', '~> 2.11.1'
gem 'sitemap_generator', '~> 5.3.1'
gem 'social-share-button', '~> 0.10'
gem 'sprockets', '~> 3.7.1'
gem 'turbolinks', '~> 2.5.3'
gem 'turnout', '~> 2.4.0'
gem 'uglifier', '~> 3.2.0'
gem 'unicorn', '~> 5.3.0'
gem 'whenever', '~> 0.9.7', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-commands-rspec'
gem 'rspec-rails', '~> 3.6'
gem 'capybara', '~> 2.14.0'
gem 'factory_girl_rails', '~> 4.8.0'
gem 'fuubar'
gem 'launchy'
gem 'quiet_assets'
gem 'letter_opener_web', '~> 1.3.1'
gem 'i18n-tasks', '~> 0.9.15'
gem 'capistrano', '~> 3.8.1', require: false
gem 'capistrano-bundler', '~> 1.2', require: false
gem "capistrano-rails", '~> 1.2.3', require: false
gem 'rvm1-capistrano3', require: false
gem 'capistrano3-delayed-job', '~> 1.7.3'
gem "bullet", '~> 5.5.1'
gem 'byebug', '~> 9.0.6'
gem 'factory_girl_rails', '~> 4.8.0'
gem "faker", '~> 1.7.3'
gem 'i18n-tasks', '~> 0.9.15'
gem 'knapsack', '~> 1.13.3'
gem 'launchy', '~> 2.4.3'
gem 'letter_opener_web', '~> 1.3.1'
gem 'quiet_assets', '~> 1.1.0'
gem 'rubocop', '~> 0.49.1', require: false
gem 'knapsack'
gem 'spring', '~> 2.0.1'
gem 'spring-commands-rspec', '~> 1.0.4'
end
group :test do
gem 'database_cleaner'
gem 'poltergeist', '~> 1.15.0'
gem 'capybara', '~> 2.14.0'
gem 'coveralls', '~> 0.8.21', require: false
gem 'email_spec'
gem 'database_cleaner', '~> 1.5.3'
gem 'email_spec', '~> 2.1.0'
gem 'poltergeist', '~> 1.15.0'
gem 'rspec-rails', '~> 3.6'
end
group :development do
gem 'mdl', require: false
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'scss_lint', require: false
gem 'web-console', '3.3.0'
gem 'capistrano', '~> 3.8.1', require: false
gem 'capistrano-bundler', '~> 1.2', require: false
gem "capistrano-rails", '~> 1.2.3', require: false
gem 'capistrano3-delayed-job', '~> 1.7.3'
gem 'mdl', '~> 0.4.0', require: false
gem 'rvm1-capistrano3', '~> 1.4.0', require: false
gem 'scss_lint', '~> 0.53.0', require: false
gem 'web-console', '~> 3.3.0'
end
eval_gemfile './Gemfile_custom'

View File

@@ -170,9 +170,6 @@ GEM
activesupport (>= 4.1)
railties (>= 4.1)
tzinfo (~> 1.2, >= 1.2.2)
fuubar (2.2.0)
rspec-core (~> 3.0)
ruby-progressbar (~> 1.4)
geocoder (1.4.3)
globalid (0.4.0)
activesupport (>= 4.2.0)
@@ -199,7 +196,7 @@ GEM
parser (>= 2.2.3.0)
rainbow (~> 2.2)
terminal-table (>= 1.5.1)
initialjs-rails (0.2.0.4)
initialjs-rails (0.2.0.5)
railties (>= 3.1, < 6.0)
invisible_captcha (0.9.2)
rails (>= 3.2.0)
@@ -387,7 +384,6 @@ GEM
rvm1-capistrano3 (1.4.0)
capistrano (~> 3.0)
sshkit (>= 1.2)
safe_yaml (1.0.4)
safely_block (0.2.0)
errbase
sass (3.4.23)
@@ -445,9 +441,6 @@ GEM
tilt (2.0.7)
timecop (0.8.1)
tins (1.13.2)
tolk (2.0.0)
rails (>= 4.0)
safe_yaml (>= 0.8.6)
turbolinks (2.5.3)
coffee-rails
turnout (2.4.0)
@@ -487,13 +480,13 @@ PLATFORMS
ruby
DEPENDENCIES
acts-as-taggable-on
acts_as_votable
acts-as-taggable-on (~> 4.0.0)
acts_as_votable (~> 0.10.0)
ahoy_matey (~> 1.6.0)
ancestry (~> 2.2.2)
browser
browser (~> 2.3.0)
bullet (~> 5.5.1)
byebug
byebug (~> 9.0.6)
cancancan (~> 1.16.0)
capistrano (~> 3.8.1)
capistrano-bundler (~> 1.2)
@@ -501,48 +494,47 @@ DEPENDENCIES
capistrano3-delayed-job (~> 1.7.3)
capybara (~> 2.14.0)
ckeditor (~> 4.2.3)
cocoon
cocoon (~> 1.2.9)
coffee-rails (~> 4.2.1)
coveralls (~> 0.8.21)
daemons
dalli
database_cleaner
daemons (~> 1.2.4)
dalli (~> 2.7.6)
database_cleaner (~> 1.5.3)
delayed_job_active_record (~> 4.1.0)
devise (~> 3.5.7)
devise-async
devise_security_extension
email_spec
devise-async (~> 0.10.2)
devise_security_extension (~> 0.10.0)
email_spec (~> 2.1.0)
factory_girl_rails (~> 4.8.0)
faker (~> 1.7.3)
foundation-rails (~> 6.2.4.0)
foundation_rails_helper (~> 2.0.0)
fuubar
graphiql-rails (~> 1.4.1)
graphql (~> 1.6.3)
groupdate (~> 3.2.0)
i18n-tasks (~> 0.9.15)
initialjs-rails (= 0.2.0.4)
initialjs-rails (~> 0.2.0.5)
invisible_captcha (~> 0.9.2)
jquery-rails (~> 4.3.1)
jquery-ui-rails
jquery-ui-rails (~> 6.0.1)
kaminari (~> 1.0.1)
knapsack
launchy
knapsack (~> 1.13.3)
launchy (~> 2.4.3)
letter_opener_web (~> 1.3.1)
mdl
mdl (~> 0.4.0)
newrelic_rpm (~> 4.1.0.333)
omniauth
omniauth (~> 1.6.1)
omniauth-facebook (~> 4.0.0)
omniauth-google-oauth2 (~> 0.4.0)
omniauth-twitter
paperclip
omniauth-twitter (~> 1.4.0)
paperclip (~> 5.1.0)
paranoia (~> 2.3.1)
pg (~> 0.20.0)
pg_search
pg_search (~> 2.0.1)
poltergeist (~> 1.15.0)
quiet_assets
quiet_assets (~> 1.1.0)
rails (= 4.2.9)
rails-assets-markdown-it!
rails-assets-markdown-it (~> 8.2.1)!
redcarpet (~> 3.4.0)
responders (~> 2.4.0)
rinku (~> 2.0.2)
@@ -550,22 +542,21 @@ DEPENDENCIES
rspec-rails (~> 3.6)
rubocop (~> 0.49.1)
rubyzip (~> 1.2.0)
rvm1-capistrano3
rvm1-capistrano3 (~> 1.4.0)
sass-rails (~> 5.0, >= 5.0.4)
savon
scss_lint
savon (~> 2.11.1)
scss_lint (~> 0.53.0)
sitemap_generator (~> 5.3.1)
social-share-button (~> 0.10)
spring
spring-commands-rspec
spring (~> 2.0.1)
spring-commands-rspec (~> 1.0.4)
sprockets (~> 3.7.1)
tolk (~> 2.0.0)
turbolinks
turbolinks (~> 2.5.3)
turnout (~> 2.4.0)
uglifier (~> 3.2.0)
unicorn (~> 5.3.0)
web-console (= 3.3.0)
whenever
web-console (~> 3.3.0)
whenever (~> 0.9.7)
BUNDLED WITH
1.15.1

View File

@@ -132,7 +132,7 @@
background: hsla(51, 91, 75, 0.5);
.weight-4 {
background: hsla(51, 91, 75, 0.75);
background: hsla(51, 91, 75, 0.75);
}
}

View File

@@ -236,6 +236,11 @@ a {
border-bottom: 2px solid $brand;
color: $brand;
}
&.bold {
font-weight: bold;
color: $brand;
}
}
&.no-margin-top {

View File

@@ -23,9 +23,11 @@ class AccountController < ApplicationController
def account_params
if @account.organization?
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name])
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter,
organization_attributes: [:name, :responsible_name])
else
params.require(:account).permit(:username, :public_activity, :public_interests, :email_on_comment, :email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter, :official_position_badge)
params.require(:account).permit(:username, :public_activity, :public_interests, :email_on_comment, :email_on_comment_reply,
:email_on_direct_message, :email_digest, :newsletter, :official_position_badge)
end
end

View File

@@ -20,7 +20,7 @@ class Admin::BudgetsController < Admin::BaseController
def calculate_winners
return unless @budget.balloting_process?
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).calculate_winners }
@budget.headings.each { |heading| Budget::Result.new(@budget, heading).delay.calculate_winners }
redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'winners'),
notice: I18n.t("admin.budgets.winners.calculated")
end

View File

@@ -8,7 +8,8 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
def create
if @draft_version.save
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe)
link = legislation_process_draft_version_path(@process, @draft_version).html_safe
redirect_to admin_legislation_process_draft_versions_path, notice: t('admin.legislation.draft_versions.create.notice', link: link)
else
flash.now[:error] = t('admin.legislation.draft_versions.create.error')
render :new
@@ -17,7 +18,9 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
def update
if @draft_version.update(draft_version_params)
redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: t('admin.legislation.draft_versions.update.notice', link: legislation_process_draft_version_path(@process, @draft_version).html_safe)
link = legislation_process_draft_version_path(@process, @draft_version).html_safe
notice = t('admin.legislation.draft_versions.update.notice', link: link)
redirect_to edit_admin_legislation_process_draft_version_path(@process, @draft_version), notice: notice
else
flash.now[:error] = t('admin.legislation.draft_versions.update.error')
render :edit

View File

@@ -9,7 +9,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
def create
if @process.save
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: legislation_process_path(@process).html_safe)
link = legislation_process_path(@process).html_safe
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.create.notice', link: link)
else
flash.now[:error] = t('admin.legislation.processes.create.error')
render :new
@@ -18,7 +19,8 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
def update
if @process.update(process_params)
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: legislation_process_path(@process).html_safe)
link = legislation_process_path(@process).html_safe
redirect_to edit_admin_legislation_process_path(@process), notice: t('admin.legislation.processes.update.notice', link: link)
else
flash.now[:error] = t('admin.legislation.processes.update.error')
render :edit

View File

@@ -13,7 +13,8 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
def create
@question.author = current_user
if @question.save
redirect_to admin_legislation_process_questions_path, notice: t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe)
notice = t('admin.legislation.questions.create.notice', link: legislation_process_question_path(@process, @question).html_safe)
redirect_to admin_legislation_process_questions_path, notice: notice
else
flash.now[:error] = t('admin.legislation.questions.create.error')
render :new
@@ -22,7 +23,8 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
def update
if @question.update(question_params)
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe)
notice = t('admin.legislation.questions.update.notice', link: legislation_process_question_path(@process, @question).html_safe)
redirect_to edit_admin_legislation_process_question_path(@process, @question), notice: notice
else
flash.now[:error] = t('admin.legislation.questions.update.error')
render :edit

View File

@@ -15,12 +15,14 @@ class Admin::Poll::BoothAssignmentsController < Admin::BaseController
end
def show
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters, officer_assignments: [officer: [:user]]).find(params[:id])
@booth_assignment = @poll.booth_assignments.includes(:recounts, :final_recounts, :voters,
officer_assignments: [officer: [:user]]).find(params[:id])
@voters_by_date = @booth_assignment.voters.group_by {|v| v.created_at.to_date}
end
def create
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll_id], booth_id: booth_assignment_params[:booth_id])
@booth_assignment = ::Poll::BoothAssignment.new(poll_id: booth_assignment_params[:poll_id],
booth_id: booth_assignment_params[:booth_id])
if @booth_assignment.save
notice = t("admin.poll_booth_assignments.flash.create")

View File

@@ -43,7 +43,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
else
notice = t("admin.poll_officer_assignments.flash.error_create")
end
redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: create_params[:poll_id], officer_id: create_params[:officer_id]), notice: notice
redirect_params = { poll_id: create_params[:poll_id], officer_id: create_params[:officer_id] }
redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice
end
def destroy
@@ -54,7 +56,9 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
else
notice = t("admin.poll_officer_assignments.flash.error_destroy")
end
redirect_to by_officer_admin_poll_officer_assignments_path(poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id), notice: notice
redirect_params = { poll_id: @officer_assignment.poll_id, officer_id: @officer_assignment.officer_id }
redirect_to by_officer_admin_poll_officer_assignments_path(redirect_params), notice: notice
end
private
@@ -68,7 +72,8 @@ class Admin::Poll::OfficerAssignmentsController < Admin::BaseController
end
def load_booth_assignment
@booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(poll_id: create_params[:poll_id], booth_id: create_params[:booth_id])
find_params = { poll_id: create_params[:poll_id], booth_id: create_params[:booth_id] }
@booth_assignment = ::Poll::BoothAssignment.includes(:poll).find_by(find_params)
end
def load_poll

View File

@@ -7,7 +7,9 @@ class Admin::SpendingProposalsController < Admin::BaseController
load_and_authorize_resource
def index
@spending_proposals = SpendingProposal.scoped_filter(params, @current_filter).order(cached_votes_up: :desc, created_at: :desc).page(params[:page])
@spending_proposals = SpendingProposal.scoped_filter(params, @current_filter)
.order(cached_votes_up: :desc, created_at: :desc)
.page(params[:page])
end
def show
@@ -33,13 +35,15 @@ class Admin::SpendingProposalsController < Admin::BaseController
def summary
@spending_proposals = SpendingProposal.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
@spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price).sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
@spending_proposals_with_supports = SpendingProposal.with_supports.group(:geozone).sum(:price)
.sort_by{|geozone, count| geozone.present? ? geozone.name : "z"}
end
private
def spending_proposal_params
params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :administrator_id, :tag_list, valuator_ids: [])
params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name,
:administrator_id, :tag_list, valuator_ids: [])
end
def load_admins

View File

@@ -28,7 +28,8 @@ module Budgets
respond_to :html, :js
def index
@investments = @investments.apply_filters_and_search(@budget, params, @current_filter).send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render
@investments = @investments.apply_filters_and_search(@budget, params, @current_filter)
.send("sort_by_#{@current_order}").page(params[:page]).per(10).for_render
@investment_ids = @investments.pluck(:id)
load_investment_votes(@investments)
@tag_cloud = tag_cloud
@@ -102,7 +103,8 @@ module Budgets
end
def investment_params
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list, :organization_name, :location, :terms_of_service)
params.require(:budget_investment).permit(:title, :description, :external_url, :heading_id, :tag_list,
:organization_name, :location, :terms_of_service)
end
def load_ballot

View File

@@ -88,7 +88,8 @@ module CommentableActions
end
def set_geozone
@resource.geozone = Geozone.find(params[resource_name.to_sym].try(:[], :geozone_id)) if params[resource_name.to_sym].try(:[], :geozone_id).present?
geozone_id = params[resource_name.to_sym].try(:[], :geozone_id)
@resource.geozone = Geozone.find(geozone_id) if geozone_id.present?
end
def load_categories

View File

@@ -102,8 +102,9 @@ class Legislation::AnnotationsController < ApplicationController
end
def convert_ranges_parameters
if params[:legislation_annotation] && params[:legislation_annotation][:ranges] && params[:legislation_annotation][:ranges].is_a?(String)
params[:legislation_annotation][:ranges] = JSON.parse(params[:legislation_annotation][:ranges])
annotation = params[:legislation_annotation]
if annotation && annotation[:ranges] && annotation[:ranges].is_a?(String)
params[:legislation_annotation][:ranges] = JSON.parse(annotation[:ranges])
end
rescue JSON::ParserError
end

View File

@@ -18,9 +18,10 @@ class Legislation::AnswersController < Legislation::BaseController
format.html { redirect_to legislation_process_question_path(@process, @question) }
end
else
alert = t('legislation.questions.participation.phase_not_open')
respond_to do |format|
format.js { render json: {}, status: :not_found }
format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') }
format.html { redirect_to legislation_process_question_path(@process, @question), alert: alert }
end
end
end

View File

@@ -43,7 +43,8 @@ class Management::DocumentVerificationsController < Management::BaseController
end
def clean_document_number
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank?
return if params[:document_verification][:document_number].blank?
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase
end
end

View File

@@ -34,7 +34,8 @@ class Management::ProposalsController < Management::BaseController
end
def proposal_params
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id)
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
:responsible_name, :tag_list, :terms_of_service, :geozone_id)
end
def resource_model

View File

@@ -17,7 +17,8 @@ class Management::SpendingProposalsController < Management::BaseController
@spending_proposal.author = managed_user
if @spending_proposal.save
redirect_to management_spending_proposal_path(@spending_proposal), notice: t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1))
notice = t('flash.actions.create.notice', resource_name: t("activerecord.models.spending_proposal", count: 1))
redirect_to management_spending_proposal_path(@spending_proposal), notice: notice
else
render :new
end

View File

@@ -15,7 +15,8 @@ class Officing::FinalRecountsController < Officing::BaseController
end
def create
@final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: final_recount_params[:date])
@final_recount = ::Poll::FinalRecount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
date: final_recount_params[:date])
@final_recount.officer_assignment_id = @officer_assignment.id
@final_recount.count = final_recount_params[:count]

View File

@@ -14,7 +14,8 @@ class Officing::RecountsController < Officing::BaseController
end
def create
@recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id, date: @officer_assignment.date)
@recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
date: @officer_assignment.date)
@recount.officer_assignment_id = @officer_assignment.id
@recount.count = recount_params[:count]

View File

@@ -126,7 +126,8 @@ class Officing::ResultsController < Officing::BaseController
def load_partial_results
if @officer_assignments.present?
@partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id)).order(:booth_assignment_id, :date)
@partial_results = ::Poll::PartialResult.where(officer_assignment_id: @officer_assignments.map(&:id))
.order(:booth_assignment_id, :date)
end
end

View File

@@ -32,7 +32,8 @@ class Organizations::RegistrationsController < Devise::RegistrationsController
private
def sign_up_params
params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service, organization_attributes: [:name, :responsible_name])
params.require(:user).permit(:email, :password, :phone_number, :password_confirmation, :terms_of_service,
organization_attributes: [:name, :responsible_name])
end
end

View File

@@ -74,7 +74,8 @@ class ProposalsController < ApplicationController
private
def proposal_params
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url, :responsible_name, :tag_list, :terms_of_service, :geozone_id)
params.require(:proposal).permit(:title, :question, :summary, :description, :external_url, :video_url,
:responsible_name, :tag_list, :terms_of_service, :geozone_id)
end
def retired_params
@@ -109,7 +110,8 @@ class ProposalsController < ApplicationController
end
def load_featured
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3) if (!@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?)
return unless !@advanced_search_terms && @search_terms.blank? && @tag_filter.blank? && params[:retired].blank?
@featured_proposals = Proposal.not_archived.sort_by_confidence_score.limit(3)
if @featured_proposals.present?
set_featured_proposal_votes(@featured_proposals)
@resources = @resources.where('proposals.id NOT IN (?)', @featured_proposals.map(&:id))

View File

@@ -30,7 +30,8 @@ class SpendingProposalsController < ApplicationController
@spending_proposal.author = current_user
if @spending_proposal.save
notice = t('flash.actions.create.spending_proposal', activity: "<a href='#{user_path(current_user, filter: :spending_proposals)}'>#{t('layouts.header.my_activity_link')}</a>")
activity = "<a href='#{user_path(current_user, filter: :spending_proposals)}'>#{t('layouts.header.my_activity_link')}</a>"
notice = t('flash.actions.create.spending_proposal', activity: activity)
redirect_to @spending_proposal, notice: notice, flash: { html_safe: true }
else
render :new

View File

@@ -12,11 +12,13 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
def index
@heading_filters = heading_filters
if current_user.valuator? && @budget.present?
@investments = @budget.investments.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page])
else
@investments = Budget::Investment.none.page(params[:page])
end
@investments = if current_user.valuator? && @budget.present?
@budget.investments.scoped_filter(params_for_current_valuator, @current_filter)
.order(cached_votes_up: :desc)
.page(params[:page])
else
Budget::Investment.none.page(params[:page])
end
end
def valuate
@@ -63,11 +65,14 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
end
def valuation_params
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation, :duration, :valuation_finished, :internal_comments)
params.require(:budget_investment).permit(:price, :price_first_year, :price_explanation, :feasibility, :unfeasibility_explanation,
:duration, :valuation_finished, :internal_comments)
end
def restrict_access_to_assigned_items
raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id)
return if current_user.administrator? ||
Budget::ValuatorAssignment.exists?(investment_id: params[:id], valuator_id: current_user.valuator.id)
raise ActionController::RoutingError.new('Not Found')
end
def valid_price_params?

View File

@@ -10,11 +10,13 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
def index
@geozone_filters = geozone_filters
if current_user.valuator?
@spending_proposals = SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter).order(cached_votes_up: :desc).page(params[:page])
else
@spending_proposals = SpendingProposal.none.page(params[:page])
end
@spending_proposals = if current_user.valuator?
SpendingProposal.scoped_filter(params_for_current_valuator, @current_filter)
.order(cached_votes_up: :desc)
.page(params[:page])
else
SpendingProposal.none.page(params[:page])
end
end
def valuate
@@ -54,7 +56,8 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
def valuation_params
params[:spending_proposal][:feasible] = nil if params[:spending_proposal][:feasible] == 'nil'
params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation, :time_scope, :valuation_finished, :internal_comments)
params.require(:spending_proposal).permit(:price, :price_first_year, :price_explanation, :feasible, :feasible_explanation,
:time_scope, :valuation_finished, :internal_comments)
end
def params_for_current_valuator
@@ -62,7 +65,9 @@ class Valuation::SpendingProposalsController < Valuation::BaseController
end
def restrict_access_to_assigned_items
raise ActionController::RoutingError.new('Not Found') unless current_user.administrator? || ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id)
return if current_user.administrator? ||
ValuationAssignment.exists?(spending_proposal_id: params[:id], valuator_id: current_user.valuator.id)
raise ActionController::RoutingError.new('Not Found')
end
def valid_price_params?

View File

@@ -78,7 +78,9 @@ module CommentsHelper
def require_verified_resident_for_commentable?(commentable, current_user)
return false if current_user.administrator? || current_user.moderator?
commentable.respond_to?(:comments_for_verified_residents_only?) && commentable.comments_for_verified_residents_only? && !current_user.residence_verified?
commentable.respond_to?(:comments_for_verified_residents_only?) &&
commentable.comments_for_verified_residents_only? &&
!current_user.residence_verified?
end
def comments_closed_for_commentable?(commentable)

View File

@@ -2,7 +2,9 @@ module ValuationHelper
def valuator_select_options(valuator = nil)
if valuator.present?
Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }.prepend([valuator.description_or_email, valuator.id])
Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC")
.includes(:user).collect { |v| [ v.description_or_email, v.id ] }
.prepend([valuator.description_or_email, valuator.id])
else
Valuator.all.order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }
end

View File

@@ -11,7 +11,8 @@ class Mailer < ApplicationMailer
@email_to = @commentable.author.email
with_user(@commentable.author) do
mail(to: @email_to, subject: t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)) if @commentable.present? && @commentable.author.present?
subject = t('mailers.comment.subject', commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)
mail(to: @email_to, subject: subject) if @commentable.present? && @commentable.author.present?
end
end

View File

@@ -32,7 +32,8 @@ module Abilities
can :mark_featured, Debate
can :unmark_featured, Debate
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment, Legislation::Question, Legislation::Annotation]
can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment,
Legislation::Question, Legislation::Annotation]
can [:search, :create, :index, :destroy], ::Administrator
can [:search, :create, :index, :destroy], ::Moderator

View File

@@ -5,7 +5,8 @@ module Abilities
def initialize(user)
merge Abilities::Moderation.new(user)
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question, Legislation::Question, Legislation::Annotation]
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question,
Legislation::Question, Legislation::Annotation]
end
end
end

View File

@@ -22,7 +22,8 @@ class Budget
end
def check_valid_heading
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(heading)
return if ballot.valid_heading?(heading)
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected")
end
def check_selected

View File

@@ -205,7 +205,7 @@ class Budget
end
def recalculate_heading_winners
Budget::Result.new(budget, heading).calculate_winners if incompatible_changed? && winner? && incompatible?
Budget::Result.new(budget, heading).calculate_winners if incompatible_changed?
end
def set_responsible_name

View File

@@ -15,7 +15,6 @@ class Budget
set_winner if inside_budget?
end
end
handle_asynchronously :calculate_winners
def investments
heading.investments.selected.sort_by_ballots

View File

@@ -3,6 +3,8 @@ class Comment < ActiveRecord::Base
include HasPublicAuthor
include Graphqlable
COMMENTABLE_TYPES = %w(Debate Proposal Budget::Investment Poll::Question Legislation::Question Legislation::Annotation).freeze
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases
acts_as_votable
@@ -13,7 +15,7 @@ class Comment < ActiveRecord::Base
validates :body, presence: true
validates :user, presence: true
validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] }
validates :commentable_type, inclusion: { in: COMMENTABLE_TYPES }
validate :validate_body_length

View File

@@ -2,8 +2,10 @@ class Legislation::Answer < ActiveRecord::Base
acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases
belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id', inverse_of: :answers, counter_cache: true
belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id', inverse_of: :answers, counter_cache: true
belongs_to :question, class_name: 'Legislation::Question', foreign_key: 'legislation_question_id',
inverse_of: :answers, counter_cache: true
belongs_to :question_option, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_option_id',
inverse_of: :answers, counter_cache: true
belongs_to :user, dependent: :destroy, inverse_of: :legislation_answers
validates :question, presence: true, uniqueness: { scope: :user_id}

View File

@@ -4,8 +4,10 @@ class Legislation::Process < ActiveRecord::Base
PHASES_AND_PUBLICATIONS = %i(debate_phase allegations_phase draft_publication result_publication).freeze
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id', dependent: :destroy
has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion', foreign_key: 'legislation_process_id'
has_many :draft_versions, -> { order(:id) }, class_name: 'Legislation::DraftVersion',
foreign_key: 'legislation_process_id', dependent: :destroy
has_one :final_draft_version, -> { where final_version: true, status: 'published' }, class_name: 'Legislation::DraftVersion',
foreign_key: 'legislation_process_id'
has_many :questions, -> { order(:id) }, class_name: 'Legislation::Question', foreign_key: 'legislation_process_id', dependent: :destroy
validates :title, presence: true
@@ -64,7 +66,9 @@ class Legislation::Process < ActiveRecord::Base
def valid_date_ranges
errors.add(:end_date, :invalid_date_range) if end_date && start_date && end_date < start_date
errors.add(:debate_end_date, :invalid_date_range) if debate_end_date && debate_start_date && debate_end_date < debate_start_date
errors.add(:allegations_end_date, :invalid_date_range) if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date
if allegations_end_date && allegations_start_date && allegations_end_date < allegations_start_date
errors.add(:allegations_end_date, :invalid_date_range)
end
end
end

View File

@@ -5,7 +5,8 @@ class Legislation::Question < ActiveRecord::Base
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
belongs_to :process, class_name: 'Legislation::Process', foreign_key: 'legislation_process_id'
has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question
has_many :question_options, -> { order(:id) }, class_name: 'Legislation::QuestionOption', foreign_key: 'legislation_question_id',
dependent: :destroy, inverse_of: :question
has_many :answers, class_name: 'Legislation::Answer', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question
has_many :comments, as: :commentable, dependent: :destroy

View File

@@ -35,7 +35,11 @@ class Organization < ActiveRecord::Base
end
def self.search(text)
text.present? ? joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%") : none
if text.present?
joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%")
else
none
end
end
def self.name_max_length

View File

@@ -14,8 +14,10 @@ class ProposalNotification < ActiveRecord::Base
def minimum_interval
return true if proposal.try(:notifications).blank?
if proposal.notifications.last.created_at > (Time.current - Setting[:proposal_notification_minimum_interval_in_days].to_i.days).to_datetime
errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: Setting[:proposal_notification_minimum_interval_in_days]))
interval = Setting[:proposal_notification_minimum_interval_in_days]
minimum_interval = (Time.current - interval.to_i.days).to_datetime
if proposal.notifications.last.created_at > minimum_interval
errors.add(:title, I18n.t('activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid', interval: interval))
end
end

View File

@@ -38,8 +38,8 @@ class Verification::Residence
end
def allowed_age
return if errors[:date_of_birth].any?
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless Age.in_years(date_of_birth) >= User.minimum_required_age
return if errors[:date_of_birth].any? || Age.in_years(date_of_birth) >= User.minimum_required_age
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age'))
end
def document_number_uniqueness

View File

@@ -63,6 +63,7 @@
<div class="row margin-top">
<% if @investment.incompatible? || @investment.winner? %>
<div class="small-12 medium-3 column">
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
<%= f.label :incompatible do %>
@@ -70,6 +71,7 @@
<span class="checkbox"><%= t("admin.budget_investments.edit.mark_as_incompatible") %></span>
<% end %>
</div>
<% end %>
<div class="small-12 medium-3 column float-left">
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
<%= f.label :selected do %>

View File

@@ -13,7 +13,7 @@
<div class="milestone-content">
<h3><%= milestone.title %></h3>
<span class="milestone-date">
<strong><%= t("budgets.investments.show.milestone_publish_date", publish_date: milestone.created_at.strftime("%d/%m/%Y")) %></strong>
<strong><%= t("budgets.investments.show.milestone_publish_date", publish_date: l(milestone.created_at.to_date)) %></strong>
</span>
<p><%= milestone.description %></p>
</div>

View File

@@ -1,4 +1,6 @@
<div class="small-12 medium-9 column <%= results_type == :compatible ? 'success' : 'js-discarded' %>" id="<%= results_type %>-container">
<div class="small-12 medium-9 column <%= results_type == :compatible ? 'success' : 'js-discarded' %>"
style="<%= results_type != :compatible ? 'display: none' : '' %>"
id="<%= results_type %>-container">
<h3 class="inline-block">
<%= title %>
@@ -28,7 +30,9 @@
<tbody>
<% amount_available = heading_price %>
<% investments.each do |investment| %>
<tr id="<%= dom_id(investment) %>" class="budget-investments <%= investment.winner? ? 'success' : 'js-discarded' %>">
<tr id="<%= dom_id(investment) %>"
class="budget-investments <%= investment.winner? ? 'success' : 'js-discarded' %>"
style="<%= investment.winner? ? '' : 'display: none' %>">
<td>
<% if investment.winner? %>
<span class="icon-check">

View File

@@ -26,7 +26,8 @@
</li>
<% @budget.headings.each do |heading| %>
<li>
<% active_class = heading.id.to_s == params[:heading_id] ? 'bold' : '' %>
<li class="<%= active_class %>">
<%= link_to heading.name,
budget_results_path(@budget, heading_id: heading.id) %>
</li>
@@ -34,7 +35,7 @@
</ul>
</div>
<span class="float-right"><%= link_to t("budgets.results.hide_discarded_link"), "#", class: "js-toggle-link button hollow margin-bottom", data: {'toggle-selector' => '.js-discarded', 'toggle-text' => t("budgets.results.show_all_link")} %></span>
<span class="float-right"><%= link_to t("budgets.results.show_all_link"), "#", class: "js-toggle-link button hollow margin-bottom", data: {'toggle-selector' => '.js-discarded', 'toggle-text' => t("budgets.results.hide_discarded_link")} %></span>
<%= render 'results_table', results_type: :compatible,
@@ -42,8 +43,10 @@
heading_price: @heading.price,
investments: @investments.compatible %>
<%= render 'results_table', results_type: :incompatible,
title: t("budgets.results.incompatibles"),
heading_price: @heading.price,
investments: @investments.incompatible %>
<% if @investments.incompatible.present? %>
<%= render 'results_table', results_type: :incompatible,
title: t("budgets.results.incompatibles"),
heading_price: @heading.price,
investments: @investments.incompatible %>
<% end %>
</div>

View File

@@ -1,25 +0,0 @@
# encoding: utf-8
# Tolk config file. Generated on January 14, 2016 12:09
# See github.com/tolk/tolk for more informations
Tolk.config do |config|
# If you need to add a mapping do it like this :
# May we suggest you use http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
# config.mapping['en-AU'] = 'English (Australia)'
# config.mapping['es-MX'] = 'Spanish (Mexico)'
# config.mapping['fr-ES'] = 'Frañol !'
# config.mapping['is'] = 'Icelandic'
# config.mapping['vi'] = 'Vietnamese'
# Master source of strings to be translated
config.primary_locale_name = 'en'
end
Tolk::ApplicationController.authenticator = proc {
authenticate_or_request_with_http_basic do |username, password|
username == Rails.application.secrets.translate_username &&
password == Rails.application.secrets.translate_password
end
}

View File

@@ -72,7 +72,7 @@ en:
follow_link: "Participatory Budgets"
sincerely: "Sincerely,"
signatory: "DEPARTMENT OF PUBLIC PARTICIPATION"
share: "Comparte tu proyecto"
share: "Share your project"
budget_investment_unfeasible:
hi: "Dear user,"
new_html: "For all these, we invite you to elaborate a <strong>new investment</strong> that ajusts to the conditions of this process. You can do it following this link: %{url}."

View File

@@ -39,7 +39,7 @@ en:
feature_3_html: "Then there is a <strong>support phase</strong> to prioritize the most interesting, the most supported are evaluated by the City to see if they are viable and how much they are worth."
feature_4_html: "At the end there is a <strong>vote phase </strong> and you decide which of the approved projects to spend the budget on."
image_alt: "Different phases of a participatory budget"
figcaption_html: '"Support phase" and "Voting" phase of participatory budgets.'
figcaption_html: '"Support" and "Voting" phases of participatory budgets.'
polls:
title: "Polls"
description: "Citizen proposals that reach 1% of support will be put to a vote."

View File

@@ -87,7 +87,7 @@ en:
back: Back
heading: Investment project
info: Author info
association_name: Asociación
association_name: Association
by: Sent by
sent: Sent at
geozone: Scope

View File

@@ -418,7 +418,6 @@ Rails.application.routes.draw do
end
mount GraphiQL::Rails::Engine, at: '/graphiql', graphql_path: '/graphql'
mount Tolk::Engine => '/translate', :as => 'tolk'
# more info pages
get 'more-information', to: 'pages#show', id: 'more_info/index', as: 'more_info'

View File

@@ -33,9 +33,6 @@ production: &production
google_oauth2_key: ""
google_oauth2_secret: ""
translate_username: ""
translate_password: ""
rollbar_server_token: ""
server_name: ""

View File

@@ -384,12 +384,12 @@ Budget::PHASES.each_with_index do |phase, i|
)
)
(1..([1, 2, 3].sample)).each do
group = budget.groups.create!(name: Faker::StarWars.planet)
(1..([1, 2, 3].sample)).each do |i|
group = budget.groups.create!(name: "#{Faker::StarWars.planet} #{i}")
geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample)
geozones.each do |geozone|
group.headings << group.headings.create!(name: geozone.name,
group.headings << group.headings.create!(name: "#{geozone.name} #{i}",
price: rand(1..100) * 100000,
population: rand(1..50) * 10000)
end

View File

@@ -0,0 +1,10 @@
class RemoveTolk < ActiveRecord::Migration
def change
remove_index :tolk_translations, column: [:phrase_id, :locale_id]
remove_index :tolk_locales, column: :name
drop_table :tolk_translations
drop_table :tolk_phrases
drop_table :tolk_locales
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170704105112) do
ActiveRecord::Schema.define(version: 20170708225159) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -871,32 +871,6 @@ ActiveRecord::Schema.define(version: 20170704105112) do
add_index "tags", ["proposals_count"], name: "index_tags_on_proposals_count", using: :btree
add_index "tags", ["spending_proposals_count"], name: "index_tags_on_spending_proposals_count", using: :btree
create_table "tolk_locales", force: :cascade do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "tolk_locales", ["name"], name: "index_tolk_locales_on_name", unique: true, using: :btree
create_table "tolk_phrases", force: :cascade do |t|
t.text "key"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "tolk_translations", force: :cascade do |t|
t.integer "phrase_id"
t.integer "locale_id"
t.text "text"
t.text "previous_text"
t.boolean "primary_updated", default: false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "tolk_translations", ["phrase_id", "locale_id"], name: "index_tolk_translations_on_phrase_id_and_locale_id", unique: true, using: :btree
create_table "users", force: :cascade do |t|
t.string "email", default: ""
t.string "encrypted_password", default: "", null: false

View File

@@ -92,7 +92,27 @@ class CensusApi
end
def stubbed_valid_response
{get_habita_datos_response: {get_habita_datos_return: {datos_habitante: { item: {fecha_nacimiento_string: "31-12-1980", identificador_documento: "12345678Z", descripcion_sexo: "Varón", nombre: "José", apellido1: "García" }}, datos_vivienda: {item: {codigo_postal: "28013", codigo_distrito: "01"}}}}}
{
get_habita_datos_response: {
get_habita_datos_return: {
datos_habitante: {
item: {
fecha_nacimiento_string: "31-12-1980",
identificador_documento: "12345678Z",
descripcion_sexo: "Varón",
nombre: "José",
apellido1: "García"
}
},
datos_vivienda: {
item: {
codigo_postal: "28013",
codigo_distrito: "01"
}
}
}
}
}
end
def stubbed_invalid_response

View File

@@ -13,7 +13,8 @@ describe Legislation::AnswersController do
it 'should create an ahoy event' do
sign_in @user
post :create, process_id: @process.id, question_id: @question.id, legislation_answer: { legislation_question_option_id: @question_option.id }
post :create, process_id: @process.id, question_id: @question.id,
legislation_answer: { legislation_question_option_id: @question_option.id }
expect(Ahoy::Event.where(name: :legislation_answer_created).count).to eq 1
expect(Ahoy::Event.last.properties['legislation_answer_id']).to eq Legislation::Answer.last.id
end
@@ -22,7 +23,8 @@ describe Legislation::AnswersController do
sign_in @user
expect do
xhr :post, :create, process_id: @process.id, question_id: @question.id, legislation_answer: { legislation_question_option_id: @question_option.id }
xhr :post, :create, process_id: @process.id, question_id: @question.id,
legislation_answer: { legislation_question_option_id: @question_option.id }
end.to change { @question.reload.answers_count }.by(1)
end
@@ -31,7 +33,8 @@ describe Legislation::AnswersController do
@process.update_attribute(:debate_end_date, Date.current - 1.day)
expect do
xhr :post, :create, process_id: @process.id, question_id: @question.id, legislation_answer: { legislation_question_option_id: @question_option.id }
xhr :post, :create, process_id: @process.id, question_id: @question.id,
legislation_answer: { legislation_question_option_id: @question_option.id }
end.to_not change { @question.reload.answers_count }
end
end

View File

@@ -312,7 +312,7 @@ feature 'Admin budget investments' do
context "Edit" do
scenario "Change title, incompatible, description or heading" do
budget_investment = create(:budget_investment, :selected)
budget_investment = create(:budget_investment, :incompatible)
create(:budget_heading, group: budget_investment.group, name: "Barbate")
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
@@ -321,7 +321,7 @@ feature 'Admin budget investments' do
fill_in 'budget_investment_title', with: 'Potatoes'
fill_in 'budget_investment_description', with: 'Carrots'
select "#{budget_investment.group.name}: Barbate", from: 'budget_investment[heading_id]'
check "budget_investment_incompatible"
uncheck "budget_investment_incompatible"
check "budget_investment_selected"
click_button 'Update'
@@ -329,10 +329,21 @@ feature 'Admin budget investments' do
expect(page).to have_content 'Potatoes'
expect(page).to have_content 'Carrots'
expect(page).to have_content 'Barbate'
expect(page).to have_content 'Incompatible'
expect(page).to have_content 'Compatibility: Compatible'
expect(page).to have_content 'Selected'
end
scenario "Compatible non-winner can't edit incompatibility" do
budget_investment = create(:budget_investment, :selected)
create(:budget_heading, group: budget_investment.group, name: "Tetuan")
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
click_link 'Edit'
expect(page).not_to have_content 'Compatibility'
expect(page).not_to have_content 'Mark as incompatible'
end
scenario "Add administrator" do
budget_investment = create(:budget_investment)
administrator = create(:administrator, user: create(:user, username: 'Marta', email: 'marta@admins.org'))

View File

@@ -33,8 +33,10 @@ feature 'Admin poll questions' do
poll = create(:poll, name: 'Movies')
title = "Star Wars: Episode IV - A New Hope"
description = %{
During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet.
Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy....
During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station
with enough power to destroy an entire planet.
Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her
people and restore freedom to the galaxy....
}
visit admin_questions_path

View File

@@ -400,7 +400,8 @@ feature 'Budget Investments' do
scenario "Show milestones", :js do
user = create(:user)
investment = create(:budget_investment)
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show")
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show",
created_at: DateTime.new(2015, 9, 19).utc)
login_as(user)
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
@@ -410,7 +411,7 @@ feature 'Budget Investments' do
within("#tab-milestones") do
expect(page).to have_content(milestone.title)
expect(page).to have_content(milestone.description)
expect(page).to have_content("Published #{milestone.created_at.strftime("%d/%m/%Y")}")
expect(page).to have_content("Published 2015-09-19")
end
end
@@ -602,9 +603,9 @@ feature 'Budget Investments' do
end
scenario 'Order by cost (only when balloting)' do
create(:budget_investment, :selected, heading: heading, title: 'Build a nice house', price: 1000).update_column(:confidence_score, 10)
create(:budget_investment, :selected, heading: heading, title: 'Build an ugly house', price: 1000).update_column(:confidence_score, 5)
create(:budget_investment, :selected, heading: heading, title: 'Build a skyscraper', price: 20000)
create(:budget_investment, :selected, heading: heading, title: 'Build a nice house', price: 1000).update_column(:confidence_score, 10)
create(:budget_investment, :selected, heading: heading, title: 'Build an ugly house', price: 1000).update_column(:confidence_score, 5)
create(:budget_investment, :selected, heading: heading, title: 'Build a skyscraper', price: 20000)
visit budget_investments_path(budget, heading_id: heading.id)

View File

@@ -17,6 +17,21 @@ feature 'Results' do
visit budget_path(budget)
click_link "See results"
within("#budget-investments-compatible") do
expect(page).to have_content investment1.title
expect(page).to have_content investment2.title
expect(page).not_to have_content investment3.title
expect(page).not_to have_content investment4.title
expect(investment1.title).to appear_before(investment2.title)
end
end
scenario "Show non winner & incomaptible investments", :js do
visit budget_path(budget)
click_link "See results"
click_link "Show all"
within("#budget-investments-compatible") do
expect(page).to have_content investment1.title
expect(page).to have_content investment2.title
@@ -31,21 +46,6 @@ feature 'Results' do
end
end
scenario "Displays non winner investments", :js do
visit budget_path(budget)
click_link "See results"
click_link "Hide discarded"
within("#budget-investments-compatible") do
expect(page).to have_content investment1.title
expect(page).to have_content investment2.title
expect(page).not_to have_content investment3.title
expect(page).not_to have_content investment4.title
expect(investment1.title).to appear_before(investment2.title)
end
end
scenario "If budget is in a phase different from finished results can't be accessed" do
budget.update phase: (Budget::PHASES - ["finished"]).sample
visit budget_path(budget)
@@ -55,4 +55,14 @@ feature 'Results' do
expect(page).to have_content "You do not have permission to carry out the action"
end
scenario "No incompatible investments", :js do
investment3.incompatible = false
investment3.save
visit budget_path(budget)
click_link "See results"
expect(page).not_to have_content "Incompatibles"
end
end

View File

@@ -62,9 +62,12 @@ feature 'Commenting Budget::Investments' do
end
scenario 'Comment order' do
c1 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 100, cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 10, cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 1, cached_votes_total: 2, created_at: Time.current)
c1 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 10,
cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 1,
cached_votes_total: 2, created_at: Time.current)
visit budget_investment_path(investment.budget, investment, order: :most_voted)
@@ -118,7 +121,8 @@ feature 'Commenting Budget::Investments' do
end
scenario 'Sanitizes comment body for security' do
create :comment, commentable: investment, body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
create :comment, commentable: investment,
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
visit budget_investment_path(investment.budget, investment)

View File

@@ -62,9 +62,12 @@ feature 'Commenting debates' do
end
scenario 'Comment order' do
c1 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 100, cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 10, cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 1, cached_votes_total: 2, created_at: Time.current)
c1 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 10,
cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 1,
cached_votes_total: 2, created_at: Time.current)
visit debate_path(debate, order: :most_voted)
@@ -118,7 +121,8 @@ feature 'Commenting debates' do
end
scenario 'Sanitizes comment body for security' do
create :comment, commentable: debate, body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
create :comment, commentable: debate,
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
visit debate_path(debate)

View File

@@ -8,7 +8,9 @@ feature 'Commenting legislation questions' do
scenario 'Index' do
3.times { create(:comment, commentable: legislation_annotation) }
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to have_css('.comment', count: 4)
@@ -24,6 +26,9 @@ feature 'Commenting legislation questions' do
parent_comment = create(:comment, commentable: legislation_annotation)
first_child = create(:comment, commentable: legislation_annotation, parent: parent_comment)
second_child = create(:comment, commentable: legislation_annotation, parent: parent_comment)
href = legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
visit comment_path(parent_comment)
@@ -32,7 +37,7 @@ feature 'Commenting legislation questions' do
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_link "Go back to #{legislation_annotation.title}", href: legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
expect(page).to have_link "Go back to #{legislation_annotation.title}", href: href
end
scenario 'Collapsable comments', :js do
@@ -40,7 +45,9 @@ feature 'Commenting legislation questions' do
child_comment = create(:comment, body: "First subcomment", commentable: legislation_annotation, parent: parent_comment)
grandchild_comment = create(:comment, body: "Last subcomment", commentable: legislation_annotation, parent: child_comment)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to have_css('.comment', count: 3)
@@ -62,21 +69,33 @@ feature 'Commenting legislation questions' do
end
scenario 'Comment order' do
c1 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 100, cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 10, cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 1, cached_votes_total: 2, created_at: Time.current)
c1 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 10,
cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 1,
cached_votes_total: 2, created_at: Time.current)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation, order: :most_voted)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation,
order: :most_voted)
expect(c1.body).to appear_before(c2.body)
expect(c2.body).to appear_before(c3.body)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation, order: :newest)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation,
order: :newest)
expect(c3.body).to appear_before(c2.body)
expect(c2.body).to appear_before(c1.body)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation, order: :oldest)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation,
order: :oldest)
expect(c1.body).to appear_before(c2.body)
expect(c2.body).to appear_before(c3.body)
@@ -88,17 +107,26 @@ feature 'Commenting legislation questions' do
old_child = create(:comment, commentable: legislation_annotation, parent_id: new_root.id, created_at: Time.current - 10)
new_child = create(:comment, commentable: legislation_annotation, parent_id: new_root.id, created_at: Time.current)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation, order: :most_voted)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation,
order: :most_voted)
expect(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.body)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation, order: :newest)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation,
order: :newest)
expect(new_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.body)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation, order: :oldest)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation,
order: :oldest)
expect(old_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body)
@@ -107,7 +135,9 @@ feature 'Commenting legislation questions' do
scenario 'Turns links into html links' do
create :comment, commentable: legislation_annotation, body: 'Built with http://rubyonrails.org/'
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within all('.comment').last do
expect(page).to have_content 'Built with http://rubyonrails.org/'
@@ -118,9 +148,12 @@ feature 'Commenting legislation questions' do
end
scenario 'Sanitizes comment body for security' do
create :comment, commentable: legislation_annotation, body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
create :comment, commentable: legislation_annotation,
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within all('.comment').last do
expect(page).to have_content "click me http://www.url.com"
@@ -133,7 +166,9 @@ feature 'Commenting legislation questions' do
per_page = 10
(per_page + 2).times { create(:comment, commentable: legislation_annotation)}
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to have_css('.comment', count: per_page)
within("ul.pagination") do
@@ -149,7 +184,9 @@ feature 'Commenting legislation questions' do
feature 'Not logged user' do
scenario 'can not see comments forms' do
create(:comment, commentable: legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
within('#comments') do
@@ -161,7 +198,9 @@ feature 'Commenting legislation questions' do
scenario 'Create', :js do
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: 'Have you thought about...?'
click_button 'Publish comment'
@@ -174,7 +213,9 @@ feature 'Commenting legislation questions' do
scenario 'Errors on create', :js do
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
click_button 'Publish comment'
@@ -188,7 +229,9 @@ feature 'Commenting legislation questions' do
comment = legislation_annotation.comments.first
login_as(manuela)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
click_link "Reply"
@@ -208,7 +251,9 @@ feature 'Commenting legislation questions' do
comment = legislation_annotation.comments.first
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
click_link "Reply"
@@ -227,7 +272,10 @@ feature 'Commenting legislation questions' do
parent = parent.children.first
end
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
end
@@ -235,7 +283,9 @@ feature 'Commenting legislation questions' do
comment = create(:comment, commentable: legislation_annotation)
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within "#comment_#{comment.id}" do
page.find("#flag-expand-comment-#{comment.id}").click
@@ -252,7 +302,9 @@ feature 'Commenting legislation questions' do
Flag.flag(user, comment)
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within "#comment_#{comment.id}" do
page.find("#unflag-expand-comment-#{comment.id}").click
@@ -269,7 +321,9 @@ feature 'Commenting legislation questions' do
comment = create(:comment, commentable: legislation_annotation)
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within "#comment_#{comment.id}" do
page.find("#flag-expand-comment-#{comment.id}").click
@@ -282,7 +336,10 @@ feature 'Commenting legislation questions' do
comment = create(:comment, commentable: legislation_annotation, body: 'this should be visible')
comment.user.erase
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
within "#comment_#{comment.id}" do
expect(page).to have_content('User deleted')
expect(page).to have_content('this should be visible')
@@ -292,7 +349,10 @@ feature 'Commenting legislation questions' do
scenario 'Submit button is disabled after clicking', :js do
legislation_annotation = create(:legislation_annotation)
login_as(user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: 'Testing submit button!'
click_button 'Publish comment'
@@ -309,7 +369,9 @@ feature 'Commenting legislation questions' do
moderator = create(:moderator)
login_as(moderator.user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "I am moderating!"
check "comment-as-moderator-legislation_annotation_#{legislation_annotation.id}"
@@ -331,7 +393,9 @@ feature 'Commenting legislation questions' do
comment = legislation_annotation.comments.first
login_as(manuela)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
click_link "Reply"
@@ -355,7 +419,9 @@ feature 'Commenting legislation questions' do
moderator = create(:moderator)
login_as(moderator.user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to_not have_content "Comment as administrator"
end
@@ -366,7 +432,9 @@ feature 'Commenting legislation questions' do
admin = create(:administrator)
login_as(admin.user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "I am your Admin!"
check "comment-as-administrator-legislation_annotation_#{legislation_annotation.id}"
@@ -388,7 +456,9 @@ feature 'Commenting legislation questions' do
comment = legislation_annotation.comments.first
login_as(manuela)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
click_link "Reply"
@@ -412,7 +482,9 @@ feature 'Commenting legislation questions' do
admin = create(:administrator)
login_as(admin.user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
legislation_annotation.draft_version,
legislation_annotation)
expect(page).to_not have_content "Comment as moderator"
end
@@ -432,7 +504,9 @@ feature 'Commenting legislation questions' do
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process, @legislation_annotation.draft_version, @legislation_annotation)
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
@legislation_annotation.draft_version,
@legislation_annotation)
within("#comment_#{@comment.id}_votes") do
within(".in_favor") do
@@ -448,7 +522,9 @@ feature 'Commenting legislation questions' do
end
scenario 'Create', :js do
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process, @legislation_annotation.draft_version, @legislation_annotation)
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
@legislation_annotation.draft_version,
@legislation_annotation)
within("#comment_#{@comment.id}_votes") do
find(".in_favor a").click
@@ -466,7 +542,9 @@ feature 'Commenting legislation questions' do
end
scenario 'Update', :js do
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process, @legislation_annotation.draft_version, @legislation_annotation)
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
@legislation_annotation.draft_version,
@legislation_annotation)
within("#comment_#{@comment.id}_votes") do
find('.in_favor a').click
@@ -485,7 +563,9 @@ feature 'Commenting legislation questions' do
end
xscenario 'Trying to vote multiple times', :js do
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process, @legislation_annotation.draft_version, @legislation_annotation)
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
@legislation_annotation.draft_version,
@legislation_annotation)
within("#comment_#{@comment.id}_votes") do
find('.in_favor a').click
@@ -510,8 +590,14 @@ feature 'Commenting legislation questions' do
feature "Merged comment threads", :js do
let!(:draft_version) { create(:legislation_draft_version, :published) }
let!(:annotation1) { create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}]) }
let!(:annotation2) { create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}]) }
let!(:annotation1) do
create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}])
end
let!(:annotation2) do
create(:legislation_annotation, draft_version: draft_version, text: "my other annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}])
end
background do
login_as user

View File

@@ -25,6 +25,7 @@ feature 'Commenting legislation questions' do
parent_comment = create(:comment, commentable: legislation_question)
first_child = create(:comment, commentable: legislation_question, parent: parent_comment)
second_child = create(:comment, commentable: legislation_question, parent: parent_comment)
href = legislation_process_question_path(legislation_question.process, legislation_question)
visit comment_path(parent_comment)
@@ -33,7 +34,7 @@ feature 'Commenting legislation questions' do
expect(page).to have_content first_child.body
expect(page).to have_content second_child.body
expect(page).to have_link "Go back to #{legislation_question.title}", href: legislation_process_question_path(legislation_question.process, legislation_question)
expect(page).to have_link "Go back to #{legislation_question.title}", href: href
end
scenario 'Collapsable comments', :js do
@@ -63,9 +64,12 @@ feature 'Commenting legislation questions' do
end
scenario 'Comment order' do
c1 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 100, cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 10, cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 1, cached_votes_total: 2, created_at: Time.current)
c1 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 10,
cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 1,
cached_votes_total: 2, created_at: Time.current)
visit legislation_process_question_path(legislation_question.process, legislation_question, order: :most_voted)
@@ -119,7 +123,8 @@ feature 'Commenting legislation questions' do
end
scenario 'Sanitizes comment body for security' do
create :comment, commentable: legislation_question, body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
create :comment, commentable: legislation_question,
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
visit legislation_process_question_path(legislation_question.process, legislation_question)

View File

@@ -62,9 +62,12 @@ feature 'Commenting proposals' do
end
scenario 'Comment order' do
c1 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 100, cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 10, cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 1, cached_votes_total: 2, created_at: Time.current)
c1 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 100,
cached_votes_total: 120, created_at: Time.current - 2)
c2 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 10,
cached_votes_total: 12, created_at: Time.current - 1)
c3 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 1,
cached_votes_total: 2, created_at: Time.current)
visit proposal_path(proposal, order: :most_voted)
@@ -118,7 +121,8 @@ feature 'Commenting proposals' do
end
scenario 'Sanitizes comment body for security' do
create :comment, commentable: proposal, body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
create :comment, commentable: proposal,
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
visit proposal_path(proposal)

View File

@@ -189,11 +189,12 @@ feature 'Debates' do
scenario 'JS injection is prevented but autolinking is respected' do
author = create(:user)
js_injection_string = "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
login_as(author)
visit new_debate_path
fill_in 'debate_title', with: 'Testing auto link'
fill_in 'debate_description', with: "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
fill_in 'debate_description', with: js_injection_string
check 'debate_terms_of_service'
click_button 'Start a debate'

View File

@@ -77,8 +77,10 @@ feature 'Legacy Legislation' do
scenario 'Search' do
legacy_legislation = create(:legacy_legislation)
annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", ranges: [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}])
annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start" => "/div[1]", "startOffset" => 12, "end" => "/div[1]", "endOffset" => 19}])
annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation",
ranges: [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}])
annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation",
ranges: [{"start" => "/div[1]", "startOffset" => 12, "end" => "/div[1]", "endOffset" => 19}])
visit legacy_legislation_path(legacy_legislation)

View File

@@ -10,9 +10,12 @@ feature 'Legislation Draft Versions' do
context "See draft text page" do
before(:each) do
@process = create(:legislation_process)
@draft_version_1 = create(:legislation_draft_version, process: @process, title: "Version 1", body: "Body of the first version", status: "published")
@draft_version_2 = create(:legislation_draft_version, process: @process, title: "Version 2", body: "Body of the second version", status: "published")
@draft_version_3 = create(:legislation_draft_version, process: @process, title: "Version 3", body: "Body of the third version", status: "draft")
@draft_version_1 = create(:legislation_draft_version, process: @process, title: "Version 1",
body: "Body of the first version", status: "published")
@draft_version_2 = create(:legislation_draft_version, process: @process, title: "Version 2",
body: "Body of the second version", status: "published")
@draft_version_3 = create(:legislation_draft_version, process: @process, title: "Version 3",
body: "Body of the third version", status: "draft")
end
it "shows the text body for this version" do
@@ -64,7 +67,8 @@ feature 'Legislation Draft Versions' do
context "for final versions" do
it "does not show the comments panel" do
final_version = create(:legislation_draft_version, process: @process, title: "Final version", body: "Final body", status: "published", final_version: true)
final_version = create(:legislation_draft_version, process: @process, title: "Final version",
body: "Final body", status: "published", final_version: true)
visit legislation_process_draft_version_path(@process, final_version)
@@ -78,9 +82,12 @@ feature 'Legislation Draft Versions' do
context "See changes page" do
before(:each) do
@process = create(:legislation_process)
@draft_version_1 = create(:legislation_draft_version, process: @process, title: "Version 1", body: "Body of the first version", changelog: "Changes for first version", status: "published")
@draft_version_2 = create(:legislation_draft_version, process: @process, title: "Version 2", body: "Body of the second version", changelog: "Changes for second version", status: "published")
@draft_version_3 = create(:legislation_draft_version, process: @process, title: "Version 3", body: "Body of the third version", changelog: "Changes for third version", status: "draft")
@draft_version_1 = create(:legislation_draft_version, process: @process, title: "Version 1", body: "Body of the first version",
changelog: "Changes for first version", status: "published")
@draft_version_2 = create(:legislation_draft_version, process: @process, title: "Version 2", body: "Body of the second version",
changelog: "Changes for second version", status: "published")
@draft_version_3 = create(:legislation_draft_version, process: @process, title: "Version 3", body: "Body of the third version",
changelog: "Changes for third version", status: "draft")
end
it "shows the changes for this version" do
@@ -173,8 +180,10 @@ feature 'Legislation Draft Versions' do
scenario 'View annotations and comments' do
draft_version = create(:legislation_draft_version, :published)
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 5, "end" => "/p[1]", "endOffset" => 10}])
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 12, "end" => "/p[1]", "endOffset" => 19}])
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 5, "end" => "/p[1]", "endOffset" => 10}])
create(:legislation_annotation, draft_version: draft_version, text: "my other annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 12, "end" => "/p[1]", "endOffset" => 19}])
comment = create(:comment, commentable: annotation1)
visit legislation_process_draft_version_path(draft_version.process, draft_version)
@@ -190,7 +199,8 @@ feature 'Legislation Draft Versions' do
scenario "Publish new comment for an annotation from comments box" do
draft_version = create(:legislation_draft_version, :published)
annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
visit legislation_process_draft_version_path(draft_version.process, draft_version)
@@ -212,8 +222,10 @@ feature 'Legislation Draft Versions' do
scenario 'View annotations and comments in an included range' do
draft_version = create(:legislation_draft_version, :published)
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}])
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}])
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}])
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation",
ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}])
visit legislation_process_draft_version_path(draft_version.process, draft_version)
@@ -232,8 +244,10 @@ feature 'Legislation Draft Versions' do
context "Annotations page" do
background do
@draft_version = create(:legislation_draft_version, :published)
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
@annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}])
create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum",
ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam",
ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}])
end
scenario "See all annotations for a draft version" do
@@ -246,10 +260,14 @@ feature 'Legislation Draft Versions' do
context "switching versions" do
background do
@process = create(:legislation_process)
@draft_version_1 = create(:legislation_draft_version, :published, process: @process, title: "Version 1", body: "Text with quote for version 1")
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1", ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}])
@draft_version_2 = create(:legislation_draft_version, :published, process: @process, title: "Version 2", body: "Text with quote for version 2")
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2", ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}])
@draft_version_1 = create(:legislation_draft_version, :published, process: @process,
title: "Version 1", body: "Text with quote for version 1")
create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1",
ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}])
@draft_version_2 = create(:legislation_draft_version, :published, process: @process,
title: "Version 2", body: "Text with quote for version 2")
create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2",
ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}])
end
scenario "without js" do
@@ -278,12 +296,14 @@ feature 'Legislation Draft Versions' do
context "Annotation comments page" do
background do
@draft_version = create(:legislation_draft_version, :published)
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
@annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}])
create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum",
ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
@annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam",
ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}])
end
scenario "See one annotation with replies for a draft version" do
visit legislation_process_draft_version_annotation_path(@draft_version.process, @draft_version, @annotation_2)
visit legislation_process_draft_version_annotation_path(@draft_version.process, @draft_version, @annotation)
expect(page).to_not have_content "ipsum"
expect(page).to_not have_content "my annotation"

View File

@@ -84,13 +84,16 @@ feature 'Budget Investments' do
expect(page).to have_css('.budget-investment', count: 1)
expect(page).to have_content(budget_investment1.title)
expect(page).to_not have_content(budget_investment2.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']", text: budget_investment1.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']",
text: budget_investment1.title)
end
end
scenario "by heading" do
budget_investment1 = create(:budget_investment, budget: @budget, title: "Hey ho", heading: create(:budget_heading, name: "District 9"))
budget_investment2 = create(:budget_investment, budget: @budget, title: "Let's go", heading: create(:budget_heading, name: "Area 52"))
budget_investment1 = create(:budget_investment, budget: @budget, title: "Hey ho",
heading: create(:budget_heading, name: "District 9"))
budget_investment2 = create(:budget_investment, budget: @budget, title: "Let's go",
heading: create(:budget_heading, name: "Area 52"))
user = create(:user, :level_two)
login_managed_user(user)
@@ -108,7 +111,8 @@ feature 'Budget Investments' do
expect(page).to have_css('.budget-investment', count: 1)
expect(page).to_not have_content(budget_investment1.title)
expect(page).to have_content(budget_investment2.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']", text: budget_investment2.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']",
text: budget_investment2.title)
end
end
end
@@ -135,8 +139,10 @@ feature 'Budget Investments' do
within("#budget-investments") do
expect(page).to have_css('.budget-investment', count: 2)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']", text: budget_investment1.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']", text: budget_investment2.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment1)}']",
text: budget_investment1.title)
expect(page).to have_css("a[href='#{management_budget_investment_path(@budget, budget_investment2)}']",
text: budget_investment2.title)
end
end

View File

@@ -92,7 +92,8 @@ feature 'Proposal Notifications' do
scenario "Show notifications" do
proposal = create(:proposal)
notification1 = create(:proposal_notification, proposal: proposal, title: "Hey guys", body: "Just wanted to let you know that...")
notification2 = create(:proposal_notification, proposal: proposal, title: "Another update", body: "We are almost there please share with your peoples!")
notification2 = create(:proposal_notification, proposal: proposal, title: "Another update",
body: "We are almost there please share with your peoples!")
visit proposal_path(proposal)

View File

@@ -333,13 +333,14 @@ feature 'Proposals' do
scenario 'JS injection is prevented but autolinking is respected' do
author = create(:user)
js_injection_string = "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
login_as(author)
visit new_proposal_path
fill_in 'proposal_title', with: 'Testing auto link'
fill_in 'proposal_question', with: 'Should I stay or should I go?'
fill_in 'proposal_summary', with: 'In summary, what we want is...'
fill_in 'proposal_description', with: "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
fill_in 'proposal_description', with: js_injection_string
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
check 'proposal_terms_of_service'

View File

@@ -6,6 +6,7 @@ feature 'Users' do
context 'Sign up' do
scenario 'Success' do
message = "You have been sent a message containing a verification link. Please click on this link to activate your account."
visit '/'
click_link 'Register'
@@ -17,7 +18,7 @@ feature 'Users' do
click_button 'Register'
expect(page).to have_content "You have been sent a message containing a verification link. Please click on this link to activate your account."
expect(page).to have_content message
confirm_email

View File

@@ -11,7 +11,8 @@ feature 'Verify Letter' do
click_link "Send me a letter with the code"
expect(page).to have_content "Thank you for requesting your maximum security code (only required for the final votes). In a few days we will send it to the address featuring in the data we have on file."
expect(page).to have_content "Thank you for requesting your maximum security code (only required for the final votes). In a few days"\
" we will send it to the address featuring in the data we have on file."
user.reload

View File

@@ -87,6 +87,7 @@ feature 'Level three verification' do
click_link "Send me a letter with the code"
expect(page).to have_content "Thank you for requesting your maximum security code (only required for the final votes). In a few days we will send it to the address featuring in the data we have on file."
expect(page).to have_content "Thank you for requesting your maximum security code (only required for the final votes)."\
" In a few days we will send it to the address featuring in the data we have on file."
end
end

View File

@@ -23,13 +23,25 @@ describe CensusApi do
end
it 'adds upper and lowercase letter when the letter is present' do
expect(api.get_document_number_variants(1, '1234567A')).to eq(['1234567', '01234567', '1234567a', '1234567A', '01234567a', '01234567A'])
expect(api.get_document_number_variants(1, '1234567A')).to eq(%w(1234567 01234567 1234567a 1234567A 01234567a 01234567A))
end
end
describe '#call' do
let(:invalid_body) { {get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {}}}} }
let(:valid_body){ {get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {item: {fecha_nacimiento_string: "1-1-1980"}}}}} }
let(:valid_body) do
{
get_habita_datos_response: {
get_habita_datos_return: {
datos_habitante: {
item: {
fecha_nacimiento_string: "1-1-1980"
}
}
}
}
}
end
it "returns the response for the first valid variant" do
allow(api).to receive(:get_response_body).with(1, "00123456").and_return(invalid_body)

View File

@@ -51,8 +51,9 @@ describe ManagerAuthenticator do
end
it 'should call the verification user method' do
message = { ub: {user_key: "31415926", date: "20151031135905"} }
allow(@authenticator).to receive(:application_authorized?).and_return(true)
expect(@authenticator.send(:client)).to receive(:call).with(:get_status_user_data, message: { ub: {user_key: "31415926", date: "20151031135905"} })
expect(@authenticator.send(:client)).to receive(:call).with(:get_status_user_data, message: message)
@authenticator.auth
end

View File

@@ -15,7 +15,7 @@ describe Budget::Result do
investment4 = create(:budget_investment, :selected, heading: heading, price: 500, ballot_lines_count: 600, winner: false)
investment5 = create(:budget_investment, :selected, heading: heading, price: 100, ballot_lines_count: 500, winner: false)
Budget::Result.new(budget, heading).calculate_winners
described_class.new(budget, heading).calculate_winners
expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment4.id])
end
@@ -29,7 +29,7 @@ describe Budget::Result do
investment4 = create(:budget_investment, :winner, heading: heading, price: 500, ballot_lines_count: 600)
investment5 = create(:budget_investment, :winner, heading: heading, price: 100, ballot_lines_count: 500)
Budget::Result.new(budget, heading).calculate_winners
described_class.new(budget, heading).calculate_winners
expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment4.id])
end
@@ -49,6 +49,20 @@ describe Budget::Result do
expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment4.id])
end
end
end
context "When an incompatible is flagged as compatible again" do
it "recalculates winners taking it in consideration" do
investment1 = create(:budget_investment, :winner, heading: heading, price: 200, ballot_lines_count: 900)
investment2 = create(:budget_investment, :winner, heading: heading, price: 300, ballot_lines_count: 800)
investment3 = create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700)
investment4 = create(:budget_investment, :winner, heading: heading, price: 500, ballot_lines_count: 600)
investment5 = create(:budget_investment, :winner, heading: heading, price: 100, ballot_lines_count: 500)
investment3.incompatible = false
investment3.save
expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment3.id])
end
end
end
end

View File

@@ -10,38 +10,102 @@ RSpec.describe Legislation::Annotation, type: :model do
end
it "calculates the context for multinode annotations" do
quote = "ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam"\
" erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex"\
" ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum"\
" dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril"\
" delenit augue duis dolore te feugait nulla facilisi."\
"\n\n"\
"Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi"\
" tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis"\
" ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id."\
"\n\n"\
"His audiam"
annotation = create(:legislation_annotation,
draft_version: draft_version,
quote: "ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.
His audiam",
quote: quote,
ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}]
)
expect(annotation.context).to eq("Lorem <span class=annotator-hl>ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.\n\nHis audiam</span>deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.")
context = "Lorem <span class=annotator-hl>ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt"\
" ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper"\
" suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit"\
" esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui"\
" blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nExpetenda tincidunt in sed, ex"\
" partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute"\
" aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit"\
" iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.\n\nHis audiam</span>deserunt in, eum"\
" ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at"\
" quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim"\
" alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu."
expect(annotation.context).to eq(context)
end
it "calculates the context for multinode annotations 2" do
quote = "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla"\
" facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore"\
" te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant"\
" aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo"
annotation = create(:legislation_annotation,
draft_version: draft_version,
quote: "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo",
quote: quote,
ranges: [{"start" => "/p[1]", "startOffset" => 273, "end" => "/p[2]", "endOffset" => 190}]
)
expect(annotation.context).to eq("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. <span class=annotator-hl>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo</span>. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.")
context = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna"\
" aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut"\
" aliquip ex ea commodo consequat. <span class=annotator-hl>Duis autem vel eum iriure dolor in hendrerit in vulputate velit"\
" esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui"\
" blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex"\
" partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute"\
" aliquando ius ex. Ea aperiri sententiae duo</span>. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit"\
" iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id."
expect(annotation.context).to eq(context)
end
it "calculates the context for multinode annotations 3" do
draft_version = create(:legislation_draft_version, body: "The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.\r\n\r\nThe licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.\r\n\r\nDevelopers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software.\r\n\r\nA secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.\r\n\r\nThe GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.\r\n\r\nAn older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.")
body = "The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed"\
" to ensure cooperation with the community in the case of network server software.\r\n\r\nThe licenses for most software and"\
" other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public"\
" Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free"\
" software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General"\
" Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for"\
" them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces"\
" of it in new free programs, and that you know you can do these things.\r\n\r\nDevelopers that use our General Public Licenses"\
" protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you"\
" legal permission to copy, distribute and/or modify the software.\r\n\r\nA secondary benefit of defending all users' freedom"\
" is that improvements made in alternate versions of the program, if they receive widespread use, become available for other"\
" developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation."\
" However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License"\
" permits making a modified version and letting the public access it on a server without ever releasing its source code to the"\
" public.\r\n\r\nThe GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified"\
" source code becomes available to the community. It requires the operator of a network server to provide the source code of"\
" the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly"\
" accessible server, gives the public access to the source code of the modified version.\r\n\r\nAn older license, called the"\
" Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license,"\
" not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this"\
" license."
draft_version = create(:legislation_draft_version, body: body)
quote = "By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a"\
" program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to"\
" freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of"\
" free software (and charge for them if you wish)"
annotation = create(:legislation_annotation,
draft_version: draft_version,
quote: "By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)",
quote: quote,
ranges: [{"start" => "/p[2]", "startOffset" => 127, "end" => "/p[3]", "endOffset" => 223}]
)
expect(annotation.context).to eq("The licenses for most software and other practical works are designed to take away your freedom to share and change the works. <span class=annotator-hl>By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)</span>, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.")
context = "The licenses for most software and other practical works are designed to take away your freedom to share and change the"\
" works. <span class=annotator-hl>By contrast, our General Public Licenses are intended to guarantee your freedom to share"\
" and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of"\
" free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have"\
" the freedom to distribute copies of free software (and charge for them if you wish)</span>, that you receive source code"\
" or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know"\
" you can do these things."
expect(annotation.context).to eq(context)
end
end

View File

@@ -25,7 +25,9 @@ describe Verification::Residence do
end
it "should validate user has allowed age" do
residence = Verification::Residence.new("date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => (5.years.ago.year).to_s)
residence = Verification::Residence.new("date_of_birth(3i)" => "1",
"date_of_birth(2i)" => "1",
"date_of_birth(1i)" => (5.years.ago.year).to_s)
expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate")
end

View File

@@ -25,7 +25,10 @@ describe Verification::Management::Document do
end
it "returns false when the user is user's minimum required age" do
census_response = double(date_of_birth: Date.new(User.minimum_required_age.years.ago.year, User.minimum_required_age.years.ago.month, User.minimum_required_age.years.ago.day))
date_of_birth = Date.new(User.minimum_required_age.years.ago.year,
User.minimum_required_age.years.ago.month,
User.minimum_required_age.years.ago.day)
census_response = double(date_of_birth: date_of_birth)
expect(Verification::Management::Document.new.under_age?(census_response)).to be false
end

View File

@@ -25,8 +25,9 @@ module CommonActions
end
def login_as_authenticated_manager
expected_response = {login: login, user_key: user_key, date: date}.with_indifferent_access
login, user_key, date = "JJB042", "31415926", Time.current.strftime("%Y%m%d%H%M%S")
allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return({login: login, user_key: user_key, date: date}.with_indifferent_access)
allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(expected_response)
visit management_sign_in_path(login: login, clave_usuario: user_key, fecha_conexion: date)
end
@@ -219,8 +220,11 @@ module CommonActions
end
def create_archived_proposals
[create(:proposal, title: "This is an expired proposal", created_at: Setting["months_to_archive_proposals"].to_i.months.ago),
create(:proposal, title: "This is an oldest expired proposal", created_at: (Setting["months_to_archive_proposals"].to_i + 2).months.ago)]
months_to_archive_proposals = Setting["months_to_archive_proposals"].to_i
[
create(:proposal, title: "This is an expired proposal", created_at: months_to_archive_proposals.months.ago),
create(:proposal, title: "This is an oldest expired proposal", created_at: (months_to_archive_proposals + 2).months.ago)
]
end
def tag_names(tag_cloud)

View File

@@ -65,7 +65,8 @@ shared_examples_for "verifiable" do
user2 = create(:user, verified_at: nil, residence_verified_at: Time.current, unconfirmed_phone: nil)
user3 = create(:user, verified_at: nil, confirmed_phone: nil)
user4 = create(:user, verified_at: Time.current, residence_verified_at: Time.current, unconfirmed_phone: "123456789", confirmed_phone: "123456789")
user4 = create(:user, verified_at: Time.current, residence_verified_at: Time.current,
unconfirmed_phone: "123456789", confirmed_phone: "123456789")
expect(model.incomplete_verification).to include(user1)
expect(model.incomplete_verification).to include(user2)