diff --git a/Gemfile b/Gemfile index f06f4a9..b4fd6cc 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ ruby RUBY_VERSION gem "decidim", "~> 0.26.0" gem "decidim-custom_proposal_states", path: "." +gem "decidim-elections", "~> 0.26.0" gem "bootsnap" gem "uglifier", "~> 4.1" diff --git a/Gemfile.lock b/Gemfile.lock index 7622cba..56dc06c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -83,7 +83,7 @@ GEM ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) batch-loader (1.5.0) - bcrypt (3.1.19) + bcrypt (3.1.20) better_html (1.0.16) actionview (>= 4.0) activesupport (>= 4.0) @@ -107,7 +107,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.4) + carrierwave (2.2.5) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) @@ -145,7 +145,7 @@ GEM crass (1.0.6) css_parser (1.16.0) addressable - date (3.3.3) + date (3.3.4) date_validator (0.9.0) activemodel activesupport @@ -195,6 +195,12 @@ GEM decidim-budgets (0.26.7) decidim-comments (= 0.26.7) decidim-core (= 0.26.7) + decidim-bulletin_board (0.22.3) + byebug (~> 11.0) + graphlient (~> 0.4.0) + jwt (~> 2.2.2) + rails (~> 6.0, >= 5.0.0) + wisper (~> 2.0.0) decidim-comments (0.26.7) decidim-core (= 0.26.7) redcarpet (~> 3.5, >= 3.5.1) @@ -281,6 +287,14 @@ GEM w3c_rspec_validators (~> 0.3.0) webmock (~> 3.6) wisper-rspec (~> 1.0) + decidim-elections (0.26.7) + decidim-bulletin_board (= 0.22.3) + decidim-core (= 0.26.7) + decidim-forms (= 0.26.7) + decidim-proposals (= 0.26.7) + rack-attack (~> 6.0) + voting_schemes-dummy (= 0.22.3) + voting_schemes-electionguard (= 0.22.3) decidim-forms (0.26.7) decidim-core (= 0.26.7) wicked_pdf (~> 2.1) @@ -325,13 +339,13 @@ GEM declarative-option (0.1.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (4.9.2) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.11.0) + devise-i18n (1.12.0) devise (>= 4.9.0) devise_invitable (2.0.9) actionmailer (>= 5.0) @@ -342,7 +356,7 @@ GEM nokogiri (>= 1.13.2, < 1.15.0) rubyzip (~> 2.3.0) docile (1.4.0) - doorkeeper (5.6.6) + doorkeeper (5.6.8) railties (>= 5) doorkeeper-i18n (4.0.1) dumb_delegator (1.0.0) @@ -358,8 +372,8 @@ GEM erbse (0.1.4) temple erubi (1.12.0) - excon (0.103.0) - execjs (2.9.0) + excon (0.105.0) + execjs (2.9.1) factory_bot (4.11.1) activesupport (>= 3.0.0) factory_bot_rails (4.11.1) @@ -367,11 +381,32 @@ GEM railties (>= 3.0.0) faker (3.2.2) i18n (>= 1.8.11, < 2) - faraday (2.7.10) - faraday-net_http (>= 2.0, < 3.1) + faraday (1.10.3) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.2) - ffi (1.15.5) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.0) + faraday-excon (1.1.0) + faraday-httpclient (1.0.1) + faraday-multipart (1.0.4) + multipart-post (~> 2) + faraday-net_http (1.0.1) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.3) + faraday_middleware (1.2.0) + faraday (~> 1.0) + ffi (1.16.3) file_validators (2.3.0) activemodel (>= 3.2) mime-types (>= 1.0) @@ -391,7 +426,14 @@ GEM geocoder (1.7.5) globalid (1.1.0) activesupport (>= 5.0) + graphlient (0.4.0) + faraday (>= 1.0) + faraday_middleware + graphql-client graphql (1.12.24) + graphql-client (0.18.0) + activesupport (>= 3.0) + graphql hashdiff (1.0.1) hashie (5.0.0) highline (2.1.0) @@ -419,7 +461,7 @@ GEM invisible_captcha (0.13.0) rails (>= 3.2.0) json (2.7.0) - jwt (2.7.1) + jwt (2.2.3) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -466,7 +508,7 @@ GEM method_source (1.0.0) mime-types (3.5.1) mime-types-data (~> 3.2015) - mime-types-data (3.2023.0808) + mime-types-data (3.2023.1003) mini_magick (4.12.0) mini_mime (1.1.5) minitest (5.20.0) @@ -477,17 +519,18 @@ GEM chef-utils msgpack (1.7.2) multi_xml (0.6.0) + multipart-post (2.3.0) mustache (1.1.1) - net-imap (0.3.7) + net-imap (0.4.7) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.4.0) net-protocol - nio4r (2.5.9) + nio4r (2.7.0) nokogiri (1.14.5-x86_64-linux) racc (~> 1.4) oauth (1.1.0) @@ -546,10 +589,10 @@ GEM actionmailer (>= 3) net-smtp premailer (~> 1.7, >= 1.7.9) - public_suffix (5.0.3) + public_suffix (5.0.4) puma (5.6.7) nio4r (~> 2.0) - racc (1.7.1) + racc (1.7.3) rack (2.2.8) rack-attack (6.7.0) rack (>= 1.0, < 4) @@ -596,7 +639,7 @@ GEM rake (>= 0.8.7) thor (>= 0.20.3, < 2.0) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) ransack (2.4.2) activerecord (>= 5.2.4) activesupport (>= 5.2.4) @@ -615,7 +658,7 @@ GEM regexp_parser (2.8.2) request_store (1.5.1) rack (>= 1.4) - responders (3.1.0) + responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) @@ -674,7 +717,7 @@ GEM rubocop-rspec (1.43.2) rubocop (~> 0.87) ruby-progressbar (1.13.0) - ruby-vips (2.1.4) + ruby-vips (2.2.0) ffi (~> 1.12) ruby2_keywords (0.0.5) rubyXL (3.4.25) @@ -713,13 +756,13 @@ GEM ssrf_filter (1.1.2) system_test_html_screenshots (0.2.0) actionpack (>= 5.2, < 6.1.a) - temple (0.10.2) + temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thor (1.2.2) + thor (1.3.0) thread_safe (0.3.6) tilt (2.3.0) - timeout (0.4.0) + timeout (0.4.1) tomlrb (2.0.3) tzinfo (1.2.11) thread_safe (~> 0.1) @@ -736,6 +779,10 @@ GEM coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) equalizer (~> 0.0, >= 0.0.9) + voting_schemes-dummy (0.22.3) + rails (>= 5.0.0) + voting_schemes-electionguard (0.22.3) + rails (>= 5.0.0) w3c_rspec_validators (0.3.0) rails rspec @@ -770,7 +817,7 @@ GEM wkhtmltopdf-binary (0.12.6.6) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.12) PLATFORMS x86_64-linux @@ -780,6 +827,7 @@ DEPENDENCIES decidim (~> 0.26.0) decidim-custom_proposal_states! decidim-dev (~> 0.26.0) + decidim-elections (~> 0.26.0) faker letter_opener_web (~> 1.3) listen (~> 3.1) diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 0000000..dea3524 --- /dev/null +++ b/bin/bundle @@ -0,0 +1,62 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +require "rubygems" + +m = Module.new do + extend self + + def invoked_as_script? + File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) + end + + def cli_arg_version + return unless invoked_as_script? # don't want to hijack other binstubs + return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` + + bundler_version = nil + update_index = nil + ARGV.each_with_index do |a, i| + bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN + next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ + + bundler_version = Regexp.last_match(1) || ">= 0.a" + update_index = i + end + bundler_version + end + + def gemfile + File.expand_path("../Gemfile", __dir__) + end + + def lockfile + "#{gemfile}.lock" + end + + def lockfile_version + return unless File.file?(lockfile) + + lockfile_contents = File.read(lockfile) + + regexp = /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ + + regexp.match(lockfile_contents)[1] + end + + def bundler_version + @bundler_version ||= cli_arg_version || lockfile_version + end + + def load_bundler! + activate_bundler(bundler_version) + end + + def activate_bundler(bundler_version) + gem "bundler", bundler_version + end +end + +m.load_bundler! + +load Gem.bin_path("bundler", "bundle") if m.invoked_as_script? diff --git a/decidim-custom_proposal_states.gemspec b/decidim-custom_proposal_states.gemspec index 604a2ee..31b33a6 100644 --- a/decidim-custom_proposal_states.gemspec +++ b/decidim-custom_proposal_states.gemspec @@ -20,4 +20,9 @@ Gem::Specification.new do |s| s.add_dependency "decidim-core", "~> 0.26.0" s.add_dependency "decidim-proposals", "~> 0.26.0" + s.add_development_dependency "decidim-accountability", "~> 0.26.0" + s.add_development_dependency "decidim-budgets", "~> 0.26.0" + s.add_development_dependency "decidim-dev", "~> 0.26.0" + s.add_development_dependency "decidim-elections", "~> 0.26.0" + s.add_development_dependency "decidim-sortitions", "~> 0.26.0" end diff --git a/gemfiles/decidim_0.26.gemfile b/gemfiles/decidim_0.26.gemfile index 9621d6a..fe1d186 100644 --- a/gemfiles/decidim_0.26.gemfile +++ b/gemfiles/decidim_0.26.gemfile @@ -6,6 +6,7 @@ ruby RUBY_VERSION gem "decidim", "~> 0.26.0" gem "decidim-custom_proposal_states", path: ".." +gem "decidim-elections", "~> 0.26.0" gem "bootsnap" gem "uglifier", "~> 4.1" diff --git a/gemfiles/decidim_0.27.gemfile b/gemfiles/decidim_0.27.gemfile index 9621d6a..fe1d186 100644 --- a/gemfiles/decidim_0.27.gemfile +++ b/gemfiles/decidim_0.27.gemfile @@ -6,6 +6,7 @@ ruby RUBY_VERSION gem "decidim", "~> 0.26.0" gem "decidim-custom_proposal_states", path: ".." +gem "decidim-elections", "~> 0.26.0" gem "bootsnap" gem "uglifier", "~> 4.1" diff --git a/spec/accountability/admin_manages_accountability_spec.rb b/spec/accountability/admin_manages_accountability_spec.rb index 11e245c..2e5cd81 100644 --- a/spec/accountability/admin_manages_accountability_spec.rb +++ b/spec/accountability/admin_manages_accountability_spec.rb @@ -5,8 +5,11 @@ describe "Admin manages accountability", type: :system do let(:manifest_name) { "accountability" } + let!(:result) { create :result, scope: scope, component: current_component } + let!(:child_result) { create :result, scope: scope, component: current_component, parent: result } + let!(:status) { create :status, key: "ongoing", name: { en: "Ongoing" }, component: current_component } - include_context "when managing an accountability component as an admin" + include_context "when managing a component as an admin" before do switch_to_host(organization.host) @@ -15,6 +18,124 @@ end describe "results" do - it_behaves_like "manage results" + describe "admin form" do + before { click_on "New Result", match: :first } + + it_behaves_like "having a rich text editor", "new_result", "full" + + it "displays the proposals picker" do + expect(page).to have_content("Choose proposals") + end + + context "when proposal linking is disabled" do + before do + allow(Decidim::Accountability).to receive(:enable_proposal_linking).and_return(false) + + # Reload the page with the updated settings + visit current_path + end + + it "does not display the proposal picker" do + expect(page).not_to have_content "Choose proposals" + end + end + end + + context "when having existing proposals" do + let!(:proposal_component) { create(:proposal_component, participatory_space: participatory_space) } + let!(:proposals) { create_list :proposal, 5, component: proposal_component, skip_injection: true } + + it "updates a result" do + within find("tr", text: translated(result.title)) do + click_link "Edit" + end + + within ".edit_result" do + fill_in_i18n( + :result_title, + "#result-title-tabs", + en: "My new title", + es: "Mi nuevo título", + ca: "El meu nou títol" + ) + + proposals_pick(select_data_picker(:result_proposals, multiple: true), proposals.last(2)) + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_content("My new title") + end + end + + it "creates a new result", :slow do + click_link "New Result", match: :first + + within ".new_result" do + fill_in_i18n( + :result_title, + "#result-title-tabs", + en: "My result", + es: "Mi result", + ca: "El meu result" + ) + fill_in_i18n_editor( + :result_description, + "#result-description-tabs", + en: "A longer description", + es: "Descripción más larga", + ca: "Descripció més llarga" + ) + + proposals_pick(select_data_picker(:result_proposals, multiple: true), proposals.first(2)) + scope_pick(select_data_picker(:result_decidim_scope_id), scope) + select translated(category.name), from: :result_decidim_category_id + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_content("My result") + end + end + end + + it "allows the user to preview the result" do + within find("tr", text: translated(result.title)) do + klass = "action-icon--preview" + href = resource_locator(result).path + target = "blank" + + expect(page).to have_selector( + :xpath, + "//a[contains(@class,'#{klass}')][@href='#{href}'][@target='#{target}']" + ) + end + end + + describe "deleting a result" do + let!(:result2) { create(:result, component: current_component) } + + before do + visit current_path + end + + it "deletes a result" do + within find("tr", text: translated(result2.title)) do + accept_confirm { click_link "Delete" } + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_no_content(translated(result2.title)) + end + end + end end end diff --git a/spec/budgets/admin_manages_projects_spec.rb b/spec/budgets/admin_manages_projects_spec.rb index bb997d0..090efa6 100644 --- a/spec/budgets/admin_manages_projects_spec.rb +++ b/spec/budgets/admin_manages_projects_spec.rb @@ -21,6 +21,257 @@ end end - it_behaves_like "manage projects" - it_behaves_like "import proposals to projects" + context "when importing proposals to projects" do + let!(:proposals) { create_list :proposal, 3, :accepted, component: origin_component } + let!(:rejected_proposals) { create_list :proposal, 3, :rejected, component: origin_component } + let!(:origin_component) { create :proposal_component, participatory_space: current_component.participatory_space } + let!(:default_budget) { 2333 } + + include Decidim::ComponentPathHelper + + it "imports proposals from one component to a budget component" do + click_link "Import proposals to projects" + + within ".import_proposals" do + select origin_component.name["en"], from: :proposals_import_origin_component_id + fill_in "Default budget", with: default_budget + check :proposals_import_import_all_accepted_proposals + end + + click_button "Import proposals to projects" + + expect(page).to have_content("3 proposals successfully imported") + + proposals.each do |project| + expect(page).to have_content(project.title["en"]) + end + end + end + + describe "admin form" do + before do + within ".process-content" do + page.find(".button--title.new").click + end + end + + it_behaves_like "having a rich text editor", "new_project", "full" + + it "displays the proposals picker" do + expect(page).to have_content("Choose proposals") + end + + context "when proposal linking is disabled" do + before do + allow(Decidim::Budgets).to receive(:enable_proposal_linking).and_return(false) + + # Reload the page with the updated settings + visit current_path + end + + it "does not display the proposal picker" do + expect(page).not_to have_content "Choose proposals" + end + end + end + + it "updates a project" do + within find("tr", text: translated(project.title)) do + click_link "Edit" + end + + within ".edit_project" do + fill_in_i18n( + :project_title, + "#project-title-tabs", + en: "My new title", + es: "Mi nuevo título", + ca: "El meu nou títol" + ) + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_content("My new title") + end + end + + context "when previewing projects" do + it "allows the user to preview the project" do + within find("tr", text: translated(project.title)) do + klass = "action-icon--preview" + href = resource_locator([project.budget, project]).path + target = "blank" + + expect(page).to have_selector( + :xpath, + "//a[contains(@class,'#{klass}')][@href='#{href}'][@target='#{target}']" + ) + end + end + end + + context "when seeing finished and pending votes" do + let!(:project) { create(:project, budget_amount: 70_000_000, budget: budget) } + + let!(:finished_orders) do + orders = create_list(:order, 10, budget: budget) + orders.each do |order| + order.update!(line_items: [create(:line_item, project: project, order: order)]) + order.reload + order.update!(checked_out_at: Time.zone.today) + end + end + + let!(:pending_orders) do + create_list(:order, 5, budget: budget, checked_out_at: nil) + end + + it "shows the order count" do + visit current_path + expect(page).to have_content("Finished votes: \n10") + expect(page).to have_content("Pending votes: \n5") + end + end + + it "creates a new project", :slow do + find(".card-title a.button.new").click + + within ".new_project" do + fill_in_i18n( + :project_title, + "#project-title-tabs", + en: "My project", + es: "Mi proyecto", + ca: "El meu projecte" + ) + fill_in_i18n_editor( + :project_description, + "#project-description-tabs", + en: "A longer description", + es: "Descripción más larga", + ca: "Descripció més llarga" + ) + fill_in :project_budget_amount, with: 22_000_000 + + scope_pick select_data_picker(:project_decidim_scope_id), scope + select translated(category.name), from: :project_decidim_category_id + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_content("My project") + end + end + + context "when deleting a project" do + let!(:project2) { create(:project, budget: budget) } + + before do + visit current_path + end + + it "deletes a project" do + within find("tr", text: translated(project2.title)) do + accept_confirm { click_link "Delete" } + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_no_content(translated(project2.title)) + end + end + end + + context "when having existing proposals" do + let!(:proposal_component) { create(:proposal_component, participatory_space: participatory_space) } + let!(:proposals) { create_list :proposal, 5, component: proposal_component, skip_injection: true } + + it "updates a project" do + within find("tr", text: translated(project.title)) do + click_link "Edit" + end + + within ".edit_project" do + fill_in_i18n( + :project_title, + "#project-title-tabs", + en: "My new title", + es: "Mi nuevo título", + ca: "El meu nou títol" + ) + + proposals_pick(select_data_picker(:project_proposals, multiple: true), proposals.last(2)) + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_content("My new title") + end + end + + it "removes proposals from project", :slow do + project.link_resources(proposals, "included_proposals") + not_removed_projects_title = project.linked_resources(:proposals, "included_proposals").first.title + expect(project.linked_resources(:proposals, "included_proposals").count).to eq(5) + + within find("tr", text: translated(project.title)) do + click_link "Edit" + end + + within ".edit_project" do + proposals_remove(select_data_picker(:project_proposals, multiple: true), proposals.last(4)) + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + expect(project.linked_resources(:proposals, "included_proposals").count).to eq(1) + expect(project.linked_resources(:proposals, "included_proposals").first.title).to eq(not_removed_projects_title) + end + + it "creates a new project", :slow do + find(".card-title a.button.new").click + + within ".new_project" do + fill_in_i18n( + :project_title, + "#project-title-tabs", + en: "My project", + es: "Mi project", + ca: "El meu project" + ) + fill_in_i18n_editor( + :project_description, + "#project-description-tabs", + en: "A longer description", + es: "Descripción más larga", + ca: "Descripció més llarga" + ) + fill_in :project_budget_amount, with: 22_000_000 + + proposals_pick(select_data_picker(:project_proposals, multiple: true), proposals.first(2)) + scope_pick(select_data_picker(:project_decidim_scope_id), scope) + select translated(category.name), from: :project_decidim_category_id + + find("*[type=submit]").click + end + + expect(page).to have_admin_callout("successfully") + + within "table" do + expect(page).to have_content("My project") + end + end + end end diff --git a/spec/factories.rb b/spec/factories.rb index 806a6c0..d7b4de1 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -1,3 +1,8 @@ # frozen_string_literal: true require "decidim/custom_proposal_states/test/factories" +require "decidim/accountability/test/factories" +require "decidim/sortitions/test/factories" +require "decidim/proposals/test/factories" +require "decidim/budgets/test/factories" +require "decidim/elections/test/factories" diff --git a/spec/sortitions/admin_manages_sortitions_spec.rb b/spec/sortitions/admin_manages_sortitions_spec.rb index 202ced1..e1ac24b 100644 --- a/spec/sortitions/admin_manages_sortitions_spec.rb +++ b/spec/sortitions/admin_manages_sortitions_spec.rb @@ -7,5 +7,120 @@ include_context "when managing a component as an admin" - it_behaves_like "manage sortitions" + describe "creation" do + let!(:proposal_component) do + create(:proposal_component, :published, participatory_space: current_component.participatory_space) + end + + before do + click_link "New sortition" + end + + it "Requires a title" do + within "form" do + expect(page).to have_content(/Title/i) + end + end + + it "can be related to a category" do + within "form" do + expect(page).to have_content(/Categories of the set of proposals in which you want to apply the draw/i) + end + end + + it "Requires a random number" do + within "form" do + expect(page).to have_content(/Result of die roll/i) + end + end + + it "Requires the number of proposals to select" do + within "form" do + expect(page).to have_content(/Number of proposals to be selected/i) + end + end + + it "Requires the proposals component" do + within "form" do + expect(page).to have_content(/Proposals set/i) + end + end + + it "Requires the witnesses" do + within "form" do + expect(page).to have_content(/Witnesses/i) + end + end + + it "Requires additional information" do + within "form" do + expect(page).to have_content(/Sortition information/i) + end + end + + context "when creates a sortition" do + let(:sortition_dice) { ::Faker::Number.between(from: 1, to: 6) } + let(:sortition_target_items) { ::Faker::Number.between(from: 1, to: 10) } + let!(:proposal) { create :proposal, component: proposal_component } + + it_behaves_like "having a rich text editor for field", ".tabs-content[data-tabs-content='sortition-additional_info-tabs']", "full" + it_behaves_like "having a rich text editor for field", ".tabs-content[data-tabs-content='sortition-witnesses-tabs']", "content" + + it "shows the sortition details" do + within ".new_sortition" do + fill_in :sortition_dice, with: sortition_dice + fill_in :sortition_target_items, with: sortition_target_items + select translated(proposal_component.name), from: :sortition_decidim_proposals_component_id + fill_in_i18n_editor( + :sortition_witnesses, + "#sortition-witnesses-tabs", + en: "Witnesses", + es: "Testigos", + ca: "Testimonis" + ) + fill_in_i18n_editor( + :sortition_additional_info, + "#sortition-additional_info-tabs", + en: "additional info", + es: "Información adicional", + ca: "Informació adicional" + ) + + fill_in_i18n( + :sortition_title, + "#sortition-title-tabs", + en: "Title", + es: "Título", + ca: "Títol" + ) + + accept_confirm { find("*[type=submit]").click } + end + + expect(page).to have_admin_callout("successfully") + expect(page).to have_content(/Title/i) + + sortition = Decidim::Sortitions::Sortition.last + within ".sortition" do + expect(page).to have_content(/Draw time/i) + expect(page).to have_content(/Dice/i) + expect(page).to have_content(/Items to select/i) + expect(page).to have_content(/Category/i) + expect(page).to have_content(/All categories/i) + expect(page).to have_content(/Proposals component/i) + expect(page).to have_content(translated(proposal_component.name)) + expect(page).to have_content(/Seed/i) + expect(page).to have_content(sortition.seed) + end + + within ".proposals" do + expect(page).to have_content(/Proposals selected for draw/i) + expect(sortition.proposals).not_to be_empty + sortition.proposals.each do |p| + expect(page).to have_content(translated(p.title)) + end + end + end + end + end end