Commit e0c43c46 authored by randx's avatar randx

Added project has_one :last_event assoc. Fixed tab line-height after...

Added project has_one :last_event assoc. Fixed tab line-height after font-awesome. Increased projects per page on dashboard
parent a9a3480d
......@@ -46,6 +46,9 @@
color:#888;
text-shadow:0 1px 1px #fff;
}
i[class^="icon-"] {
line-height:14px;
}
}
&.active {
> a {
......
......@@ -4,7 +4,7 @@ class DashboardController < ApplicationController
def index
@groups = Group.where(id: current_user.projects.pluck(:group_id))
@projects = current_user.projects_with_events
@projects = @projects.page(params[:page]).per(20)
@projects = @projects.page(params[:page]).per(30)
@events = Event.in_projects(current_user.project_ids).limit(20).offset(params[:offset] || 0)
@last_push = current_user.recent_push
......
......@@ -25,6 +25,7 @@ class Project < ActiveRecord::Base
has_many :hooks, dependent: :destroy, class_name: "ProjectHook"
has_many :wikis, dependent: :destroy
has_many :protected_branches, dependent: :destroy
has_one :last_event, class_name: 'Event', order: 'events.created_at DESC', foreign_key: 'project_id'
delegate :name, to: :owner, allow_nil: true, prefix: true
......@@ -141,15 +142,11 @@ class Project < ActiveRecord::Base
end
def last_activity
events.order("created_at ASC").last
last_event
end
def last_activity_date
if events.last
events.last.created_at
else
updated_at
end
last_event.try(:created_at) || updated_at
end
def wiki_notes
......
......@@ -169,10 +169,9 @@ describe Project do
describe "last_activity" do
let(:project) { Factory :project }
let(:last_event) { double }
before do
project.stub_chain(:events, :order).and_return( [ double, double, last_event ] )
project.stub(last_event: double)
end
it { project.last_activity.should == last_event }
......@@ -182,8 +181,8 @@ describe Project do
let(:project) { Factory :project }
it 'returns the creation date of the project\'s last event if present' do
last_event = double(created_at: 'now')
project.stub(:events).and_return( [double, double, last_event] )
last_event = double(created_at: Time.now)
project.stub(last_event: last_event)
project.last_activity_date.should == last_event.created_at
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment