diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 73ae44b4..792a1776 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -23,6 +23,7 @@ class Attachment < ActiveRecord::Base belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" + belongs_to :attachmentstype, :foreign_key => "attachtype" validates_presence_of :filename, :author validates_length_of :filename, :maximum => 255 diff --git a/app/models/attachmentstype.rb b/app/models/attachmentstype.rb new file mode 100644 index 00000000..1d3c2cfc --- /dev/null +++ b/app/models/attachmentstype.rb @@ -0,0 +1,3 @@ +class Attachmentstype < ActiveRecord::Base + attr_accessible :typeId, :typeName +end diff --git a/db/migrate/20140508030039_create_attachmentstypes.rb b/db/migrate/20140508030039_create_attachmentstypes.rb new file mode 100644 index 00000000..62568634 --- /dev/null +++ b/db/migrate/20140508030039_create_attachmentstypes.rb @@ -0,0 +1,12 @@ +class CreateAttachmentstypes < ActiveRecord::Migration + def self.up + create_table :attachmentstypes do |t| + t.column :typeId, :integer, :null => false + t.column :typeName, :string, :limit =>50 + end + end + + def self.down + drop_table :attachmentstypes + end +end \ No newline at end of file diff --git a/db/migrate/20140508030358_add_attachtype_to_attachments.rb b/db/migrate/20140508030358_add_attachtype_to_attachments.rb new file mode 100644 index 00000000..24a98839 --- /dev/null +++ b/db/migrate/20140508030358_add_attachtype_to_attachments.rb @@ -0,0 +1,5 @@ +class AddAttachtypeToAttachments < ActiveRecord::Migration + def change + add_column :attachments, :attachtype, :int + end +end diff --git a/db/schema.rb b/db/schema.rb index fe23a1ca..2ff8ca00 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140428013546) do +ActiveRecord::Schema.define(:version => 20140508030358) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -36,6 +36,7 @@ ActiveRecord::Schema.define(:version => 20140428013546) do t.datetime "created_on" t.string "description" t.string "disk_directory" + t.integer "attachtype" end add_index "attachments", ["author_id"], :name => "index_attachments_on_author_id" @@ -755,11 +756,6 @@ ActiveRecord::Schema.define(:version => 20140428013546) do add_index "time_entries", ["project_id"], :name => "time_entries_project_id" add_index "time_entries", ["user_id"], :name => "index_time_entries_on_user_id" - create_table "tmp", :force => true do |t| - t.string "name" - t.string "part_number" - end - create_table "tokens", :force => true do |t| t.integer "user_id", :default => 0, :null => false t.string "action", :limit => 30, :default => "", :null => false @@ -966,10 +962,4 @@ ActiveRecord::Schema.define(:version => 20140428013546) do add_index "workflows", ["role_id", "tracker_id", "old_status_id"], :name => "wkfs_role_tracker_old_status" add_index "workflows", ["role_id"], :name => "index_workflows_on_role_id" - create_table "yans", :force => true do |t| - t.string "name" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - end diff --git a/test/fixtures/attachmentstypes.yml b/test/fixtures/attachmentstypes.yml new file mode 100644 index 00000000..429b31b4 --- /dev/null +++ b/test/fixtures/attachmentstypes.yml @@ -0,0 +1,9 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + typeId: + typeName: + +two: + typeId: + typeName: diff --git a/test/unit/attachmentstype_test.rb b/test/unit/attachmentstype_test.rb new file mode 100644 index 00000000..0dcee447 --- /dev/null +++ b/test/unit/attachmentstype_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class AttachmentstypeTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end