Changeset 34
- Timestamp:
- 10/27/07 14:59:54 (13 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 7 modified
-
app/controllers/stages_controller.rb (modified) (1 diff)
-
app/models/stage.rb (modified) (1 diff)
-
app/views/stages/show.rhtml (modified) (1 diff)
-
app/views/stages/tasks.rhtml (added)
-
config/routes.rb (modified) (1 diff)
-
lib/webistrano/deployer.rb (modified) (4 diffs)
-
test/functional/stages_controller_test.rb (modified) (2 diffs)
-
test/unit/webistrano_deployer_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/stages_controller.rb
r1 r34 22 22 def edit 23 23 @stage = current_project.stages.find(params[:id]) 24 end 25 26 # GET /projects/1/stages/1/tasks 27 # GET /projects/1/stages/1/tasks.xml 28 def tasks 29 @stage = current_project.stages.find(params[:id]) 30 @tasks = @stage.list_tasks 31 32 respond_to do |format| 33 format.html # tasks.rhtml 34 format.xml { render :xml => @tasks.to_xml } 35 end 24 36 end 25 37 -
trunk/app/models/stage.rb
r1 r34 117 117 end 118 118 119 # returns a lists of all availabe tasks for this stage 120 def list_tasks 121 d = Deployment.new 122 d.stage = self 123 deployer = Webistrano::Deployer.new(d) 124 deployer.list_tasks.collect { |t| [t.fully_qualified_name, t.description] } 125 end 126 119 127 protected 120 128 def add_deployment_problem(key, desc) -
trunk/app/views/stages/show.rhtml
r26 r34 8 8 <p><%= link_to 'Rollback to previous', new_project_stage_deployment_path(current_project, @stage) + '?task=deploy:rollback', :class => 'arrow_link' %></p> 9 9 <p><%= link_to 'Setup', new_project_stage_deployment_path(current_project, @stage) + '?task=deploy:setup', :class => 'arrow_link' %></p> 10 <p><%= link_to 'List all available tasks', tasks_project_stage_path(current_project, @stage), :class => 'arrow_link' %></p> 10 11 </div> 11 12 -
trunk/config/routes.rb
r9 r34 23 23 projects.resources :project_configurations 24 24 25 projects.resources :stages, :member => {:capfile => :get, :recipes => :any } do |stages|25 projects.resources :stages, :member => {:capfile => :get, :recipes => :any, :tasks => :get} do |stages| 26 26 stages.resources :stage_configurations 27 27 stages.resources :roles -
trunk/lib/webistrano/deployer.rb
r31 r34 22 22 23 23 @deployment = deployment 24 @logger = Webistrano::Logger.new(deployment) 25 @logger.level = Webistrano::Logger::TRACE 26 validate 24 25 if(@deployment.task && !@deployment.new_record?) 26 # a read deployment 27 @logger = Webistrano::Logger.new(deployment) 28 @logger.level = Webistrano::Logger::TRACE 29 validate 30 else 31 # a fake deployment in order to access tasks 32 @logger = Capistrano::Logger.new 33 end 27 34 end 28 35 … … 56 63 set_webistrano_logger(config) 57 64 58 set_pre_vars(config) 59 load_recipes(config) 60 61 set_stage_configuration(config) 62 set_stage_roles(config) 63 set_project_and_stage_names(config) 64 load_project_template_tasks(config) 65 load_stage_custom_recipes(config) 65 set_up_config(config) 66 66 67 67 exchange_real_revision(config) unless (config.fetch(:scm).to_s == 'git') # git cannot do a local query by default … … 86 86 config = Webistrano::Configuration.new 87 87 config.logger = logger 88 config 89 end 90 91 def set_up_config(config) 92 set_pre_vars(config) 93 load_recipes(config) 94 95 set_stage_configuration(config) 96 set_stage_roles(config) 97 set_project_and_stage_names(config) 98 load_project_template_tasks(config) 99 load_stage_custom_recipes(config) 88 100 config 89 101 end … … 213 225 end 214 226 end 227 228 # returns a list of all tasks defined for this deployer 229 def list_tasks 230 config = instantiate_configuration 231 config.load 'deploy' 232 233 set_up_config(config) 234 235 config.task_list(:all) 236 end 215 237 216 238 end -
trunk/test/functional/stages_controller_test.rb
r1 r34 13 13 @response = ActionController::TestResponse.new 14 14 15 @project = create_new_project 15 @project = create_new_project(:template => 'mongrel_rails') 16 16 @stage = create_new_stage(:project => @project) 17 17 @user = login … … 101 101 assert_match "foobar here", @response.body 102 102 end 103 104 def test_should_show_stage_tasks 105 get :tasks, :id => @stage.id, :project_id => @project.id 106 assert_response :success 107 assert_match /webistrano:mongrel:start/, @response.body 108 end 109 103 110 end -
trunk/test/unit/webistrano_deployer_test.rb
r31 r34 674 674 end 675 675 676 def test_list_tasks 677 d = Deployment.new 678 d.stage = @stage 679 deployer = Webistrano::Deployer.new(d) 680 681 assert_not_nil deployer.list_tasks 682 assert_equal 23, deployer.list_tasks.size 683 assert_equal 23, @stage.list_tasks.size 684 deployer.list_tasks.each{|t| assert t.is_a?(Capistrano::TaskDefinition) } 685 686 # add a stage recipe 687 recipe_body = <<-EOS 688 namespace :foo do 689 task :bar do 690 run 'foobar' 691 end 692 end 693 EOS 694 recipe = create_new_recipe(:name => 'A new recipe', :body => recipe_body) 695 @stage.recipes << recipe 696 697 assert_equal 24, deployer.list_tasks.size 698 assert_equal 24, @stage.list_tasks.size 699 assert_equal 1, deployer.list_tasks.delete_if{|t| t.fully_qualified_name != 'foo:bar'}.size 700 assert_equal 1, @stage.list_tasks.delete_if{|t| t[0] != 'foo:bar'}.size 701 end 702 676 703 677 704 protected
