summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-02-21 22:31:38 -0700
committermo khan <mo@mokhan.ca>2014-02-21 22:31:38 -0700
commitb50a9b42f1cddc78f75f75913f39bd19fbf4d8d5 (patch)
treeb112ad20d9bb0c46b63e5bf74ed2d2e050994b11
parent60aa8fa77deaf9d4c90c1ede37caeeff13ee283d (diff)
add well type to licenses table.
-rw-r--r--app/models/license.rb1
-rw-r--r--db/migrate/20140222052902_add_well_type_to_licenses.rb5
-rw-r--r--db/schema.rb3
-rw-r--r--spec/models/license_spec.rb22
4 files changed, 20 insertions, 11 deletions
diff --git a/app/models/license.rb b/app/models/license.rb
index d1ce61d..3da7b24 100644
--- a/app/models/license.rb
+++ b/app/models/license.rb
@@ -1,5 +1,6 @@
class License < ActiveRecord::Base
belongs_to :company
+ belongs_to :well_type
def self.most_recent(page: 1, per_page: 10)
offset = (page - 1) * per_page
diff --git a/db/migrate/20140222052902_add_well_type_to_licenses.rb b/db/migrate/20140222052902_add_well_type_to_licenses.rb
new file mode 100644
index 0000000..bc1dded
--- /dev/null
+++ b/db/migrate/20140222052902_add_well_type_to_licenses.rb
@@ -0,0 +1,5 @@
+class AddWellTypeToLicenses < ActiveRecord::Migration
+ def change
+ add_column :licenses, :well_type_id, :integer
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index aa1c471..d6e0d44 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140222051253) do
+ActiveRecord::Schema.define(version: 20140222052902) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -30,6 +30,7 @@ ActiveRecord::Schema.define(version: 20140222051253) do
t.datetime "expired_at"
t.uuid "company_id"
t.boolean "confidential", default: false
+ t.integer "well_type_id"
end
create_table "well_types", force: true do |t|
diff --git a/spec/models/license_spec.rb b/spec/models/license_spec.rb
index d35c51f..ac4c37c 100644
--- a/spec/models/license_spec.rb
+++ b/spec/models/license_spec.rb
@@ -30,17 +30,19 @@ describe License do
end
end
- describe "model" do
- it "looks like this" do
- company = Company.create(name: 'ABC Resources Ltd.')
- user = User.new(company: company)
- location = Location.new(latitude: 51.06, longitude: -114.09, township: '1')
- license = user.apply_for(WellType::NFW, location)
+ describe "#apply_for" do
+ context "when applying for a license" do
+ it "creates a new license" do
+ company = Company.create(name: 'ABC Resources Ltd.')
+ user = User.new(company: company)
+ location = Location.new(latitude: 51.06, longitude: -114.09, township: '1')
+ license = user.apply_for(WellType::NFW, location)
- license.company.should == user.company
- license.well_type.should == WellType::NFW
- license.location.should == location
- license.applicant.should == user
+ license.company.should == user.company
+ license.well_type.should == WellType::NFW
+ license.location.should == location
+ license.applicant.should == user
+ end
end
end
end