Class: Rutema::UI::MainController
- Inherits:
-
Ramaze::Controller
- Object
- Ramaze::Controller
- Rutema::UI::MainController
- Includes:
- ViewUtilities
- Defined in:
- lib/rutemaweb/ramaze_controller.rb
Constant Summary collapse
- PAGE_SIZE =
The number of items to show in lists
10
Constants included from ViewUtilities
ViewUtilities::IMG_LEFT, ViewUtilities::IMG_RIGHT, ViewUtilities::IMG_SCE_ERROR, ViewUtilities::IMG_SCE_OK, ViewUtilities::IMG_SCE_WARN, ViewUtilities::IMG_STEP_ERROR, ViewUtilities::IMG_STEP_OK, ViewUtilities::IMG_STEP_WARN, ViewUtilities::TIME_FORMAT
Instance Method Summary collapse
- #error ⇒ Object
- #index ⇒ Object
-
#run(run_id = "") ⇒ Object
Displays the details of a run.
-
#runs(page = 0) ⇒ Object
Displays a paginated list of all runs.
-
#scenario(scenario_id = "") ⇒ Object
Displays the details of a scenario.
-
#scenarios(page = 0) ⇒ Object
Displays a paginated list of scenarios.
- #settings ⇒ Object
Methods included from ViewUtilities
#context_table, #run_link, #run_page_link, #run_summary, #run_url, #scenario_page_link, #scenario_status, #status_icon, #time_formatted
Instance Method Details
#error ⇒ Object
203 204 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 203 def error end |
#index ⇒ Object
118 119 120 121 122 123 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 118 def index @title="Rutema" @panel_content=panel_runs @content_title="Welcome to Rutema" @content="<p>This is the rutema web interface.<br/>It allows you to browse the contents of the test results database.</p><p>Currently you can view the results for each separate run, the results for a specific scenario (a complete list of all steps executed in the scenario with standard and error output logs) or the complete execution history of a scenario.</p><p>The panel on the left shows a list of the ten most recent runs.</p>" end |
#run(run_id = "") ⇒ Object
Displays the details of a run
Routes to /runs if no id is provided
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 145 def run run_id="" @panel_content=nil if !run_id.empty? @panel_content=panel_runs @title="Run #{run_id}" @content_title="Summary of run #{run_id}" @content=single_run(run_id) else runs end end |
#runs(page = 0) ⇒ Object
Displays a paginated list of all runs
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 125 def runs page=0 @title="All runs" @content_title="Runs" @content="" dt=[] total_pages=(Rutema::Model::Run.count/PAGE_SIZE)+1 page_number=validated_page_number(page,total_pages) runs=Rutema::Model::Run.find_on_page(page_number,PAGE_SIZE) runs.each do |r| dt<<[status_icon(r.status),run_summary(r)] end @content<< Ruport::Data::Table.new(:data=>dt,:column_names=>["status","description"]).to_html @content<<"<br/>" @content<<run_page_link(page_number,total_pages) return @content end |
#scenario(scenario_id = "") ⇒ Object
Displays the details of a scenario
190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 190 def scenario scenario_id="" @panel_content="" if !scenario_id.empty? if scenario_id.to_i==0 @content=scenario_by_name(scenario_id) else @content=scenario_in_a_run(scenario_id.to_i) end else return scenarios end end |
#scenarios(page = 0) ⇒ Object
Displays a paginated list of scenarios
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 158 def scenarios page=0 @title="All scenarios" @content_title="Scenarios" @content="" @panel_content=panel_runs runs=Hash.new #find which runs contain each scenario with the same name Ramaze::Log.debug("Getting the runs for each scenario") conditions="name NOT LIKE '%_teardown' AND name NOT LIKE '%_setup'" Rutema::Model::Scenario.find(:all, :conditions=>conditions).each do |sc| nm=sc.name runs[nm]||=[] runs[nm]<<sc.run.id end #the size of the hash is also the number of unique scenario names total_pages=(runs.size / PAGE_SIZE)+1 page_number=validated_page_number(page,total_pages) Ramaze::Log.debug("Getting scenarios for page #{page_number}") scens=Rutema::Model::Scenario.find_on_page(page_number,PAGE_SIZE,conditions) #and now build the table data dt=Array.new scens.each do |sc| nm=sc.name #sort the run ids runs[nm]=runs[nm].sort.reverse[0..4] dt<<["<a href=\"/scenario/#{nm}\">#{nm}</a> : ",sc.title,runs[nm].map{|r| " <a href=\"/run/#{r}\">#{r}</a>"}.join(" "),"#{failure_rate(sc.name)}%"] end @content<<Ruport::Data::Table.new(:data=>dt,:column_names=>["name","title","last 5 runs","failure rate"]).to_html @content<<"<br/>" @content<<scenario_page_link(page_number,total_pages) end |
#settings ⇒ Object
206 207 208 209 210 211 212 213 |
# File 'lib/rutemaweb/ramaze_controller.rb', line 206 def settings if request.post? end @panel_content=panel_runs() @title="Settings" @content_title="Settings" @content="" end |