Don't include unneeded helpers in tests
Including them might lead to conflicts since two methods might have the same name. For example, we're getting some exceptions when taking screenshots of a failing test, because the method `image_path` from `ActionView::Helpers::AssetUrlHelper` has the same name as a method used to save the screenshot. Besides, we were including all helpers in places were only the `dom_id` method is used, and in other places where no helper methods were used at all. So we can just invoke `ActionView::RecordIdentifier.dom_id` directly.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting Budget::Investments" do
|
describe "Commenting Budget::Investments" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting debates" do
|
describe "Commenting debates" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting legislation questions" do
|
describe "Commenting legislation questions" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting legislation questions" do
|
describe "Commenting legislation questions" do
|
||||||
let(:user) { create :user, :level_two }
|
let(:user) { create :user, :level_two }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting polls" do
|
describe "Commenting polls" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting proposals" do
|
describe "Commenting proposals" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
include ActionView::Helpers::DateHelper
|
|
||||||
|
|
||||||
describe "Commenting topics from proposals" do
|
describe "Commenting topics from proposals" do
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
shared_examples "documentable" do |documentable_factory_name, documentable_path, documentable_path_arguments|
|
shared_examples "documentable" do |documentable_factory_name, documentable_path, documentable_path_arguments|
|
||||||
include ActionView::Helpers
|
|
||||||
|
|
||||||
let(:administrator) { create(:user) }
|
let(:administrator) { create(:user) }
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:arguments) { {} }
|
let(:arguments) { {} }
|
||||||
@@ -134,7 +132,7 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
|
|||||||
click_on "Delete document"
|
click_on "Delete document"
|
||||||
end
|
end
|
||||||
|
|
||||||
within "##{dom_id(documentable)}" do
|
within "##{ActionView::RecordIdentifier.dom_id(documentable)}" do
|
||||||
expect(page).to have_selector "h1", text: documentable.title
|
expect(page).to have_selector "h1", text: documentable.title
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
shared_examples "followable" do |followable_class_name, followable_path, followable_path_arguments|
|
shared_examples "followable" do |followable_class_name, followable_path, followable_path_arguments|
|
||||||
include ActionView::Helpers
|
|
||||||
|
|
||||||
let!(:arguments) { {} }
|
let!(:arguments) { {} }
|
||||||
let!(:followable) { create(followable_class_name) }
|
let!(:followable) { create(followable_class_name) }
|
||||||
let!(:followable_dom_name) { followable_class_name.tr("_", "-") }
|
let!(:followable_dom_name) { followable_class_name.tr("_", "-") }
|
||||||
|
|
||||||
|
def dom_id(record)
|
||||||
|
ActionView::RecordIdentifier.dom_id(record)
|
||||||
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
followable_path_arguments.each do |argument_name, path_to_value|
|
followable_path_arguments.each do |argument_name, path_to_value|
|
||||||
arguments.merge!("#{argument_name}": followable.send(path_to_value))
|
arguments.merge!("#{argument_name}": followable.send(path_to_value))
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
shared_examples "imageable" do |imageable_factory_name, imageable_path, imageable_path_arguments|
|
shared_examples "imageable" do |imageable_factory_name, imageable_path, imageable_path_arguments|
|
||||||
include ActionView::Helpers
|
|
||||||
include ImagesHelper
|
|
||||||
include ImageablesHelper
|
|
||||||
|
|
||||||
let!(:administrator) { create(:user) }
|
let!(:administrator) { create(:user) }
|
||||||
let!(:user) { create(:user) }
|
let!(:user) { create(:user) }
|
||||||
let!(:imageable_arguments) { {} }
|
let!(:imageable_arguments) { {} }
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
shared_examples "mappable" do |mappable_factory_name, mappable_association_name, mappable_new_path, mappable_edit_path, mappable_show_path, mappable_path_arguments, management: false|
|
shared_examples "mappable" do |mappable_factory_name, mappable_association_name, mappable_new_path, mappable_edit_path, mappable_show_path, mappable_path_arguments, management: false|
|
||||||
include ActionView::Helpers
|
|
||||||
|
|
||||||
let!(:user) { create(:user, :level_two) }
|
let!(:user) { create(:user, :level_two) }
|
||||||
let!(:arguments) { {} }
|
let!(:arguments) { {} }
|
||||||
let!(:mappable) { create(mappable_factory_name.to_s.to_sym) }
|
let!(:mappable) { create(mappable_factory_name.to_s.to_sym) }
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
shared_examples "nested documentable" do |login_as_name, documentable_factory_name, path, documentable_path_arguments, fill_resource_method_name, submit_button, documentable_success_notice|
|
shared_examples "nested documentable" do |login_as_name, documentable_factory_name, path, documentable_path_arguments, fill_resource_method_name, submit_button, documentable_success_notice|
|
||||||
include ActionView::Helpers
|
|
||||||
include DocumentsHelper
|
|
||||||
include DocumentablesHelper
|
|
||||||
|
|
||||||
let!(:administrator) { create(:user) }
|
let!(:administrator) { create(:user) }
|
||||||
let!(:user) { create(:user, :level_two) }
|
let!(:user) { create(:user, :level_two) }
|
||||||
let!(:arguments) { {} }
|
let!(:arguments) { {} }
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice, has_many_images = false|
|
shared_examples "nested imageable" do |imageable_factory_name, path, imageable_path_arguments, fill_resource_method_name, submit_button, imageable_success_notice, has_many_images = false|
|
||||||
include ActionView::Helpers
|
|
||||||
include ImagesHelper
|
|
||||||
include ImageablesHelper
|
|
||||||
|
|
||||||
let!(:user) { create(:user, :level_two) }
|
let!(:user) { create(:user, :level_two) }
|
||||||
let!(:administrator) { create(:administrator, user: user) }
|
let!(:administrator) { create(:administrator, user: user) }
|
||||||
let!(:arguments) { {} }
|
let!(:arguments) { {} }
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
shared_examples "image validations" do |imageable_factory|
|
shared_examples "image validations" do |imageable_factory|
|
||||||
include ImagesHelper
|
|
||||||
include ImageablesHelper
|
include ImageablesHelper
|
||||||
|
|
||||||
let!(:image) { build(:image, imageable_factory.to_sym) }
|
let!(:image) { build(:image, imageable_factory.to_sym) }
|
||||||
|
|||||||
Reference in New Issue
Block a user