mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-02-26 19:59:06 -05:00
The view here isn't as DRY as we'd like, but all the options were kind of ugly, and this one was easiest.
55 lines
1.5 KiB
Ruby
55 lines
1.5 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe NotificationsController do
|
|
|
|
login_member
|
|
|
|
def valid_attributes
|
|
{ "recipient_id" => subject.current_member.id }
|
|
end
|
|
|
|
def valid_session
|
|
{}
|
|
end
|
|
|
|
describe "GET index" do
|
|
it "assigns all notifications as @notifications" do
|
|
notification = Notification.create! valid_attributes
|
|
get :index, {}
|
|
assigns(:notifications).should eq([notification])
|
|
end
|
|
end
|
|
|
|
describe "GET show" do
|
|
it "assigns the requested notification as @notification" do
|
|
notification = Notification.create! valid_attributes
|
|
get :show, {:id => notification.to_param}
|
|
assigns(:notification).should eq(notification)
|
|
end
|
|
|
|
it "marks notifications as read" do
|
|
notification = Notification.create! valid_attributes
|
|
get :show, {:id => notification.to_param}
|
|
# we need to fetch it from the db again, can't test against the old one
|
|
n = Notification.find(notification.id)
|
|
n.read.should eq true
|
|
end
|
|
end
|
|
|
|
describe "DELETE destroy" do
|
|
it "destroys the requested notification" do
|
|
notification = Notification.create! valid_attributes
|
|
expect {
|
|
delete :destroy, {:id => notification.to_param}
|
|
}.to change(Notification, :count).by(-1)
|
|
end
|
|
|
|
it "redirects to the notifications page" do
|
|
notification = Notification.create! valid_attributes
|
|
delete :destroy, {:id => notification.to_param}
|
|
response.should redirect_to(notifications_url)
|
|
end
|
|
end
|
|
|
|
end
|