Commit 020e1a8eee37e6a0acba9833f8abb5dfc80eb248
1 parent
83c1194d
Exists in
master
and in
4 other branches
dashboard
Showing
7 changed files
with
115 additions
and
22 deletions
Show diff stats
app/helpers/dashboard_helper.rb
1 | module DashboardHelper | 1 | module DashboardHelper |
2 | - def path_to_object(project, object) | 2 | + def dashboard_feed_path(project, object) |
3 | case object.class.name.to_s | 3 | case object.class.name.to_s |
4 | when "Issue" then project_issues_path(project, project.issues.find(object.id)) | 4 | when "Issue" then project_issues_path(project, project.issues.find(object.id)) |
5 | when "Grit::Commit" then project_commit_path(project, project.repo.commits(object.id).first) | 5 | when "Grit::Commit" then project_commit_path(project, project.repo.commits(object.id).first) |
6 | - else "#" | 6 | + when "Note" |
7 | + then | ||
8 | + note = object | ||
9 | + case note.noteable_type | ||
10 | + when "Issue" then project_issue_path(project, note.noteable_id) | ||
11 | + when "Snippet" then project_snippet_path(project, note.noteable_id) | ||
12 | + when "Commit" then project_commit_path(project, :id => note.noteable_id) | ||
13 | + else wall_project_path(project) | ||
14 | + end | ||
15 | + else "#" | ||
7 | end | 16 | end |
17 | + rescue | ||
18 | + "#" | ||
19 | + end | ||
20 | + | ||
21 | + def dashboard_feed_title(object) | ||
22 | + title = case object.class.name.to_s | ||
23 | + when "Note" then markdown(object.note) | ||
24 | + when "Issue" then object.title | ||
25 | + when "Grit::Commit" then object.safe_message | ||
26 | + else "" | ||
27 | + end | ||
28 | + "[#{object.class.name}] #{truncate(sanitize(title, :tags => []), :length => 60)} " | ||
8 | end | 29 | end |
9 | end | 30 | end |
app/models/project.rb
@@ -136,7 +136,7 @@ class Project < ActiveRecord::Base | @@ -136,7 +136,7 @@ class Project < ActiveRecord::Base | ||
136 | notes.fresh.limit(n) | 136 | notes.fresh.limit(n) |
137 | ].compact.flatten.sort do |x, y| | 137 | ].compact.flatten.sort do |x, y| |
138 | y.created_at <=> x.created_at | 138 | y.created_at <=> x.created_at |
139 | - end[0..n] | 139 | + end[0...n] |
140 | end | 140 | end |
141 | 141 | ||
142 | def commit(commit_id = nil) | 142 | def commit(commit_id = nil) |
@@ -160,7 +160,7 @@ class Project < ActiveRecord::Base | @@ -160,7 +160,7 @@ class Project < ActiveRecord::Base | ||
160 | y.committed_date <=> x.committed_date | 160 | y.committed_date <=> x.committed_date |
161 | end | 161 | end |
162 | 162 | ||
163 | - commits[0..n] | 163 | + commits[0...n] |
164 | end | 164 | end |
165 | 165 | ||
166 | def commits_since(date) | 166 | def commits_since(date) |
app/views/dashboard/index.html.haml
@@ -3,12 +3,13 @@ | @@ -3,12 +3,13 @@ | ||
3 | #dashboard-content.dashboard-content.content | 3 | #dashboard-content.dashboard-content.content |
4 | %aside | 4 | %aside |
5 | %h4 | 5 | %h4 |
6 | - %a.button-small.button-green{:href => ""} New Repository | 6 | + - if current_user.can_create_project? |
7 | + %a.button-small.button-green{:href => new_project_path} New Repository | ||
7 | Your Repositories | 8 | Your Repositories |
8 | %ol.project-list | 9 | %ol.project-list |
9 | - @projects.each do |project| | 10 | - @projects.each do |project| |
10 | %li | 11 | %li |
11 | - %a{:href => "#"} | 12 | + %a{:href => project_path(project)} |
12 | %span.arrow → | 13 | %span.arrow → |
13 | %span.project-name= project.name | 14 | %span.project-name= project.name |
14 | %span.time | 15 | %span.time |
@@ -18,19 +19,20 @@ | @@ -18,19 +19,20 @@ | ||
18 | %h2.icon | 19 | %h2.icon |
19 | %span> | 20 | %span> |
20 | Dashboard | 21 | Dashboard |
21 | - - @active_projects.each do |project| | 22 | + - @active_projects.first(3).each do |project| |
22 | .project-box.project-updates.ui-box.ui-box-small.ui-box-big | 23 | .project-box.project-updates.ui-box.ui-box-small.ui-box-big |
23 | %h3= project.name | 24 | %h3= project.name |
24 | .data | 25 | .data |
25 | - project.updates.each do |update| | 26 | - project.updates.each do |update| |
26 | - %a.project-update{:href => path_to_object(project, update)} | ||
27 | - %img{:src => "http://placehold.it/40x40"} | ||
28 | - %span.update-title [#{update.class.name}] added a matcher that helps debugging matching problems | ||
29 | - %span.update-author | ||
30 | - %strong= update.author.name | ||
31 | - authored | ||
32 | - = time_ago_in_words(update.created_at) | ||
33 | - ago | 27 | + %a.project-update{:href => dashboard_feed_path(project, update)} |
28 | + = image_tag gravatar_icon(update.author.email), :class => "left", :width => 40 | ||
29 | + %span.update-title | ||
30 | + = dashboard_feed_title(update) | ||
31 | + %span.update-author | ||
32 | + %strong= update.author.name | ||
33 | + authored | ||
34 | + = time_ago_in_words(update.created_at) | ||
35 | + ago | ||
34 | %br | 36 | %br |
35 | / .project-update | 37 | / .project-update |
36 | / .project-updates | 38 | / .project-updates |
app/views/layouts/_head_panel.html.erb
@@ -22,9 +22,9 @@ | @@ -22,9 +22,9 @@ | ||
22 | <%= link_to projects_path, :class => current_page?(projects_path) ? "current project" : "project" do %> | 22 | <%= link_to projects_path, :class => current_page?(projects_path) ? "current project" : "project" do %> |
23 | <span></span>Projects | 23 | <span></span>Projects |
24 | <% end %> | 24 | <% end %> |
25 | - <%= link_to( admin_root_path, :class => admin_namespace? ? "current admin" : "admin" ) do %> | 25 | + <%= link_to((current_user.is_admin? ? admin_root_path : "#"), :class => (admin_namespace? ? "current admin" : "admin")) do %> |
26 | <span></span>Admin | 26 | <span></span>Admin |
27 | - <% end if current_user.is_admin? %> | 27 | + <% end %> |
28 | </nav> | 28 | </nav> |
29 | </header> | 29 | </header> |
30 | <!-- eo Page Header --> | 30 | <!-- eo Page Header --> |
spec/models/project_spec.rb
@@ -62,6 +62,51 @@ describe Project do | @@ -62,6 +62,51 @@ describe Project do | ||
62 | end | 62 | end |
63 | end | 63 | end |
64 | 64 | ||
65 | + describe "updates" do | ||
66 | + let(:project) { Factory :project } | ||
67 | + | ||
68 | + before do | ||
69 | + @issue = Factory :issue, | ||
70 | + :project => project, | ||
71 | + :author => Factory(:user), | ||
72 | + :assignee => Factory(:user) | ||
73 | + | ||
74 | + @note = Factory :note, | ||
75 | + :project => project, | ||
76 | + :author => Factory(:user) | ||
77 | + | ||
78 | + @commit = project.fresh_commits(1).first | ||
79 | + end | ||
80 | + | ||
81 | + describe "return commit, note & issue" do | ||
82 | + it { project.updates(3).count.should == 3 } | ||
83 | + it { project.updates(3).last.id.should == @commit.id } | ||
84 | + it { project.updates(3).include?(@issue).should be_true } | ||
85 | + it { project.updates(3).include?(@note).should be_true } | ||
86 | + end | ||
87 | + end | ||
88 | + | ||
89 | + describe "last_activity" do | ||
90 | + let(:project) { Factory :project } | ||
91 | + | ||
92 | + before do | ||
93 | + @note = Factory :note, | ||
94 | + :project => project, | ||
95 | + :author => Factory(:user) | ||
96 | + end | ||
97 | + | ||
98 | + it { project.last_activity.should == @note } | ||
99 | + it { project.last_activity_date.to_s.should == @note.created_at.to_s } | ||
100 | + end | ||
101 | + | ||
102 | + describe "fresh commits" do | ||
103 | + let(:project) { Factory :project } | ||
104 | + | ||
105 | + it { project.fresh_commits(3).count.should == 3 } | ||
106 | + it { project.fresh_commits.first.id.should == "2fb376f61875b58bceee0492e270e9c805294b1a" } | ||
107 | + it { project.fresh_commits.last.id.should == "0dac878dbfe0b9c6104a87d65fe999149a8d862c" } | ||
108 | + end | ||
109 | + | ||
65 | describe "Git methods" do | 110 | describe "Git methods" do |
66 | let(:project) { Factory :project } | 111 | let(:project) { Factory :project } |
67 | 112 |
@@ -0,0 +1,30 @@ | @@ -0,0 +1,30 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe "Dashboard" do | ||
4 | + before { login_as :user } | ||
5 | + | ||
6 | + describe "GET /dashboard" do | ||
7 | + before do | ||
8 | + @project = Factory :project | ||
9 | + @project.add_access(@user, :read, :write) | ||
10 | + visit dashboard_path | ||
11 | + end | ||
12 | + | ||
13 | + it "should be on dashboard page" do | ||
14 | + current_path.should == dashboard_path | ||
15 | + end | ||
16 | + | ||
17 | + it "should have projects panel" do | ||
18 | + within ".project-list" do | ||
19 | + page.should have_content(@project.name) | ||
20 | + end | ||
21 | + end | ||
22 | + | ||
23 | + it "should have news feed" do | ||
24 | + within "#news-feed" do | ||
25 | + page.should have_content(@project.commit.author.name) | ||
26 | + page.should have_content(@project.commit.safe_message) | ||
27 | + end | ||
28 | + end | ||
29 | + end | ||
30 | +end |
spec/requests/issues_spec.rb
@@ -105,11 +105,6 @@ describe "Issues" do | @@ -105,11 +105,6 @@ describe "Issues" do | ||
105 | Notify.should_not_receive(:new_issue_email) | 105 | Notify.should_not_receive(:new_issue_email) |
106 | click_button "Save" | 106 | click_button "Save" |
107 | end | 107 | end |
108 | - | ||
109 | - it "should send valid email to user with email & password" do | ||
110 | - click_button "Save" | ||
111 | - ActionMailer::Base.deliveries.last.should be_nil | ||
112 | - end | ||
113 | end | 108 | end |
114 | 109 | ||
115 | describe 'assign to other' do | 110 | describe 'assign to other' do |