From 5845f76e1da9d36c37308fec654ecacd403aacf8 Mon Sep 17 00:00:00 2001 From: Mark Moser Date: Fri, 18 Nov 2016 17:43:24 -0600 Subject: [PATCH] linked into views --- README.md | 6 ++- app/assets/images/thumb-down-red.png | Bin 0 -> 311 bytes app/assets/images/thumb-down.png | Bin 0 -> 282 bytes app/assets/images/thumb-up-green.png | Bin 0 -> 316 bytes app/assets/images/thumb-up.png | Bin 0 -> 274 bytes .../stylesheets/molecules/_review_meta.scss | 12 ++++++ app/models/candidate.rb | 7 +++ app/models/reviewer_vote.rb | 4 +- app/views/admin/candidate/index.html.erb | 4 +- app/views/admin/result/view.html.erb | 33 ++++++++++++--- test/fixtures/answers.yml | 40 +++++++++--------- test/fixtures/candidates.yml | 4 +- test/fixtures/questions.yml | 2 +- test/models/reviewer_vote_test.rb | 26 ++++++++++++ 14 files changed, 107 insertions(+), 31 deletions(-) create mode 100644 app/assets/images/thumb-down-red.png create mode 100644 app/assets/images/thumb-down.png create mode 100644 app/assets/images/thumb-up-green.png create mode 100644 app/assets/images/thumb-up.png create mode 100644 app/assets/stylesheets/molecules/_review_meta.scss diff --git a/README.md b/README.md index 76b03dc..8d2f5e1 100644 --- a/README.md +++ b/README.md @@ -77,10 +77,14 @@ There are some convenience scripts included to make starting the container and r * `./start-server.sh` - starts up just rails server for viewing application +## Deploying a new version +* ssh into server +* cd into app root +* run deploy.sh ## TODOs and notes -* Question attachment path: http://dev.perficientxd.com/skill_assets/ +* Question attachment path: https://dev.perficientdigital.com/skills-app-images/ * clean code * [Confident Ruby](http://www.confidentruby.com/) * [POODR](http://www.poodr.com/) diff --git a/app/assets/images/thumb-down-red.png b/app/assets/images/thumb-down-red.png new file mode 100644 index 0000000000000000000000000000000000000000..13c46e74fdffb5e48be13fd0791da20fffb45db0 GIT binary patch literal 311 zcmV-70m%M|P)k-0Y|_m-%M}?M$i#-1Xqv|WCWSOgc0ltK2S_kuYp$hlRh+e`M>6R zy(X{2o(N^u8l`{^Xzj!_z_b8PKsAxq0b3XF@FX_C&6tNA0`KWK{ zHcp^-_Bz5GhC?d}P)8a{DkXq)7mEUxRJArhyo1FdYXh>i0o4>h{Rt>ihT+r*#yxOl zXx)rBwaLtBdS`mbxza#BcbXo7C;qwQRzZ*Zka4{O-kw-t;y()MA`Rr8n8MQ#p>5jZ zABbZ4V%~wWt literal 0 HcmV?d00001 diff --git a/app/assets/images/thumb-down.png b/app/assets/images/thumb-down.png new file mode 100644 index 0000000000000000000000000000000000000000..9cd2fb3145d972a5be4fddba136862f3a40ffcfc GIT binary patch literal 282 zcmV+#0p|3LO0h>tD~KpqR=8dc~?lj;RPjwtjd+vmF?{Be>p gjBjElQxLN5z+1DD9<>cXxRt z+w+DF$B4=A1qT0!BN<+ry#f@ zm&b-Svk{k9$mKEq*==+KdIc+nlhZ$c;6}EM3f>Ar4YEGUHhCmUpw4izFG7;>Ul)ra zJgo(8ZE$V+0M4O!k4bc3Pz`#(!X=;`}!LL)(#UVt{w}aqML;-_0 zzZAh{acYckrbgYP)94&8845x&LQ3k;!m@uvKWL$ z5cjbKD2%{bg9gLvv^fH27^gzIdg#e*-b>`}Cr`$&cc2pWyO@U-f_`sLr);7Gdd~?IrjGwWO;~Kq2~fC78_gQ?b)#fp47j div { flex: 1 1 auto; } + } + + .review_meta__votes, + .review_meta__vetos { + a { padding: 5px; } + } +} diff --git a/app/models/candidate.rb b/app/models/candidate.rb index a216c37..dac22db 100644 --- a/app/models/candidate.rb +++ b/app/models/candidate.rb @@ -4,6 +4,7 @@ class Candidate < ApplicationRecord has_many :questions, -> { order("sort") }, through: :quiz has_many :answers belongs_to :recruiter, class_name: "User" + has_many :votes, class_name: "ReviewerVote" serialize :email, CryptSerializer @@ -15,6 +16,12 @@ class Candidate < ApplicationRecord validates :email, uniqueness: true, presence: true, email_format: true validates :test_hash, uniqueness: true, presence: true + enum review_status: { + # pending: 0, + approved: 1, + declined: 2 + } + def submitted_answers answers.where(submitted: true) end diff --git a/app/models/reviewer_vote.rb b/app/models/reviewer_vote.rb index 8f52019..6ed8fce 100644 --- a/app/models/reviewer_vote.rb +++ b/app/models/reviewer_vote.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true class ReviewerVote < ApplicationRecord - # validates :user_id, uniqueness: {scope: :friend_id} - belongs_to :candidate belongs_to :user + validates :user_id, uniqueness: { scope: :candidate_id } + enum vote: { undecided: 0, yea: 1, diff --git a/app/views/admin/candidate/index.html.erb b/app/views/admin/candidate/index.html.erb index 130c99e..d4ababd 100644 --- a/app/views/admin/candidate/index.html.erb +++ b/app/views/admin/candidate/index.html.erb @@ -15,6 +15,7 @@ Progress Completed Reminded + Review Status <% @candidates.each do |candidate| %> @@ -28,8 +29,9 @@ <%= candidate.experience %> years <%= candidate.status %> - <%= candidate.completed ? "Submitted" : "" %> + <%= candidate.completed ? link_to("Submitted", admin_result_path(candidate.test_hash)) : "" %> <%= candidate.reminded ? "Yes" : "" %> + <%= candidate.review_status %> <% end %> diff --git a/app/views/admin/result/view.html.erb b/app/views/admin/result/view.html.erb index 73a0f72..10f1458 100644 --- a/app/views/admin/result/view.html.erb +++ b/app/views/admin/result/view.html.erb @@ -1,10 +1,33 @@

Quiz Review

-

- Test ID: <%= @candidate.test_hash %>
- Years of Experience: <%= @candidate.experience %>
- Recruiter Email: <%= mail_to @candidate.recruiter.name, @candidate.recruiter.email %>
-

+ +
+
+ Test ID: <%= @candidate.test_hash %>
+ Years of Experience: <%= @candidate.experience %>
+ Recruiter Email: <%= mail_to @candidate.recruiter.name, @candidate.recruiter.email %>
+
+
+
+ Votes: + <%= link_to '#cast-vote-up', remote: true do %> + Yea (<%= @candidate.votes.yea.count %>) + <% end %> + <%= link_to '#cast-vote-down', remote: true do %> + Nay (<%= @candidate.votes.nay.count %>) + <% end %> +
+
+ Manager Vetos: + <%= link_to '#request', remote: true do %> + Request Interview + <% end %> + <%= link_to '#decline', remote: true do %> + Decline Interview + <% end %> +
+
+
<% @quiz.each do |question| %> <%= form_for(:answer, url: '#never-post', html:{id: 'summary-form'}) do |form| %> diff --git a/test/fixtures/answers.yml b/test/fixtures/answers.yml index feda3fa..de70e0c 100644 --- a/test/fixtures/answers.yml +++ b/test/fixtures/answers.yml @@ -599,8 +599,8 @@ henry10: created_at: <%= DateTime.now() - 36.hours - 40.minutes %> updated_at: <%= DateTime.now() - 36.hours - 20.minutes %> -martin1: - candidate: martin +wade1: + candidate: wade question: Cras justo odio, dapibus ac facilisis in, egestas eget quam. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Nullam id dolor id nibh ultricies vehicula ut id elit. answer: option 3 saved: 0 @@ -608,8 +608,8 @@ martin1: created_at: <%= DateTime.now() - 36.hours - 22.minutes %> updated_at: <%= DateTime.now() - 36.hours - 22.minutes %> -martin2: - candidate: martin +wade2: + candidate: wade question: fed2 answer: 'indexOf()' saved: 0 @@ -617,8 +617,8 @@ martin2: created_at: <%= DateTime.now() - 36.hours - 24.minutes %> updated_at: <%= DateTime.now() - 36.hours - 4.minutes %> -martin3: - candidate: martin +wade3: + candidate: wade question: fed3 answer: {html: '

Salmon

', css: 'h1 {color: salmon;}', js: '', text: 'Gotta lotta GOOD things on sale, strangah.'} saved: 0 @@ -626,8 +626,8 @@ martin3: created_at: <%= DateTime.now() - 36.hours - 26.minutes %> updated_at: <%= DateTime.now() - 36.hours - 6.minutes %> -martin4: - candidate: martin +wade4: + candidate: wade question: fed4 answer: Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. saved: 0 @@ -635,8 +635,8 @@ martin4: created_at: <%= DateTime.now() - 36.hours - 28.minutes %> updated_at: <%= DateTime.now() - 36.hours - 28.minutes %> -martin5: - candidate: martin +wade5: + candidate: wade question: fed5 answer: 'Dynamic listeners' saved: 0 @@ -644,8 +644,8 @@ martin5: created_at: <%= DateTime.now() - 36.hours - 30.minutes %> updated_at: <%= DateTime.now() - 36.hours - 30.minutes %> -martin6: - candidate: martin +wade6: + candidate: wade question: fed6 answer: Integer posuere erat a ante venenatis dapibus posuere velit aliquet. saved: 0 @@ -653,8 +653,8 @@ martin6: created_at: <%= DateTime.now() - 36.hours - 32.minutes %> updated_at: <%= DateTime.now() - 36.hours - 12.minutes %> -martin7: - candidate: martin +wade7: + candidate: wade question: fed7 answer: {html: '

This means jQuery needs to be available in live-coder!

', css: "strong {font-size: 1.6em;}\n.green {color: green;}", js: '$("strong").addClass("green");'} saved: 0 @@ -662,8 +662,8 @@ martin7: created_at: <%= DateTime.now() - 36.hours - 34.minutes %> updated_at: <%= DateTime.now() - 36.hours - 14.minutes %> -martin8: - candidate: martin +wade8: + candidate: wade question: fed8 answer: other: Some generic user input @@ -674,8 +674,8 @@ martin8: created_at: <%= DateTime.now() - 36.hours - 36.minutes %> updated_at: <%= DateTime.now() - 36.hours - 16.minutes %> -martin9: - candidate: martin +wade9: + candidate: wade question: fed9 answer: other: Brunch @@ -687,8 +687,8 @@ martin9: created_at: <%= DateTime.now() - 36.hours - 38.minutes %> updated_at: <%= DateTime.now() - 36.hours - 18.minutes %> -martin10: - candidate: martin +wade10: + candidate: wade question: fed10 answer: ["Live long and prosper", "Who you calling Scruffy?"] saved: 0 diff --git a/test/fixtures/candidates.yml b/test/fixtures/candidates.yml index 237c23a..7a22bfd 100644 --- a/test/fixtures/candidates.yml +++ b/test/fixtures/candidates.yml @@ -59,6 +59,7 @@ richard: # Richard has completed AND submitted the test completed: true reminded: false test_hash: 6NjnourLE6Y + review_status: 1 juan: # Juan has chosen "finish later" for live coders name: Juan Campbell @@ -79,6 +80,7 @@ stacy: # Stacy has completed AND submitted the test completed: true reminded: false test_hash: s6oFExZliYYFx + review_status: 2 henry: # Henry has completed AND submitted the test name: Henry Butler @@ -98,5 +100,5 @@ wade: # Wade has completed AND submitted the test quiz: fed completed: true reminded: false - test_hash: BkSkpa/pJnkz2N + test_hash: BkSkpapJnkz2N diff --git a/test/fixtures/questions.yml b/test/fixtures/questions.yml index 97c7d00..4380750 100644 --- a/test/fixtures/questions.yml +++ b/test/fixtures/questions.yml @@ -55,7 +55,7 @@ fed5: fed6: quiz: fed question: Comment on how realistic the following image is. - attachment: "http://dev.perficientxd.com/skill_assets/commets_css.jpg" + attachment: "https://dev.perficientdigital.com/skills-app-images/commets_css.jpg" category: CSS input_type: text input_options: diff --git a/test/models/reviewer_vote_test.rb b/test/models/reviewer_vote_test.rb index 1ce2161..48db0fe 100644 --- a/test/models/reviewer_vote_test.rb +++ b/test/models/reviewer_vote_test.rb @@ -5,4 +5,30 @@ class ReviewerVoteTest < ActiveSupport::TestCase test "the truth" do assert ReviewerVoteTest end + + test "richard has 3 votes" do + richard = candidates(:richard) + + assert_equal 3, richard.votes.size + end + + test "manager has 4 votes" do + manager = users(:manager) + + assert_equal 4, manager.votes.size + end + + test "richard has been approved" do + richard = candidates(:richard) + + assert richard.approved? + refute richard.declined? + end + + test "stacy has been declined" do + stacy = candidates(:stacy) + + assert stacy.declined? + refute stacy.approved? + end end