spec/controllers/roles_controller_spec.rb in curupira-0.1.4 vs spec/controllers/roles_controller_spec.rb in curupira-0.1.6
- old
+ new
@@ -22,24 +22,24 @@
describe "GET show" do
context "when role exists" do
let!(:role) { FactoryGirl.create(:role) }
it "should get show" do
- get :show, id: role
+ get :show, params: { id: role }
expect(response).to be_success
end
it "returns role" do
- get :show, id: user
+ get :show, params: { id: user }
expect(assigns(:role)).to eql role
end
end
context "when user does not exist" do
it "renders 404" do
expect {
- get :show, id: "wrong id"
+ get :show, params: { id: "wrong id" }
}.to raise_error ActiveRecord::RecordNotFound
end
end
end
@@ -58,24 +58,24 @@
describe "GET edit" do
context "when role exists" do
let!(:role) { FactoryGirl.create(:role) }
it "should get edit" do
- get :edit, id: role
+ get :edit, params: { id: role }
expect(response).to be_success
end
it "returns role" do
- get :edit, id: role
+ get :edit, params: { id: role }
expect(assigns(:role)).to eql role
end
end
context "when user does not exist" do
it "renders 404" do
expect {
- get :edit, id: "wrong id"
+ get :edit, params: { id: "wrong id" }
}.to raise_error ActiveRecord::RecordNotFound
end
end
end
@@ -92,22 +92,22 @@
}
}
end
it "should redirect to new user" do
- post :create, role: params
+ post :create, params: { role: params }
expect(flash[:notice]).to eql "Perfil criado com sucesso"
end
it "should redirect to new role" do
- post :create, role: params
+ post :create, params: { role: params }
expect(response).to redirect_to assigns(:role)
end
it "creates role" do
expect {
- post :create, role: params
+ post :create, params: { role: params }
}.to change { Role.count }.by(1)
expect(assigns[:role].name).to eql "Minha Role"
expect(assigns[:role].features.first.name).to eq("Cadastrar")
end
@@ -116,16 +116,16 @@
context "when role is invalid" do
let(:params) { FactoryGirl.build(:role, name: '').attributes }
it "does not create user" do
expect {
- post :create, role: params
+ post :create, params: { role: params }
}.to change { Role.count }.by(0)
end
it "should render new" do
- post :create, role: params
+ post :create, params: { role: params }
expect(response).to render_template :new
end
end
end
@@ -134,34 +134,34 @@
context "when user is valid" do
let(:params) { FactoryGirl.build(:role, name: 'Outra role').attributes }
it "sets flash message" do
- put :update, id: role, role: params
+ put :update, params: { id: role, role: params }
expect(flash[:notice]).to eql "Perfil atualizado com sucesso"
end
it "redirects to user" do
- put :update, id: role, role: params
+ put :update, params: { id: role, role: params }
expect(response).to redirect_to assigns(:role)
end
it "updates role" do
- put :update, id: role, role: params
+ put :update, params: { id: role, role: params }
expect(assigns(:role).name).to eql "Outra role"
end
end
context "when role is invalid" do
let(:params) { FactoryGirl.build(:role, name: '').attributes }
it "does not create role" do
- put :update, id: role, role: params
+ put :update, params: { id: role, role: params }
expect(assigns(:role).reload.name).to eql role.name
end
it "should render edit" do
- put :update, id: role, role: params
+ put :update, params: { id: role, role: params }
expect(response).to render_template :edit
end
end
end
end
\ No newline at end of file