Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Implement or remove pending tests #4803

Merged
merged 20 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/debates_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DebatesController < ApplicationController
include FlagActions
include Translatable

before_action :authenticate_user!, except: [:index, :show, :map]
before_action :authenticate_user!, except: [:index, :show]
before_action :set_view, only: :index
before_action :debates_recommendations, only: :index, if: :current_user

Expand Down
2 changes: 1 addition & 1 deletion app/models/abilities/administrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def initialize(user)
can :mark_featured, Debate
can :unmark_featured, Debate

can :comment_as_administrator, [Debate, Comment, Proposal, Poll::Question, Budget::Investment,
can :comment_as_administrator, [Debate, Comment, Proposal, Poll, Poll::Question, Budget::Investment,
Legislation::Question, Legislation::Proposal, Legislation::Annotation, Topic]

can [:search, :create, :index, :destroy, :update], ::Administrator
Expand Down
2 changes: 1 addition & 1 deletion app/models/abilities/moderator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Moderator
def initialize(user)
merge Abilities::Moderation.new(user)

can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll::Question,
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll, Poll::Question,
Legislation::Question, Legislation::Annotation, Legislation::Proposal, Topic]
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/poll/questions/answers/images/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="poll-question-form">
<%= form_for(Poll::Question::Answer.new,
<%= form_for(@answer,
url: admin_answer_images_path(@answer),
method: :post) do |f| %>
<%= render "shared/errors", resource: @answer %>
Expand Down
1 change: 0 additions & 1 deletion app/views/debates/map.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion config/routes/debate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
end

collection do
get :map
get :suggest
put "recommendations/disable", only: :index, controller: "debates", action: :disable_recommendations
end
Expand Down
4 changes: 4 additions & 0 deletions spec/models/abilities/administrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
let(:budget_investment) { create(:budget_investment) }
let(:finished_investment) { create(:budget_investment, budget: create(:budget, :finished)) }
let(:legislation_question) { create(:legislation_question) }
let(:poll) { create(:poll) }
let(:poll_question) { create(:poll_question) }

let(:past_process) { create(:legislation_process, :past) }
Expand Down Expand Up @@ -71,6 +72,9 @@
it { should be_able_to(:comment_as_administrator, legislation_question) }
it { should_not be_able_to(:comment_as_moderator, legislation_question) }

it { should be_able_to(:comment_as_administrator, poll) }
it { should_not be_able_to(:comment_as_moderator, poll) }

it { should be_able_to(:summary, past_process) }
it { should_not be_able_to(:summary, past_draft_process) }
it { should_not be_able_to(:summary, open_process) }
Expand Down
3 changes: 3 additions & 0 deletions spec/models/abilities/moderator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
let(:comment) { create(:comment) }
let(:proposal) { create(:proposal) }
let(:legislation_question) { create(:legislation_question) }
let(:poll) { create(:poll) }

let(:own_debate) { create(:debate, author: user) }
let(:own_comment) { create(:comment, author: user) }
Expand Down Expand Up @@ -101,9 +102,11 @@
it { should be_able_to(:comment_as_moderator, debate) }
it { should be_able_to(:comment_as_moderator, proposal) }
it { should be_able_to(:comment_as_moderator, legislation_question) }
it { should be_able_to(:comment_as_moderator, poll) }
it { should_not be_able_to(:comment_as_administrator, debate) }
it { should_not be_able_to(:comment_as_administrator, proposal) }
it { should_not be_able_to(:comment_as_administrator, legislation_question) }
it { should_not be_able_to(:comment_as_administrator, poll) }
end

it { should_not be_able_to(:read, SDG::Target) }
Expand Down
64 changes: 32 additions & 32 deletions spec/models/concerns/globalizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@
end

it "Does not create invalid translations in the database" do
skip("cannot have invalid translations") if required_fields.empty?
if required_fields.any?
record.update(translations_attributes: [{ locale: :fr }])
javierm marked this conversation as resolved.
Show resolved Hide resolved

record.update(translations_attributes: [{ locale: :fr }])
expect(record.translations.map(&:locale)).to match_array %i[en es fr]

expect(record.translations.map(&:locale)).to match_array %i[en es fr]
record.reload

record.reload

expect(record.translations.map(&:locale)).to match_array %i[en es]
expect(record.translations.map(&:locale)).to match_array %i[en es]
end
end

it "Does not automatically add a translation for the current locale" do
Expand Down Expand Up @@ -84,17 +84,17 @@
end

it "Does not save invalid translations" do
skip("cannot have invalid translations") if required_fields.empty?

record.update(translations_attributes: [
{ id: record.translations.find_by(locale: :es).id, attribute => "" }
])
if required_fields.any?
record.update(translations_attributes: [
javierm marked this conversation as resolved.
Show resolved Hide resolved
{ id: record.translations.find_by(locale: :es).id, attribute => "" }
])

I18n.with_locale(:es) { expect(record.send(attribute)).to eq "" }
I18n.with_locale(:es) { expect(record.send(attribute)).to eq "" }

record.reload
record.reload

I18n.with_locale(:es) { expect(record.send(attribute)).to eq "En español" }
I18n.with_locale(:es) { expect(record.send(attribute)).to eq "En español" }
end
end

it "Does not automatically add a translation for the current locale" do
Expand Down Expand Up @@ -122,33 +122,33 @@
end

it "Does not remove all translations" do
skip("cannot have invalid translations") if required_fields.empty?
if required_fields.any?
record.translations_attributes = [
{ id: record.translations.find_by(locale: :en).id, _destroy: true },
{ id: record.translations.find_by(locale: :es).id, _destroy: true }
]

record.translations_attributes = [
{ id: record.translations.find_by(locale: :en).id, _destroy: true },
{ id: record.translations.find_by(locale: :es).id, _destroy: true }
]
expect(record).not_to be_valid

expect(record).not_to be_valid
record.reload

record.reload

expect(record.translations.map(&:locale)).to match_array %i[en es]
expect(record.translations.map(&:locale)).to match_array %i[en es]
end
end

it "Does not remove translations when there's invalid data" do
skip("cannot have invalid translations") if required_fields.empty?
if required_fields.any?
record.translations_attributes = [
{ id: record.translations.find_by(locale: :es).id, attribute => "" },
{ id: record.translations.find_by(locale: :en).id, _destroy: true }
]

record.translations_attributes = [
{ id: record.translations.find_by(locale: :es).id, attribute => "" },
{ id: record.translations.find_by(locale: :en).id, _destroy: true }
]
expect(record).not_to be_valid

expect(record).not_to be_valid
record.reload

record.reload

expect(record.translations.map(&:locale)).to match_array %i[en es]
expect(record.translations.map(&:locale)).to match_array %i[en es]
end
end
end

Expand Down
16 changes: 0 additions & 16 deletions spec/models/concerns/reportable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@
expect(saved_reportable.results_enabled?).to be false
expect(saved_reportable.results_enabled).to be false
end

it "uses the `has_one` relation instead of the original column" do
skip "there's no original column" unless reportable.has_attribute?(:results_enabled)

reportable.update!(results_enabled: true)

expect(reportable.read_attribute(:results_enabled)).to be false
end
end

describe "#stats_enabled" do
Expand Down Expand Up @@ -93,13 +85,5 @@
expect(saved_reportable.stats_enabled?).to be false
expect(saved_reportable.stats_enabled).to be false
end

it "uses the `has_one` relation instead of the original column" do
skip "there's no original column" unless reportable.has_attribute?(:stats_enabled)

reportable.update!(stats_enabled: true)

expect(reportable.read_attribute(:stats_enabled)).to be false
end
end
end
2 changes: 0 additions & 2 deletions spec/models/poll/poll_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
poll.ends_at = 2.months.ago
expect(poll).not_to be_valid
end

pending "no overlapping polls for proposal polls are allowed"
end

describe "proposal polls specific validations" do
Expand Down
4 changes: 0 additions & 4 deletions spec/models/poll/stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@
end
end

describe "#total_web_white" do
pending "Too complex to test"
end

describe "#total_web_null" do
it "returns 0" do
expect(stats.total_web_null).to eq(0)
Expand Down
3 changes: 0 additions & 3 deletions spec/models/tag_cloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
expect(tag_names(tag_cloud)).to contain_exactly("parks")
end

xit "returns tags scoped by category for debates"
xit "returns tags scoped by geozone for debates"

it "orders tags by count" do
3.times { create(:proposal, tag_list: "participation") }
create(:proposal, tag_list: "corruption")
Expand Down
6 changes: 0 additions & 6 deletions spec/shared/models/sanitizable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@
let(:sanitizable) { build(model_name(described_class)) }

describe "#tag_list" do
before do
unless described_class.included_modules.include?(Taggable)
skip "#{described_class} does not have a tag list"
end
end

it "sanitizes the tag list" do
sanitizable.tag_list = "user_id=1"

Expand Down
4 changes: 1 addition & 3 deletions spec/shared/system/flaggable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@
end
end

scenario "Flagging a comment with a child does not update its children" do
skip "Only for comments" unless flaggable.is_a?(Comment)

scenario "Flagging a comment with a child does not update its children", if: factory_name =~ /comment/ do
child_comment = create(:comment, commentable: flaggable.commentable, parent: flaggable)

login_as(user)
Expand Down
15 changes: 1 addition & 14 deletions spec/shared/system/mappable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@
end
end

describe "At #{mappable_edit_path}" do
before { skip } if mappable_edit_path.blank?

describe "At #{mappable_edit_path}", if: mappable_edit_path.present? do
scenario "Should edit map on #{mappable_factory_name} and contain default values" do
do_login_for mappable.author, management: management

Expand Down Expand Up @@ -232,17 +230,6 @@
expect(page).not_to have_css(".map_location")
end

scenario "No errors on update" do
skip ""
do_login_for mappable.author, management: management

visit send(mappable_edit_path, id: mappable.id)
click_link "Remove map marker"
click_on "Save changes"

expect(page).not_to have_content "Map location can't be blank"
end

scenario "No need to skip map on update" do
do_login_for mappable.author, management: management

Expand Down
11 changes: 3 additions & 8 deletions spec/shared/system/nested_documentable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@
expect(page).to have_content documentable_success_notice
end

scenario "Should show new document after successful creation with one uploaded file" do
if documentable_factory_name == "dashboard_action"
skip("Not render Documents count on dashboard_actions")
end
scenario "Should show new document after successful creation with one uploaded file",
unless: documentable_factory_name == "dashboard_action" do
do_login_for user_to_login, management: management
visit send(path, arguments)
send(fill_resource_method_name) if fill_resource_method_name
Expand All @@ -223,10 +221,7 @@
end

scenario "Should show resource with new document after successful creation with
maximum allowed uploaded files" do
if documentable_factory_name == "dashboard_action"
skip("Not render Documents count on dashboard_actions")
end
maximum allowed uploaded files", unless: documentable_factory_name == "dashboard_action" do
do_login_for user_to_login, management: management
visit send(path, arguments)

Expand Down
37 changes: 13 additions & 24 deletions spec/shared/system/nested_imageable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,13 @@
click_link "Add image"
click_on submit_button

if has_many_images
# Pending. Review soon and test
else
within "#nested-image .image" do
expect(page).to have_content("can't be blank", count: 2)
end
within "#nested-image .image" do
expect(page).to have_content("can't be blank", count: 2)
end
end

scenario "Render image preview after sending the form with validation errors" do
skip "Question answers behave differently" if imageable.is_a?(Poll::Question::Answer)
scenario "Render image preview after sending the form with validation errors",
unless: imageable_factory_name == "poll_question_answer" do
do_login_for user, management: management
visit send(path, arguments)

Expand All @@ -154,17 +150,14 @@
expect(page).not_to have_selector("#nested-image .image")
end

scenario "Should show successful notice when resource filled correctly without any nested images" do
if has_many_images
skip "no need to test, there are no attributes for the parent resource"
else
do_login_for user, management: management
visit send(path, arguments)
scenario "Should show successful notice when resource filled correctly without any nested images",
unless: has_many_images do
do_login_for user, management: management
visit send(path, arguments)

send(fill_resource_method_name) if fill_resource_method_name
click_on submit_button
expect(page).to have_content imageable_success_notice
end
send(fill_resource_method_name) if fill_resource_method_name
click_on submit_button
expect(page).to have_content imageable_success_notice
end

scenario "Should show successful notice when resource filled correctly and after valid file uploads" do
Expand Down Expand Up @@ -193,12 +186,8 @@
click_on submit_button
imageable_redirected_to_resource_show_or_navigate_to(imageable)

if has_many_images
# Pending. Review soon and test
else
expect(page).to have_selector "figure img"
expect(page).to have_selector "figure figcaption" if show_caption_for?(imageable_factory_name)
end
expect(page).to have_selector "figure img"
expect(page).to have_selector "figure figcaption" if show_caption_for?(imageable_factory_name)
end

scenario "Different URLs for different images" do
Expand Down