[from now] 2013/09/28 15:35:06

diff --git a/Gemfile b/Gemfile
index ca82d4b..f94e4d3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -46,13 +46,14 @@ group :development, :test do
   gem 'hirb'
   gem 'hirb-unicode'
   gem 'awesome_print'
+
+  gem 'rspec-rails'
+  gem 'factory_girl_rails'
 end

 group :test do
-  gem 'rspec-rails'
   gem 'shoulda-matchers'
   gem 'database_rewinder'
-  gem 'factory_girl_rails'
   gem 'forgery'
   gem 'capybara'

diff --git a/app/models/upload.rb b/app/models/upload.rb
new file mode 100644
index 0000000..50cc73a
--- /dev/null
+++ b/app/models/upload.rb
@@ -0,0 +1,5 @@
+class Upload < ActiveRecord::Base
+  validates :filename, presence: true
+  validates :ext, presence: true
+  validates :ip, presence: true
+end
diff --git a/db/migrate/20130928060122_create_uploads.rb b/db/migrate/20130928060122_create_uploads.rb
new file mode 100644
index 0000000..93c2bea
--- /dev/null
+++ b/db/migrate/20130928060122_create_uploads.rb
@@ -0,0 +1,14 @@
+class CreateUploads < ActiveRecord::Migration
+  def change
+    create_table :uploads do |t|
+      t.string :filename,  presence: true
+      t.string :ext,      presence: true
+      t.string :comment
+      t.string :ip,       presence: true
+      t.integer :view_count
+      t.binary :data, :limit => 5.megabytes
+
+      t.timestamps
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 4dfbb16..ecf30b0 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,6 +11,17 @@
 #
 # It's strongly recommended that you check this file into your version control system.

-ActiveRecord::Schema.define(version: 0) do
+ActiveRecord::Schema.define(version: 20130928060122) do
+
+  create_table "uploads", force: true do |t|
+    t.string   "filename"
+    t.string   "ext"
+    t.string   "comment"
+    t.string   "ip"
+    t.integer  "view_count"
+    t.binary   "data",       limit: 5242880
+    t.datetime "created_at"
+    t.datetime "updated_at"
+  end

 end
diff --git a/spec/factories/uploads.rb b/spec/factories/uploads.rb
new file mode 100644
index 0000000..4b1ad0b
--- /dev/null
+++ b/spec/factories/uploads.rb
@@ -0,0 +1,11 @@
+# Read about factories at https://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+  factory :upload do
+    filename { Forgery(:basic).text+".jpg" }
+    comment { Forgery(:basic).text(at_most: 200) }
+    ip { Forgery(:internet).ip_v4 }
+    # ext
+    # view_count
+  end
+end
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb
index f582e25..5d47e25 100644
--- a/spec/models/upload_spec.rb
+++ b/spec/models/upload_spec.rb
@@ -1,5 +1,16 @@
 require 'spec_helper'

 describe Upload do
-  pending "add some examples to (or delete) #{__FILE__}"
+  describe "validations" do
+    context "valid" do
+      subject { FactoryGirl.build(:upload, ext: ".jpg") }
+      it { should be_valid }
+    end
+    context "invalid" do
+      subject { FactoryGirl.build :upload }
+      it { subject.filename = "" ; should_not be_valid }
+      it { subject.ext = "" ; should_not be_valid }
+      it { subject.ip = "" ; should_not be_valid }
+    end
+  end
 end