Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
model
module Report
class EmployerApplicationReport
attr_accessor :job, :archived
def initialize(options = {})
options ||= {}
options.reverse_merge!(:archived => false)
options.each do |k, v|
send("#{k}=", v) if respond_to?("#{k}=")
end
end
def applications
if archived
job.job_applications.all
else
job.job_applications.active
end
end
end
end
require 'spec_helper'
describe Report::EmployerApplicationReport do
let(:report) { Report::EmployerApplicationReport.new }
describe "#archived" do
it 'defaults to false' do
report.archived.should be_false
end
end
describe "#applications" do
before do
@job = Factory(:active_job)
Factory(:job_application, :job => @job)
Factory(:job_application, :job => @job, :archived_at => Time.zone.now)
end
context "with a job" do
before do
report.job = @job
end
context "when archived is false" do
before do
report.archived = false
end
it 'returns unarchived applications for the job' do
report.applications.should == @job.job_applications.active
end
end
context "when archived is true" do
before do
report.archived = true
end
it 'returns all applications for the job' do
report.applications.should == @job.job_applications
end
end
end
end
end
require 'spec_helper'
describe Report::EmployerApplicationReport do
let(:report) { Report::EmployerApplicationReport.new }
describe "#archived" do
it 'defaults to false' do
report.archived.should be_false
end
end
describe "#applications" do
before do
@job = Factory.stub(:active_job)
@applications = []
@applications << Factory.stub(:job_application, :job => @job)
@applications << Factory.stub(:job_application, :job => @job, :archived_at => Time.zone.now)
@job.stub_chain(:job_applications, :all => @applications)
@job.stub_chain(:job_applications, :active => [@applications.first])
end
context "with a job" do
before do
report.job = @job
end
context "when archived is false" do
before do
report.archived = false
end
it 'returns unarchived applications for the job' do
report.applications.should == [@applications.first]
end
end
context "when archived is true" do
before do
report.archived = true
end
it 'returns all applications for the job' do
report.applications.should == @applications
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.