Add map location missing specs

This commit is contained in:
Senén Rodero Rodríguez
2017-08-08 12:33:52 +02:00
parent 053a87eb2c
commit 011ef41ae1
5 changed files with 46 additions and 6 deletions

View File

@@ -982,7 +982,6 @@ table {
top: 50%;
margin-top: -5px;
.map-icon{
transform: rotate(-45deg);
width: 30px;
height: 30px;
border-radius: 50% 50% 50% 0;

View File

@@ -1,7 +1,7 @@
module MapLocationsHelper
def map_location_available?(map_location)
map_location.present? && map_location.filled?
map_location.present? && map_location.available?
end
def map_location_latitude(map_location)

View File

@@ -3,7 +3,7 @@ class MapLocation < ActiveRecord::Base
belongs_to :proposal
belongs_to :investment
def filled?
def available?
latitude.present? && longitude.present? && zoom.present?
end

View File

@@ -840,4 +840,18 @@ LOREM_IPSUM
initialize_with { new(attributes) }
end
factory :map_location do
latitude 51.48
longitude 0.0
zoom 10
trait :proposal_map_location do
proposal
end
trait :investment_map_location do
investment
end
end
end

View File

@@ -2,8 +2,35 @@ require 'rails_helper'
describe MapLocation do
context "#filled?" do
let(:map_location) { build(:map_location, :proposal_map_location ) }
it "should be valid" do
expect(map_location).to be_valid
end
context "#available?" do
it "should return true when latitude, longitude and zoom defined" do
expect(map_location.available?).to be(true)
end
it "should return false when longitude is nil" do
map_location.longitude = nil
expect(map_location.available?).to be(false)
end
it "should return false when latitude is nil" do
map_location.latitude = nil
expect(map_location.available?).to be(false)
end
it "should return false when zoom is nil" do
map_location.zoom = nil
expect(map_location.available?).to be(false)
end
end
end