Skip to content

Commit

Permalink
tdd @ 96% (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
KenXiong123 authored Nov 16, 2022
1 parent fa43f26 commit faa764d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/controllers/events_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit faa764d

Please sign in to comment.