Skip to content

Commit

Permalink
on home page only projects status is reloaded and its done via ajax
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrec1 committed Oct 21, 2009
1 parent c48325c commit 2812e67
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
5 changes: 5 additions & 0 deletions app/controllers/projects_controller.rb
Expand Up @@ -4,4 +4,9 @@ def build
Project.find(params[:project_id]).send_later :build
render :nothing => true
end

def status
@projects = Project.all
render :partial => "shared/projects"
end
end
7 changes: 3 additions & 4 deletions app/views/projects/index.html.haml
@@ -1,6 +1,5 @@
%meta{'http-equiv' => "Refresh", :content => "5"}
.projects
- for project in @projects do
= link_to render(:partial => "shared/project", :locals => {:project => project}), project_path(project)
.projects= render :partial => "shared/projects"

= periodically_call_remote :url => projects_status_path, :update => '.projects'

= link_to I18n.t(:new_project), new_project_path
2 changes: 2 additions & 0 deletions app/views/shared/_projects.haml
@@ -0,0 +1,2 @@
- for project in @projects do
= link_to render(:partial => "shared/project", :locals => {:project => project}), project_path(project)
4 changes: 3 additions & 1 deletion config/routes.rb
Expand Up @@ -3,8 +3,10 @@
project.resources :builds
project.connect 'build', :controller => 'projects', :action => 'build'
end
map.root :controller => "projects"
map.root :controller => "projects"
map.metrics "/projects/:name/tmp/metric_fu/output/index.html", :controller => nil
map.specs "/projects/:name/doc/specs.html", :controller => nil
map.features "/projects/:name/doc/features.html", :controller => nil

map.projects_status "/projects/status", :controller => :projects, :action => :status
end
16 changes: 16 additions & 0 deletions spec/controllers/projects_controller_spec.rb
Expand Up @@ -10,4 +10,20 @@
get :build, :project_id => project_id
end
end

context "responding to status" do
before :each do
Project.stub!(:all).and_return(@projects = [Project.new])
end

it "should return the status html panel for all the projects" do
get :status
response.should render_template("shared/_projects")
end

it "should assign all the projects to @projects" do
get :status
assigns[:projects].should eql(@projects)
end
end
end

0 comments on commit 2812e67

Please sign in to comment.