Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Fix profile index #53

Merged
merged 3 commits into from
Jul 17, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app/models/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def approve!
self.update_attribute(:approved, true)
end

def save_with_epic_sort(args={})
def save_with_epic_sort(args={})
assign_attributes(args)
epic_sort
save
Expand All @@ -50,9 +50,11 @@ def save_with_epic_sort(args={})
private
def epic_sort
return if organizer?
epic_length = 80 + Random.rand(20)
bio_length = blurb.present? ? blurb.length : 0
score = (epic_length - bio_length).abs
self.sort_order = score
score = Random.rand(20)
score += 100 + Random.rand(20) if name.blank?
score += Random.rand(20) if blurb.blank?
score += Random.rand(20) if twitter.blank?
score += Random.rand(20) if homepage.blank?
self.sort_order = score
end
end
3 changes: 3 additions & 0 deletions app/views/kaminari/_gap.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
per_page: number of items to fetch per page
remote: data-remote
-%>
<!--
Commenting this out because I don't think we need it... plus it has styling issues.
<span class="page gap"><%= raw(t 'views.pagination.truncate') %></span>
-->
8 changes: 4 additions & 4 deletions spec/models/profile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
@member.save_with_epic_sort

@member.reload
@member.sort_order.should be_between(0, 20)
@member.sort_order.should be_between(0, 100)
end

it "should update attributes when saving with epic" do
@member.save_with_epic_sort({blurb: @blurb, name: 'sample'})

@member.reload
@member.sort_order.should be_between(0, 20)
@member.sort_order.should be_between(0, 100)
@member.name.should == 'sample'
end

Expand All @@ -52,8 +52,8 @@
@member.reload
@member_2.reload

@member.sort_order.should be_between(0, 20)
@member_2.sort_order.should be_between(0, 20)
@member.sort_order.should be_between(0, 100)
@member_2.sort_order.should be_between(0, 100)
end

it "should not show non-organizers more than once" do
Expand Down