Created
April 16, 2009 13:21
-
-
Save matthewrudy/96411 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> vdaf = VacancyDownloadableApplicationForm.last | |
VacancyDownloadableApplicationForm Load (0.122909) SELECT * FROM `vacancy_downloadable_application_forms` ORDER BY vacancy_downloadable_application_forms.id DESC LIMIT 1 | |
VacancyDownloadableApplicationForm Columns (0.063622) SHOW FIELDS FROM `vacancy_downloadable_application_forms` | |
=> #<VacancyDownloadableApplicationForm id: 54228, vacancy_id: 53520, attachment_id: 3104, name: "Welwyn Hatfield Council - Standard"> | |
>> vdaf.downloadable_application_form | |
DownloadableApplicationForm Columns (0.027216) SHOW FIELDS FROM `uploaded_files` | |
DownloadableApplicationForm Load (0.042126) SELECT * FROM `uploaded_files` WHERE (`uploaded_files`.`id` = 3104) AND ( (`uploaded_files`.`type` = 'DownloadableApplicationForm' ) ) | |
=> #<DownloadableApplicationForm id: 3104, file_name: "568.pdf", file_type: "pdf", type: "DownloadableApplicationForm", name: nil, organisation_id: nil, jgp4_id: nil, originated_from: nil> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- HTMLTrace:Start sites/vacancies/_dam_link_rdfa.rhtml --> | |
<% | |
return unless file = dam_link_rdfa.downloadable_application_form | |
if file_found?(file) | |
file_name_for_link = case file.file_type | |
when "pdf" then "Downloadable Form (PDF)" | |
when "doc" then "E-mailable Form (Word)" | |
else dam_link_rdfa.name | |
end | |
-%> | |
<p property="dc:references"><%= link_to file_name_for_link, :controller => "/sites/uploaded_files", :action => "download", :file => url_for_file_column(file, "file_name"), :vacancy_permalink => @vacancy.permalink, :vacancy => @vacancy, :source => file.file_type %></p> | |
<% else -%> | |
<p>File not found (<%= file.file_name %>)</p> | |
<% end -%> | |
<!-- HTMLTrace:End sites/vacancies/_dam_link_rdfa.rhtml --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../../../spec_helper' | |
describe "sites/vacancies/_dam_link_rdfa" do | |
before(:each) do | |
@vacancy = stub_model(Vacancy, :permalink => "/somewhere/nice") | |
application_form = mock_model(DownloadableApplicationForm, :file_name => "my_file") | |
assigns[:dam_link_rdfa] = mock_model(VacancyDownloadableApplicationForm, :downloadable_application_form => application_form, :name => "My File Name") | |
end | |
it "should not contain the element to downloadable file if file does not exists" do | |
template.stub!(:file_found?).and_return(false) | |
render :partial => 'sites/vacancies/dam_link_rdfa' | |
response.should_not have_tag("p[property=dc:references]") | |
end | |
it "should contain link to downloadable file if file exists" do | |
template.stub!(:file_found?).and_return(true) | |
template.stub!(:match).and_return(true) | |
render :partial => 'sites/vacancies/dam_link_rdfa' | |
response.should have_tag("p[property=dc:references]") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment