From ab486aa8118604067bc74e5c0b914192587bddaf Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 17 Jun 2014 15:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85user=5Fscore=5Fdetails=20Mode?= =?UTF-8?q?l=E5=8F=8A=E6=95=B0=E6=8D=AE=E8=BF=81=E7=A7=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user_score_details.rb | 4 +++ ...0140617013146_create_user_score_details.rb | 19 +++++++++++++ test/fixtures/user_score_details.yml | 27 +++++++++++++++++++ test/unit/user_score_details_test.rb | 7 +++++ 4 files changed, 57 insertions(+) create mode 100644 app/models/user_score_details.rb create mode 100644 db/migrate/20140617013146_create_user_score_details.rb create mode 100644 test/fixtures/user_score_details.yml create mode 100644 test/unit/user_score_details_test.rb diff --git a/app/models/user_score_details.rb b/app/models/user_score_details.rb new file mode 100644 index 00000000..61d5d098 --- /dev/null +++ b/app/models/user_score_details.rb @@ -0,0 +1,4 @@ +class UserScoreDetails < ActiveRecord::Base + attr_accessible :current_user_id, :current_user_level, :new_score, :old_score, :score_action, :score_changeable_obj_id, :score_changeable_obj_type, :score_type, :target_user_id, :target_user_level, :user_id + belongs_to :score_changeable_obj,:polymorphic => true +end diff --git a/db/migrate/20140617013146_create_user_score_details.rb b/db/migrate/20140617013146_create_user_score_details.rb new file mode 100644 index 00000000..e830e3e0 --- /dev/null +++ b/db/migrate/20140617013146_create_user_score_details.rb @@ -0,0 +1,19 @@ +class CreateUserScoreDetails < ActiveRecord::Migration + def change + create_table :user_score_details do |t| + t.integer :current_user_id + t.integer :target_user_id + t.string :score_type + t.string :score_action + t.integer :user_id + t.integer :old_score + t.integer :new_score + t.integer :current_user_level + t.integer :target_user_level + t.integer :score_changeable_obj_id + t.string :score_changeable_obj_type + + t.timestamps + end + end +end diff --git a/test/fixtures/user_score_details.yml b/test/fixtures/user_score_details.yml new file mode 100644 index 00000000..ac8da802 --- /dev/null +++ b/test/fixtures/user_score_details.yml @@ -0,0 +1,27 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + current_user_id: 1 + target_user_id: 1 + score_type: MyString + score_action: MyString + user_id: 1 + old_score: 1 + new_score: 1 + current_user_level: 1 + target_user_level: 1 + score_changeable_obj_id: 1 + score_changeable_obj_type: MyString + +two: + current_user_id: 1 + target_user_id: 1 + score_type: MyString + score_action: MyString + user_id: 1 + old_score: 1 + new_score: 1 + current_user_level: 1 + target_user_level: 1 + score_changeable_obj_id: 1 + score_changeable_obj_type: MyString diff --git a/test/unit/user_score_details_test.rb b/test/unit/user_score_details_test.rb new file mode 100644 index 00000000..657a9c2f --- /dev/null +++ b/test/unit/user_score_details_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class UserScoreDetailsTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end