Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: rideconnection/wiseguide
base: 21ec455e04
...
head fork: rideconnection/wiseguide
compare: a387a03cdd
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 16 files changed
  • 0 commit comments
  • 1 contributor
View
1  Gemfile
@@ -50,6 +50,7 @@ group :development, :test do
gem "database_cleaner"
gem "ruby-debug19", :require => "ruby-debug"
gem "sqlite3-ruby", :require => "sqlite3"
+ gem "pdf-inspector", :require => "pdf/inspector"
end
group :development, :test, :staging do
View
3  Gemfile.lock
@@ -153,6 +153,8 @@ GEM
activesupport (>= 2.3.2)
cocaine (>= 0.0.2)
mime-types
+ pdf-inspector (1.0.1)
+ pdf-reader (>= 0.9.0)
pdf-reader (1.0.0)
Ascii85 (~> 1.0.0)
ruby-rc4
@@ -253,6 +255,7 @@ DEPENDENCIES
jquery-rails (>= 0.2.6)
launchy
paperclip
+ pdf-inspector
pdf-reader
pg
prawn!
View
1  app/controllers/contacts_controller.rb
@@ -42,7 +42,6 @@ def update
def destroy
@contact.destroy
-
redirect_to kase_path(@contact.kase)
end
View
2  app/controllers/outcomes_controller.rb
@@ -39,7 +39,7 @@ def update
def destroy
@outcome.destroy
- redirect_to(@outcome.kase, :notice => 'Outcome was successfully deleted.')
+ redirect_to(kase_path(@outcome.kase), :notice => 'Outcome was successfully deleted.')
end
private
View
2  app/controllers/referral_documents_controller.rb
@@ -56,7 +56,7 @@ def update
def destroy
@referral_document.destroy
- redirect_to(@referral_document.kase)
+ redirect_to(kase_path(@referral_document.kase), :notice => 'Referral document was successfully deleted.')
end
private
View
12 app/models/kase.rb
@@ -10,13 +10,13 @@ class Kase < ActiveRecord::Base
belongs_to :created_by, :foreign_key => :created_by_id, :class_name=>'User'
belongs_to :updated_by, :foreign_key => :updated_by_id, :class_name=>'User'
- has_many :contacts
- has_many :events
- has_many :response_sets
- has_many :kase_routes
+ has_many :contacts, :dependent => :destroy
+ has_many :events, :dependent => :destroy
+ has_many :response_sets, :dependent => :destroy
+ has_many :kase_routes, :dependent => :destroy
has_many :routes, :through=>:kase_routes
- has_many :outcomes
- has_many :referral_documents
+ has_many :outcomes, :dependent => :destroy
+ has_many :referral_documents, :dependent => :destroy
VALID_COUNTIES = {'Clackamas' => 'C', 'Multnomah' => 'M', 'Washington' => 'W'}
View
2  app/models/organization.rb
@@ -11,7 +11,7 @@ class Organization < ActiveRecord::Base
validates_inclusion_of :organization_type, :in => ORGANIZATION_TYPES.values.collect{|t| t[:id]}
validates_presence_of :parent, :if => :is_cmo?
- has_many :users
+ has_many :users, :dependent => :restrict
has_many :children, :class_name => "Organization",
:foreign_key => "parent_id", :dependent => :nullify
View
8 app/models/user.rb
@@ -6,10 +6,10 @@ class User < ActiveRecord::Base
belongs_to :organization
- has_many :surveys
- has_many :kases
- has_many :contacts
- has_many :events
+ has_many :surveys, :dependent => :nullify
+ has_many :kases, :dependent => :nullify
+ has_many :contacts, :dependent => :nullify
+ has_many :events, :dependent => :nullify
validates_presence_of :first_name
validates_presence_of :last_name
View
4 app/views/kases/_events.html.erb
@@ -11,13 +11,13 @@
<td><%= event.start_time %></td>
<td><%= event.end_time %></td>
<td><%= event.event_type.name %></td>
- <td><%= event.user.email %></td>
+ <!-- td><%= event.user.email %></td -->
<td><%= link_to "Details", edit_event_path(event), :class=>"details" %></td>
</tr>
<% if event.show_full_notes? %>
<tr class=<%= cycle %>>
<td></td>
- <td colspan="4"><%= event.notes %></td>
+ <td colspan="3"><%= event.notes %></td>
<td></td>
</tr>
<% end %>
View
62 app/views/kases/_outcomes.html.erb
@@ -1,4 +1,4 @@
-<h1>Outcomes</h1>
+<h1 class="clearfix">Outcomes</h1>
<% if can? :edit, @kase %>
<%= link_to "Add", new_outcome_path(:kase_id=>@kase.id), :class => :add %>
@@ -6,42 +6,40 @@
<% for outcome in @kase.outcomes %>
<h2>
- <%= outcome.trip_reason.name %>
+ <div class="clearfix"><%= outcome.trip_reason.name %></div>
<%= link_to( "Edit", edit_outcome_path( outcome ), :class => :edit ) if can? :edit, outcome %>
</h2>
<table>
-<tr>
-<th>When</th>
-<th>Trips/wk</th>
-<th>VMR</th>
-</tr>
+ <tr>
+ <th>When</th>
+ <th>Trips/wk</th>
+ <th>VMR</th>
+ </tr>
-<tr class="auto-zebra">
-<td>Exit</td>
-<td><%= outcome.exit_trip_count %></td>
-<td><%= outcome.exit_vehicle_miles_reduced %></td>
-</tr>
+ <tr class="auto-zebra">
+ <td>Exit</td>
+ <td><%= outcome.exit_trip_count %></td>
+ <td><%= outcome.exit_vehicle_miles_reduced %></td>
+ </tr>
-<tr class="auto-zebra">
-<td>3 Months</td>
-<% if outcome.three_month_unreachable %>
-<td colspan="2">not reachable</td>
-<% else %>
-<td><%= outcome.three_month_trip_count %></td>
-<td><%= outcome.three_month_vehicle_miles_reduced %></td>
-<% end %>
-</tr>
-
-<tr class="auto-zebra">
-<td>6 Months</td>
-<% if outcome.six_month_unreachable %>
-<td colspan="2">not reachable</td>
-<% else %>
-<td><%= outcome.six_month_trip_count %></td>
-<td><%= outcome.six_month_vehicle_miles_reduced %></td>
-<% end %>
-</tr>
+ <tr class="auto-zebra">
+ <td>3 Months</td>
+ <% if outcome.three_month_unreachable %>
+ <td colspan="2">not reachable</td>
+ <% else %>
+ <td><%= outcome.three_month_trip_count %></td>
+ <td><%= outcome.three_month_vehicle_miles_reduced %></td>
+ <% end %>
+ </tr>
+ <tr class="auto-zebra">
+ <td>6 Months</td>
+ <% if outcome.six_month_unreachable %>
+ <td colspan="2">not reachable</td>
+ <% else %>
+ <td><%= outcome.six_month_trip_count %></td>
+ <td><%= outcome.six_month_vehicle_miles_reduced %></td>
+ <% end %>
+ </tr>
</table>
<% end %>
-
View
3  app/views/kases/_referral_documents.html.erb
@@ -27,6 +27,9 @@
<td>
<%= link_to "Edit", edit_referral_document_path(referral_document), :class=>"edit" %>
</td>
+ <td>
+ <%= link_to "", referral_document, :confirm => 'Are you sure you want to delete this referral document?', :method => :delete, :class => "delete referral_document" %>
+ </td>
</tr>
<% end %>
</tbody>
View
12 app/views/kases/show.html.erb
@@ -19,6 +19,12 @@
</li>
</ol>
<% end -%>
+
+ <ol class="section" id="referral_documents">
+ <li>
+ <%= render "referral_documents" %>
+ </li>
+ </ol>
</div>
<div class="second">
@@ -41,11 +47,5 @@
</li>
</ol>
<% end -%>
-
- <ol class="section" id="referral_documents">
- <li>
- <%= render "referral_documents" %>
- </li>
- </ol>
</div>
</fieldset>
View
46 features/referral_document.feature
@@ -31,8 +31,8 @@ Feature: Manage referral documents
And I should see a confirmation message
And I should see the new resource listed when I click on the referral document details link
- @firebug
- @pause_on_fail
+ # @firebug
+ # @pause_on_fail
@javascript
Scenario: Trainers can remove a resource from an existing referral document
Given I am logged in as a trainer
@@ -48,11 +48,45 @@ Feature: Manage referral documents
And I should see a confirmation message
And I should not see the new resource listed when I click on the referral document details link
- @wip
Scenario: Trainers can print a referral document
+ Given I am logged in as a trainer
+ And an open training case exists
+ And a referral document exists for the existing case
+ And I am on the homepage
+ When I click on the "Training Cases" link
+ And I click through to the case details
+ And I click on the link to print the referral document
+ Then I should be served the referral document as a PDF
+ And I should see the referral document details
@wip
- Scenario: Trainers cannot delete a referral document
-
+ @firebug
+ @pause_on_fail
+ @javascript
+ Scenario: Trainers can not delete a referral document
+ Given I am logged in as an trainer
+ And an open training case exists
+ And a referral document exists for the existing case
+ And I am on the homepage
+ When I click on the "Training Cases" link
+ And I click through to the case details
+ Then I should see a button to delete the referral document
+ And I should be prompted to confirm the deletion when I click the referral document's delete button
+ And I should see an error message because I don't have permission to delete the referral document
+ And I should see the referral document listed when I return to the case profile
+
@wip
- Scenario: Admins can delete a referral document
+ @firebug
+ @pause_on_fail
+ @javascript
+ Scenario: Admins can delete a referral document
+ Given I am logged in as an admin
+ And an open training case exists
+ And a referral document exists for the existing case
+ And I am on the homepage
+ When I click on the "Training Cases" link
+ And I click through to the case details
+ Then I should see a button to delete the referral document
+ And I should be prompted to confirm the deletion when I click the referral document's delete button
+ And I should see a confirmation message
+ And I should not see the referral document listed when I return to the case profile
View
56 features/step_definitions/referral_document_steps.rb
@@ -1,3 +1,5 @@
+require "pdf/inspector"
+
When /^I click on the link to create a new referral document$/ do
find("#referral_documents a[href='/referral_documents/new?kase_id=#{@kase.id}']").click
end
@@ -46,6 +48,12 @@
page.should have_content("Tnetennba")
end
+Then /^I should not see the new resource listed when I click on the referral document details link$/ do
+ find("#referral_documents a[href='/referral_documents/#{@referral_document.id}']").click
+ page.all('#main ol li').count.should eq(1)
+ page.should_not have_content("Sweet Resource")
+end
+
Given /^the resource is assigned to the referral document as a second resource$/ do
@referral_document.resources.create(:resource => @resource)
end
@@ -59,8 +67,48 @@
step %Q(I should see a confirmation message)
end
-Then /^I should not see the new resource listed when I click on the referral document details link$/ do
- find("#referral_documents a[href='/referral_documents/#{@referral_document.id}']").click
- page.all('#main ol li').count.should eq(1)
- page.should_not have_content("Sweet Resource")
+When /^I click on the link to print the referral document$/ do
+ find("#referral_documents a[href='/referral_documents/#{@referral_document.id}.pdf']").click
+end
+
+Then /^I should be served the referral document as a PDF$/ do
+ page.response_headers['Content-Type'].should == "application/pdf"
+ pdf = PDF::Inspector::Text.analyze(page.source).strings.join(" ")
+ page.driver.response.instance_variable_set('@body', pdf)
+end
+
+Then /^I should see the referral document details$/ do
+ page.should have_content("Referral Document for #{@referral_document.customer.name}")
+ page.should have_content("#{@referral_document.resources.first.resource.name}")
+ page.should have_content("Referral document opened at #{@referral_document.created_at.strftime("%e-%b-%4Y %r")}")
+end
+
+Then /^I should( not)? see a button to delete the referral document$/ do|negation|
+ assertion = negation ? :should_not : :should
+ selector = "#referral_documents a.delete[href='/referral_documents/#{@referral_document.id}'][data-method=delete]"
+ page.send(assertion, have_selector(selector))
+ if !negation
+ find(selector)['data-confirm'].should eql("Are you sure you want to delete this referral document?")
+ end
+end
+
+Then /^I should be prompted to confirm the deletion when I click the referral document(?:'s) delete button$/ do
+ button = find("#referral_documents a.delete[href='/referral_documents/#{@referral_document.id}'][data-method=delete]")
+ button['data-confirm'].should eql("Are you sure you want to delete this referral document?")
+ button.click
+ page.driver.browser.switch_to.alert.accept
+ @confirmation_message = 'Referral document was successfully deleted.'
+ # Don't confirm just yet because we may want to test if it failed (due to permissions)
+end
+
+Then /^I should see an error message because I don't have permission to delete the referral document$/ do
+ # page.driver.status_code.should be 403
+ page.should have_content("You are not allowed to take the action you requested.")
+end
+
+Then /^I should( not)? see the referral document listed when I return to the case(?:'s) profile$/ do |negation|
+ assertion = negation ? :should_not : :should
+ visit "/cases/#{@referral_document.kase.id}"
+ selector = "#referral_documents a[href='/referral_documents/#{@referral_document.id}']"
+ page.send(assertion, have_selector(selector))
end
View
1  features/survey.feature
@@ -18,7 +18,6 @@ Feature: Manage surveys aka Assessments
And an open training case exists and is assigned to me
And a simple survey exists
And I am on the homepage
- Then show me the page
When I click on the "Training Cases" link
And I click through to the case details
And I click the link to add an assessment
View
9 public/stylesheets/style.css
@@ -1004,12 +1004,12 @@ body.customers a.new-customer {
*/
body.kases div.first,
body.kases div.second {
- float : left;
- min-width: 250px;
+ float: left;
+ width: 50%;
}
body.kases div.first {
- width : 55%;
+ width : 45%;
margin-right : 5%;
}
@@ -1033,7 +1033,8 @@ ol.section li h1 {
margin: 0;
}
-ol.section li a.add {
+ol.section li a.add,
+ol#outcomes.section li a.edit {
float: left;
margin : -26px 10px 0 280px;
}

No commit comments for this range

Something went wrong with that request. Please try again.