Commit 620171ce authored by marcheing's avatar marcheing

Remove unused variables on profiles controller

Signed-off-by: Diego de Araújo Martinez Camarinha's avatarDiego Araújo <[email protected]>
parent 195ac087
Pipeline #3568221 passed with stage
in 5 minutes and 39 seconds
......@@ -21,11 +21,6 @@ require 'rails_helper'
RSpec.describe ProfilesController, type: :controller do
include Devise::TestHelpers
# This should return the minimal set of attributes required to create a valid
# Profile. As you add validations to Profile, be sure to
# adjust the attributes here as well.
let(:valid_attributes) { attributes_for(:profile).merge(user_id: user.id) }
let(:valid_request_parameters) do
attributes = attributes_for(:profile)
birthdate = attributes.delete(:birthdate)
......@@ -35,15 +30,6 @@ RSpec.describe ProfilesController, type: :controller do
attributes
end
let(:invalid_attributes) {
skip("Add a hash of attributes invalid for your model")
}
# This should return the minimal set of values that should be in the session
# in order to pass any filters (e.g. authentication) defined in
# ProfilesController. Be sure to keep this updated too.
let(:valid_session) { {} }
let(:user) { create(:user, confirmed_at: Time.zone.now) }
before do
......@@ -85,12 +71,12 @@ RSpec.describe ProfilesController, type: :controller do
context "with valid params" do
it "creates a new Profile" do
expect {
post :create, params: { profile: valid_request_parameters }, session: valid_session
post :create, params: { profile: valid_request_parameters }
}.to change(Profile, :count).by(1)
end
it "redirects to the created profile" do
post :create, params: { profile: valid_request_parameters }, session: valid_session
post :create, params: { profile: valid_request_parameters }
expect(response).to redirect_to(root_path)
end
end
......@@ -98,7 +84,7 @@ RSpec.describe ProfilesController, type: :controller do
context "with invalid params" do
before do
expect_any_instance_of(Profile).to receive(:save).and_return false
post :create, params: { profile: valid_request_parameters }, session: valid_session
post :create, params: { profile: valid_request_parameters }
end
it { is_expected.to respond_with(:ok) }
......@@ -118,13 +104,13 @@ RSpec.describe ProfilesController, type: :controller do
}
it "updates the requested profile" do
put :update, params: {id: profile.to_param, profile: new_attributes}, session: valid_session
put :update, params: {id: profile.to_param, profile: new_attributes}
profile.reload
skip("Add assertions for updated state")
end
it "redirects to the profile" do
put :update, params: {id: profile.to_param, profile: valid_request_parameters }, session: valid_session
put :update, params: {id: profile.to_param, profile: valid_request_parameters }
expect(response).to redirect_to(profile)
end
end
......@@ -132,7 +118,7 @@ RSpec.describe ProfilesController, type: :controller do
context "with invalid params" do
before do
expect_any_instance_of(Profile).to receive(:update).and_return false
put :update, params: {id: profile.to_param, profile: valid_request_parameters }, session: valid_session
put :update, params: {id: profile.to_param, profile: valid_request_parameters }
end
it { is_expected.to respond_with(:ok) }
......@@ -148,11 +134,11 @@ RSpec.describe ProfilesController, type: :controller do
it "destroys the requested profile" do
expect(profile).to receive(:destroy)
delete :destroy, params: { id: profile.id }, session: valid_session
delete :destroy, params: { id: profile.id }
end
it "redirects to the profiles list" do
delete :destroy, params: {id: profile.to_param}, session: valid_session
delete :destroy, params: {id: profile.to_param}
expect(response).to redirect_to(profiles_url)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment