adds Geozones 🗺

This commit is contained in:
Juanjo Bazán
2016-01-05 14:03:33 +01:00
parent 54badef191
commit d6abf44477
5 changed files with 39 additions and 0 deletions

3
app/models/geozone.rb Normal file
View File

@@ -0,0 +1,3 @@
class Geozone < ActiveRecord::Base
validates :name, presence: true
end

View File

@@ -0,0 +1,11 @@
class CreateGeozones < ActiveRecord::Migration
def change
create_table :geozones do |t|
t.string :name
t.string :html_map_coordinates
t.string :external_code
t.timestamps null: false
end
end
end

View File

@@ -171,6 +171,14 @@ ActiveRecord::Schema.define(version: 20160108133501) do
add_index "flags", ["user_id", "flaggable_type", "flaggable_id"], name: "access_inappropiate_flags", using: :btree
add_index "flags", ["user_id"], name: "index_flags_on_user_id", using: :btree
create_table "geozones", force: :cascade do |t|
t.string "name"
t.string "html_map_coordinates"
t.string "external_code"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "identities", force: :cascade do |t|
t.integer "user_id"
t.string "provider"

View File

@@ -303,4 +303,7 @@ FactoryGirl.define do
association :notifiable, factory: :proposal
end
factory :geozone do
sequence(:name) { |n| "District #{n}" }
end
end

View File

@@ -0,0 +1,14 @@
require 'rails_helper'
RSpec.describe Geozone, type: :model do
let(:geozone) { build(:geozone) }
it "should be valid" do
expect(geozone).to be_valid
end
it "should not be valid without a name" do
geozone.name = nil
expect(geozone).to_not be_valid
end
end