Commit f61d401ec8f1d11b47a71ab590f81c7190c0c314
1 parent
ebd4f04a
Exists in
temp_ratings
Add ratings from persons to communities
Signed-off-by: DylanGuedes <djmgguedes@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Filipe Ribeiro <firibeiro77@live.com>
Showing
6 changed files
with
62 additions
and
0 deletions
Show diff stats
plugins/communities_ratings/db/migrate/20150701122801_create_community_ratings.rb
0 → 100644
plugins/communities_ratings/lib/communities_ratings_plugin.rb
0 → 100644
@@ -0,0 +1,15 @@ | @@ -0,0 +1,15 @@ | ||
1 | +class CommunityRating < ActiveRecord::Base | ||
2 | + belongs_to :person | ||
3 | + belongs_to :community | ||
4 | + | ||
5 | + attr_accessible :value, :person, :community | ||
6 | + | ||
7 | + validates :value, | ||
8 | + :presence => true, :inclusion => { | ||
9 | + in: 0..5, message: _("must be between 0 and 5") | ||
10 | + } | ||
11 | + | ||
12 | + validates :community_id, :person_id, | ||
13 | + :presence => true | ||
14 | + | ||
15 | +end |
plugins/communities_ratings/test/unit/community_rating_test.rb
0 → 100644
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +require 'test_helper' | ||
2 | + | ||
3 | +class CommunityRatingTest < ActiveSupport::TestCase | ||
4 | + test "The value must be between 0 and 5" do | ||
5 | + cr1 = CommunityRating.new :value => -1 | ||
6 | + cr2 = CommunityRating.new :value => 6 | ||
7 | + | ||
8 | + assert_equal false, cr1.valid? | ||
9 | + assert_equal false, cr2.valid? | ||
10 | + | ||
11 | + assert_equal true, cr1.errors[:value].include?("must be between 0 and 5") | ||
12 | + assert_equal true, cr2.errors[:value].include?("must be between 0 and 5") | ||
13 | + end | ||
14 | +end |