From faa764d1765b5d6969d73e68cf474a4466c936a0 Mon Sep 17 00:00:00 2001 From: KenXiong123 <100426951+KenXiong123@users.noreply.github.com> Date: Wed, 16 Nov 2022 16:11:31 -0500 Subject: [PATCH] tdd @ 96% (#88) --- spec/controllers/events_controller_spec.rb | 14 ++++++++++++++ spec/controllers/users_controller_spec.rb | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/spec/controllers/events_controller_spec.rb b/spec/controllers/events_controller_spec.rb index 1b1d819..aa2b09e 100644 --- a/spec/controllers/events_controller_spec.rb +++ b/spec/controllers/events_controller_spec.rb @@ -213,4 +213,18 @@ end end + describe "#ratePeople" do + let!(:event) {FactoryGirl.create(:event)} + let!(:user) {FactoryGirl.build(:user, username: 'Ben')} + before do + sign_in user + get :ratePeople, {:id=>event.id} + end + + context "attendee goes to event page" do + it "should return ratePeople template" do + expect(response).to render_template("ratePeople") + end + end + end end \ No newline at end of file diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index f48fc1e..00ac215 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -126,4 +126,23 @@ end end + describe "PUT #rateUser" do + let!(:event) {FactoryGirl.create(:event)} + let!(:user) {FactoryGirl.build(:user, username: 'David')} + before do + sign_in user + put :rateUser, {:id => event.id} + end + + context "When successfully update an existing user profile" do + it "should store the update in the database and redirect to user profile page" do + # rating = ActionController::Parameters.new(:David => "1") + put :rateUser, {:id => event.id, :David => "1"} + user.reload + expect(user.rating).to eq(1) + expect(response).to redirect_to("/events/1") + end + end + end + end