Merge pull request #2221 from consul/map-validations

Map validations
This commit is contained in:
Raimond Garcia
2017-12-26 13:13:40 +01:00
committed by GitHub
3 changed files with 21 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ module Mappable
has_one :map_location, dependent: :destroy
accepts_nested_attributes_for :map_location, allow_destroy: true
validate :map_must_be_valid, if: :feature_maps?
validate :map_must_be_valid, on: :create, if: :feature_maps?
def map_must_be_valid
return true if skip_map?

16
lib/tasks/votes.rake Normal file
View File

@@ -0,0 +1,16 @@
namespace :votes do
desc "Resets cached_votes_up counter to its latest value"
task reset_vote_counter: :environment do
models = [Proposal, Budget::Investment]
models.each do |model|
model.find_each do |resource|
resource.update_cached_votes
print "."
end
end
end
end

View File

@@ -175,22 +175,22 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
expect(page).not_to have_css(".map_location")
end
scenario 'Errors on update', :js do
scenario 'No errors on update', :js do
skip ""
login_as mappable.author
visit send(mappable_edit_path, id: mappable.id)
click_link "Remove map marker"
click_on "Save changes"
expect(page).to have_content "Map location can't be blank"
expect(page).to_not have_content "Map location can't be blank"
end
scenario 'Skip map on update' do
scenario 'No need to skip map on update' do
login_as mappable.author
visit send(mappable_edit_path, id: mappable.id)
click_link "Remove map marker"
check "#{mappable_factory_name}_skip_map"
click_on "Save changes"
expect(page).to_not have_content "Map location can't be blank"