diff --git a/app/assets/stylesheets/membership_application.scss b/app/assets/stylesheets/membership_application.scss index 107938dc..bd0c23c4 100644 --- a/app/assets/stylesheets/membership_application.scss +++ b/app/assets/stylesheets/membership_application.scss @@ -35,4 +35,4 @@ body.applications.show { display: block; } } -} +} \ No newline at end of file diff --git a/app/helpers/membership_application_helper.rb b/app/helpers/membership_application_helper.rb new file mode 100644 index 00000000..059e3f30 --- /dev/null +++ b/app/helpers/membership_application_helper.rb @@ -0,0 +1,14 @@ +module MembershipApplicationHelper + + def choose_highlight_class(age) + if age >= 7.weeks && age < 2.months + "bg-info" + elsif age > 2.months + "bg-danger" + end + end + + def age_in_days(age) + (age/ 1.day).floor + end +end \ No newline at end of file diff --git a/app/models/application.rb b/app/models/application.rb index 1824a8d3..466310eb 100644 --- a/app/models/application.rb +++ b/app/models/application.rb @@ -125,6 +125,10 @@ def sufficient_votes? enough_yes || !few_nos end + def age + Time.now - submitted_at + end + def self.to_approve all.map { |x| x if x.approvable? && x.state == "submitted" }.compact.sort_by { |x| x.submitted_at } end diff --git a/app/views/members/applications/index.html.haml b/app/views/members/applications/index.html.haml index 74fd7dee..21645a47 100644 --- a/app/views/members/applications/index.html.haml +++ b/app/views/members/applications/index.html.haml @@ -22,6 +22,7 @@ %th Yes %th No %th ? + %th Age %tbody - @applicants_submitted.each do |applicant| - application = applicant.application @@ -48,6 +49,11 @@ %td= application.yes_votes.size %td= application.no_votes.size %td= application.not_voted_count + %td{:class => choose_highlight_class(application.age)} + = "#{age_in_days(application.age)} days" + + + %h3 %a{"data-toggle" => "collapse" , "href" => "#collapseEmails"} Applicant Email Addresses diff --git a/spec/features/application_age_spec.rb b/spec/features/application_age_spec.rb new file mode 100644 index 00000000..6880f6c3 --- /dev/null +++ b/spec/features/application_age_spec.rb @@ -0,0 +1,25 @@ +require "spec_helper" + +describe "diplaying age on application" do + + before do + @submitted_application = create(:user, state: :applicant).application + @submitted_application.update_attribute(:state, "submitted") + @submitted_application.update_attribute(:submitted_at, 1.week.ago) + end + + before do + page.set_rack_session(user_id: member.id) + end + + context "when logged in as a voting member" do + let(:member) { create(:voting_member) } + + it "displays the correct application age" do + visit members_applications_path + expect(page).to have_content "Age" + #This spec controls the age of the application so the age can be hardcoded in + expect(page).to have_content "7 days" + end + end +end