adds Geozones 🗺
This commit is contained in:
3
app/models/geozone.rb
Normal file
3
app/models/geozone.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class Geozone < ActiveRecord::Base
|
||||||
|
validates :name, presence: true
|
||||||
|
end
|
||||||
11
db/migrate/20160105121132_create_geozones.rb
Normal file
11
db/migrate/20160105121132_create_geozones.rb
Normal 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
|
||||||
@@ -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", "flaggable_type", "flaggable_id"], name: "access_inappropiate_flags", using: :btree
|
||||||
add_index "flags", ["user_id"], name: "index_flags_on_user_id", 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|
|
create_table "identities", force: :cascade do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.string "provider"
|
t.string "provider"
|
||||||
|
|||||||
@@ -303,4 +303,7 @@ FactoryGirl.define do
|
|||||||
association :notifiable, factory: :proposal
|
association :notifiable, factory: :proposal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :geozone do
|
||||||
|
sequence(:name) { |n| "District #{n}" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
14
spec/models/geozone_spec.rb
Normal file
14
spec/models/geozone_spec.rb
Normal 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
|
||||||
Reference in New Issue
Block a user