FIX: suspended users cannot be trust level 3
This commit is contained in:
parent
6b41c6b335
commit
ec42b61a4d
|
@ -98,6 +98,9 @@
|
|||
{{/unless}}
|
||||
{{else}}
|
||||
<i class="fa fa-times"></i> {{i18n admin.user.tl3_requirements.does_not_qualify}}
|
||||
{{#if suspended}}
|
||||
{{i18n user.suspended_notice date="suspendedTillDate"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</p>
|
||||
</div>
|
||||
|
|
|
@ -23,19 +23,21 @@ class LeaderRequirements
|
|||
end
|
||||
|
||||
def requirements_met?
|
||||
!@user.suspended? &&
|
||||
days_visited >= min_days_visited &&
|
||||
num_topics_replied_to >= min_topics_replied_to &&
|
||||
topics_viewed >= min_topics_viewed &&
|
||||
posts_read >= min_posts_read &&
|
||||
num_flagged_posts <= max_flagged_posts &&
|
||||
num_flagged_by_users <= max_flagged_by_users &&
|
||||
topics_viewed_all_time >= min_topics_viewed_all_time &&
|
||||
posts_read_all_time >= min_posts_read_all_time &&
|
||||
num_likes_given >= min_likes_given &&
|
||||
num_likes_received >= min_likes_received
|
||||
num_topics_replied_to >= min_topics_replied_to &&
|
||||
topics_viewed >= min_topics_viewed &&
|
||||
posts_read >= min_posts_read &&
|
||||
num_flagged_posts <= max_flagged_posts &&
|
||||
num_flagged_by_users <= max_flagged_by_users &&
|
||||
topics_viewed_all_time >= min_topics_viewed_all_time &&
|
||||
posts_read_all_time >= min_posts_read_all_time &&
|
||||
num_likes_given >= min_likes_given &&
|
||||
num_likes_received >= min_likes_received
|
||||
end
|
||||
|
||||
def requirements_lost?
|
||||
@user.suspended? ||
|
||||
days_visited < min_days_visited * LOW_WATER_MARK ||
|
||||
num_topics_replied_to < min_topics_replied_to * LOW_WATER_MARK ||
|
||||
topics_viewed < min_topics_viewed * LOW_WATER_MARK ||
|
||||
|
|
|
@ -280,6 +280,16 @@ describe LeaderRequirements do
|
|||
leader_requirements.stubs(:num_likes_received).returns(17)
|
||||
leader_requirements.requirements_lost?.should == true
|
||||
end
|
||||
|
||||
it "are not met if suspended" do
|
||||
user.stubs(:suspended?).returns(true)
|
||||
leader_requirements.requirements_met?.should == false
|
||||
end
|
||||
|
||||
it "are lost if suspended" do
|
||||
user.stubs(:suspended?).returns(true)
|
||||
leader_requirements.requirements_lost?.should == true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue