diff options
| author | mo <mo.khan@gmail.com> | 2017-09-23 09:13:29 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2017-09-23 09:13:29 -0600 |
| commit | afc870216e5eb02c1c73ed018d21ec2d027db041 (patch) | |
| tree | 6c96a7d40c31a131f10e2da702afc4e685d17381 /spec | |
| parent | 49ee70b30b2e114622f90bcf77ded003908006aa (diff) | |
upgrade specs
Diffstat (limited to 'spec')
25 files changed, 83 insertions, 65 deletions
diff --git a/spec/controllers/admin/photos_controller_spec.rb b/spec/controllers/admin/photos_controller_spec.rb index 0fe203b2..76b9e302 100644 --- a/spec/controllers/admin/photos_controller_spec.rb +++ b/spec/controllers/admin/photos_controller_spec.rb @@ -14,7 +14,7 @@ module Admin it "re-processes the photo" do allow(ReProcessPhotoJob).to receive(:perform_later) - put :update, id: photo.id + put :update, params: { id: photo.id } expect(ReProcessPhotoJob).to have_received(:perform_later).with(photo) end diff --git a/spec/controllers/admin/products_controller_spec.rb b/spec/controllers/admin/products_controller_spec.rb index 1151851f..89de9b17 100644 --- a/spec/controllers/admin/products_controller_spec.rb +++ b/spec/controllers/admin/products_controller_spec.rb @@ -20,7 +20,7 @@ module Admin product = "product" allow(product_api).to receive(:find).with(asin).and_return(product) - get :show, id: asin + get :show, params: { id: asin } expect(assigns(:product)).to eql(product) end @@ -29,14 +29,14 @@ module Admin let(:tool) { create(:tool) } it "loads the tool" do - get :show, id: tool.asin + get :show, params: { id: tool.asin } expect(assigns(:tool)).to eql(tool) end end context "when the tool is not in the toolbox" do it "does not load a tool" do - get :show, id: "not_added" + get :show, params: { id: "not_added" } expect(assigns(:tool)).to be_nil end end @@ -44,7 +44,7 @@ module Admin describe "#create" do it "creates new tool" do - post :create, {:name=>"pan", :asin=>"34234"} + post :create, params: { name: "pan", asin: "34234" } expect(Tool.count).to eql(1) expect(Tool.first.name).to eql("pan") @@ -52,7 +52,7 @@ module Admin end it "redirects back to the detail page" do - post :create, {name: 'blah', asin: 'blah' } + post :create, params: { name: 'blah', asin: 'blah' } expect(response).to redirect_to(admin_product_path('blah')) end end diff --git a/spec/controllers/admin/sessions_controller_spec.rb b/spec/controllers/admin/sessions_controller_spec.rb index 815cbd00..f494bd6e 100644 --- a/spec/controllers/admin/sessions_controller_spec.rb +++ b/spec/controllers/admin/sessions_controller_spec.rb @@ -24,7 +24,7 @@ module Admin before :each do allow(UserSession).to receive(:find).with(user_session.id).and_return(user_session) allow(user_session).to receive(:revoke!).and_return(true) - delete :destroy, id: user_session.id + delete :destroy, params: { id: user_session.id } end it "revokes the specified session" do diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c2c1ad0c..5e4d3b86 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -21,7 +21,7 @@ module Admin repository = double allow(controller).to receive(:repository).and_return(repository) allow(repository).to receive(:search_with).and_return([matching_user]) - get :index, q: 'mo' + get :index, params: { q: 'mo' } expect(assigns(:users)).to include(matching_user) end end @@ -30,7 +30,7 @@ module Admin let!(:user) { create(:user) } it "loads the details on the specific user" do - get :show, id: user.id + get :show, params: { id: user.id } expect(assigns(:user)).to eql(user) end end diff --git a/spec/controllers/api/v1/cakes_controller_spec.rb b/spec/controllers/api/v1/cakes_controller_spec.rb index 7f84d3ae..cb8d81d2 100644 --- a/spec/controllers/api/v1/cakes_controller_spec.rb +++ b/spec/controllers/api/v1/cakes_controller_spec.rb @@ -16,7 +16,7 @@ describe Api::V1::CakesController do before :each do user.creations << my_cake - xhr :get, :index + get :index, xhr: true end it "returns all of my cakes" do @@ -33,7 +33,7 @@ describe Api::V1::CakesController do before :each do user.creations << cake - xhr :get, :show, id: cake.id + get :show, params: { id: cake.id }, xhr: true end it "loads a specific cake" do @@ -45,7 +45,7 @@ describe Api::V1::CakesController do let(:category) { create(:category) } it "creates a new project" do - xhr :post, :create, cake: { name: "new-cake", category_id: category.id } + post :create, params: { cake: { name: "new-cake", category_id: category.id } }, xhr: true expect(Creation.count).to eql(1) expect(Creation.first.name).to eql("new-cake") @@ -59,7 +59,7 @@ describe Api::V1::CakesController do it "tags the cake" do tags = ["cake", "cookies", "yummy"] - xhr :patch, :update, id: cake.id, cake: { tags: tags.join(", ") } + patch :update, params: { id: cake.id, cake: { tags: tags.join(", ") } }, xhr: true cake.reload expect(cake.tags.pluck(:name)).to match_array(tags) @@ -67,7 +67,7 @@ describe Api::V1::CakesController do it "updates the description" do new_story = "what is the haps on the craps" - xhr :patch, :update, id: cake.id, cake: { story: new_story } + patch :update, params: { id: cake.id, cake: { story: new_story } }, xhr: true cake.reload expect(cake.story).to eql(new_story) @@ -75,7 +75,7 @@ describe Api::V1::CakesController do it "updates the category" do category = create(:category) - xhr :patch, :update, id: cake.id, cake: { category_id: category.id } + patch :update, params: { id: cake.id, cake: { category_id: category.id } }, xhr: true cake.reload expect(cake.category).to eql(category) @@ -87,7 +87,7 @@ describe Api::V1::CakesController do before :each do user.creations << cake - xhr :delete, :destroy, id: cake.id + delete :destroy, params: { id: cake.id }, xhr: true end it "deletes the specified cake" do diff --git a/spec/controllers/api/v1/categories_controller_spec.rb b/spec/controllers/api/v1/categories_controller_spec.rb index cf7cd3ba..890bc407 100644 --- a/spec/controllers/api/v1/categories_controller_spec.rb +++ b/spec/controllers/api/v1/categories_controller_spec.rb @@ -7,7 +7,7 @@ module Api describe "#index" do it 'loads all the categories' do - xhr :get, :index + get :index, xhr: true expect(assigns(:categories)).to match_array(Category.all) end end diff --git a/spec/controllers/api/v1/logins_controller_spec.rb b/spec/controllers/api/v1/logins_controller_spec.rb index 3b8d53e8..8dfc6f65 100644 --- a/spec/controllers/api/v1/logins_controller_spec.rb +++ b/spec/controllers/api/v1/logins_controller_spec.rb @@ -7,7 +7,7 @@ describe Api::V1::LoginsController do let(:user) { create(:user) } it "returns the auth token" do - post :create, { email: user.email, password: 'password' } + post :create, params: { email: user.email, password: 'password' }, xhr: true expected_json = { auth_token: user.authentication_token }.to_json expect(response.body).to eql(expected_json) end @@ -16,7 +16,9 @@ describe Api::V1::LoginsController do context "when logging in with invalid credentials" do let(:user) { create(:user) } - before { post :create, { email: user.email, password: user.password.reverse } } + before do + post :create, params: { email: user.email, password: user.password.reverse }, xhr: true + end it "returns an empty auth token" do expect(response.body).to eql({ auth_token: "" }.to_json) diff --git a/spec/controllers/api/v1/photos_controller_spec.rb b/spec/controllers/api/v1/photos_controller_spec.rb index 9ce72eaa..193d011c 100644 --- a/spec/controllers/api/v1/photos_controller_spec.rb +++ b/spec/controllers/api/v1/photos_controller_spec.rb @@ -14,7 +14,7 @@ module Api describe "#index" do it "loads the cakes photos" do - xhr :get, :index, cake_id: cake.id + get :index, params: { cake_id: cake.id }, xhr: true expect(assigns(:photos)).to match_array(cake.photos) end end @@ -23,7 +23,7 @@ module Api let(:photo) { create(:photo, imageable: cake) } it "loads the photo" do - xhr :get, :show, cake_id: cake.id, id: photo.id + get :show, params: { cake_id: cake.id, id: photo.id }, xhr: true expect(assigns(:photo)).to eql(photo) end end @@ -34,7 +34,7 @@ module Api it "attaches a new photo to a cake" do allow(ProcessPhotoJob).to receive(:perform_later) - xhr :post, :create, cake_id: cake.id, watermark: "watery", image: file + post :create, params: { cake_id: cake.id, watermark: "watery", image: file }, xhr: true cake.reload expect(cake.photos.count).to eql(1) diff --git a/spec/controllers/api/v1/profiles_controller_spec.rb b/spec/controllers/api/v1/profiles_controller_spec.rb index d4c02e4b..8c10a7b2 100644 --- a/spec/controllers/api/v1/profiles_controller_spec.rb +++ b/spec/controllers/api/v1/profiles_controller_spec.rb @@ -12,7 +12,7 @@ module Api describe "#show" do it "loads the current users profile" do - xhr :get, :show, id: "me" + get :show, params: { id: "me" }, xhr: true expect(assigns(:profile)).to eql(user) end end @@ -28,7 +28,7 @@ module Api facebook: "facebookie", } - xhr :patch, :update, id: "me", profile: new_attributes + patch :update, params: { id: "me", profile: new_attributes }, xhr: true user.reload expect(user.name).to eql("new name") @@ -40,7 +40,7 @@ module Api end it "returns errors" do - xhr :patch, :update, id: "me", profile: { email: "" } + patch :update, params: { id: "me", profile: { email: "" } }, xhr: true json = JSON.parse(response.body) expect(json["email"]).to_not be_empty end diff --git a/spec/controllers/api/v1/tutorials_controller_spec.rb b/spec/controllers/api/v1/tutorials_controller_spec.rb index d1e9a749..b32cebfd 100644 --- a/spec/controllers/api/v1/tutorials_controller_spec.rb +++ b/spec/controllers/api/v1/tutorials_controller_spec.rb @@ -13,7 +13,7 @@ describe Api::V1::TutorialsController do let!(:other_tutorial) { create(:tutorial) } it "returns the users tutorials" do - xhr :get, :index + get :index, xhr: true expect(assigns(:tutorials)).to match_array([my_tutorial]) end end @@ -27,7 +27,7 @@ describe Api::V1::TutorialsController do description: "Connect with your friends - and other fascinating people", tags: "cake,cookie", } - xhr :post, :create, tutorial: attributes + post :create, params: { tutorial: attributes }, xhr: true expect(assigns(:tutorial)).to be_present expect(assigns(:tutorial).url).to eql(attributes[:url]) diff --git a/spec/controllers/api/v2/cakes_controller_spec.rb b/spec/controllers/api/v2/cakes_controller_spec.rb index dfba531c..c0ee7ed3 100644 --- a/spec/controllers/api/v2/cakes_controller_spec.rb +++ b/spec/controllers/api/v2/cakes_controller_spec.rb @@ -7,27 +7,27 @@ module Api describe "#index" do let!(:cakes) { create(:category, slug: "cakes") } - let!(:cookies) { create(:category, slug: "cookies") } + let!(:cookies_category) { create(:category, slug: "cookies") } let!(:cake) { create(:published_cake, name: "cake", category: cakes) } let!(:cookie) do - create(:published_cake, name: "cookie", category: cookies) + create(:published_cake, name: "cookie", category: cookies_category) end let!(:unpublished_cake) do create(:cake, name: "unpublished", category: cakes) end it "returns all published cakes" do - xhr :get, :index + get :index, xhr: true expect(assigns(:cakes)).to match_array([cake, cookie]) end it "returns all cakes in the category" do - xhr :get, :index, category: cookie.category.slug + get :index, params: { category: cookie.category.slug }, xhr: true expect(assigns(:cakes)).to match_array([cookie]) end it "returns all cakes matching the search query" do - xhr :get, :index, q: cake.name[0..2] + get :index, params: { q: cake.name[0..2] }, xhr: true expect(assigns(:cakes)).to match_array([cake]) end @@ -35,7 +35,7 @@ module Api cake.tag_list = "cakes" cake.save! - xhr :get, :index, tags: "cakes" + get :index, params: { tags: "cakes" }, xhr: true expect(assigns(:cakes)).to match_array([cake]) end end @@ -44,7 +44,7 @@ module Api let!(:cake) { create(:published_cake) } it "loads the cake" do - xhr :get, :show, id: cake.id + get :show, params: { id: cake.id }, xhr: true expect(assigns(:cake)).to eql(cake) end end diff --git a/spec/controllers/api/v2/categories_controller_spec.rb b/spec/controllers/api/v2/categories_controller_spec.rb index 3e5c4f65..ace15f56 100644 --- a/spec/controllers/api/v2/categories_controller_spec.rb +++ b/spec/controllers/api/v2/categories_controller_spec.rb @@ -9,7 +9,7 @@ module Api let!(:category) { create(:category) } it "loads all the categories" do - xhr :get, :index + get :index, xhr: true expect(assigns(:categories)).to match_array([category]) end end @@ -19,7 +19,7 @@ module Api let!(:category) { create(:category) } it "loads the specified category" do - xhr :get, :show, id: category.id + get :show, params: { id: category.id }, xhr: true expect(assigns(:category)).to eql(category) end end diff --git a/spec/controllers/api/v2/photos_controller_spec.rb b/spec/controllers/api/v2/photos_controller_spec.rb index 09bdc736..df1cef2e 100644 --- a/spec/controllers/api/v2/photos_controller_spec.rb +++ b/spec/controllers/api/v2/photos_controller_spec.rb @@ -10,7 +10,7 @@ module Api let!(:unprocessed_photo) { create(:photo, image_processing: true) } it "loads all processed photos" do - xhr :get, :index + get :index, xhr: true expect(assigns(:photos)).to match_array([processed_photo]) end end @@ -20,7 +20,7 @@ module Api let!(:photo) { create(:photo) } it "loads the specified photo" do - xhr :get, :show, id: photo.id + get :show, params: { id: photo.id }, xhr: true expect(assigns(:photo)).to eql(photo) end end diff --git a/spec/controllers/api/v2/tutorials_controller_spec.rb b/spec/controllers/api/v2/tutorials_controller_spec.rb index 65954243..4c4f4a5d 100644 --- a/spec/controllers/api/v2/tutorials_controller_spec.rb +++ b/spec/controllers/api/v2/tutorials_controller_spec.rb @@ -9,7 +9,7 @@ module Api let!(:tutorial) { create(:tutorial) } before :each do - xhr :get, :index + get :index, xhr: true end it "loads all the tutorials" do @@ -33,7 +33,7 @@ module Api let!(:tutorial) { create(:tutorial) } it "loads the single tutorial" do - xhr :get, :show, id: tutorial.id + get :show, params: { id: tutorial.id }, xhr: true expect(assigns(:tutorial)).to eql(tutorial) end end diff --git a/spec/controllers/api/v2/users_controller_spec.rb b/spec/controllers/api/v2/users_controller_spec.rb index 2400ede3..ffe96a63 100644 --- a/spec/controllers/api/v2/users_controller_spec.rb +++ b/spec/controllers/api/v2/users_controller_spec.rb @@ -9,7 +9,7 @@ module Api let!(:user) { create(:user) } it "loads all users" do - xhr :get, :index + get :index, xhr: true expect(assigns(:users)).to match_array([user]) end end @@ -18,7 +18,7 @@ module Api let!(:user) { create(:user) } it "loads the info on the user" do - xhr :get, :show, id: user.id + get :show, params: { id: user.id }, xhr: true expect(assigns(:user)).to eql(user) end end diff --git a/spec/controllers/favorites_controller_spec.rb b/spec/controllers/favorites_controller_spec.rb index 626f7938..13111646 100644 --- a/spec/controllers/favorites_controller_spec.rb +++ b/spec/controllers/favorites_controller_spec.rb @@ -9,7 +9,7 @@ describe FavoritesController do context "when adding a cake to your favorites" do before :each do - post :create, cake_id: cake.id + post :create, params: { cake_id: cake.id } end it "should add the cake to the logged in users favorites" do diff --git a/spec/controllers/my/avatars_controller_spec.rb b/spec/controllers/my/avatars_controller_spec.rb index 96ff82ce..8f4b6244 100644 --- a/spec/controllers/my/avatars_controller_spec.rb +++ b/spec/controllers/my/avatars_controller_spec.rb @@ -10,7 +10,7 @@ describe My::AvatarsController do context "when uploading a new avatar" do let(:image) { Rack::Test::UploadedFile.new('spec/fixtures/images/gorilla.jpg', 'image/jpeg') } - before { post :create, photo: { image: image } } + before { post :create, params: { photo: { image: image } } } it "saves the new avatar" do user.reload @@ -29,7 +29,7 @@ describe My::AvatarsController do end describe "#new" do - before { get :new, id: user.id } + before { get :new, params: { id: user.id } } it "displays the current avatar" do expect(assigns(:avatar)).to_not be_nil diff --git a/spec/controllers/my/passwords_controller_spec.rb b/spec/controllers/my/passwords_controller_spec.rb index 92262371..85b13ed7 100644 --- a/spec/controllers/my/passwords_controller_spec.rb +++ b/spec/controllers/my/passwords_controller_spec.rb @@ -6,7 +6,7 @@ describe My::PasswordsController do let(:user) { create(:user) } it "redirects you to the login page" do - put :update, id: user.id + put :update, params: { id: user.id } expect(response).to redirect_to(login_path) end end @@ -18,9 +18,12 @@ describe My::PasswordsController do context "when the new password and the confirmation password does not match" do before :each do - put :update, id: user.id, user: { - password: "foobar", - password_confirmation: "barfoo" + put :update, params: { + id: user.id, + user: { + password: "foobar", + password_confirmation: "barfoo" + } } end @@ -38,9 +41,12 @@ describe My::PasswordsController do let(:new_password) { "booyakasham" } before :each do - put :update, id: user.id, user: { - password: new_password, - password_confirmation: new_password + put :update, params: { + id: user.id, + user: { + password: new_password, + password_confirmation: new_password + } } end diff --git a/spec/controllers/my/settings_controller_spec.rb b/spec/controllers/my/settings_controller_spec.rb index 606aec17..19f2855f 100644 --- a/spec/controllers/my/settings_controller_spec.rb +++ b/spec/controllers/my/settings_controller_spec.rb @@ -15,7 +15,17 @@ describe My::SettingsController do before :each do http_login(user) - patch :update, id: user.id, user: { name: 'mo khan', email: 'mo@mokhan.ca', city: 'Calgary', website: 'http://mokhan.ca/', twitter: 'mocheen', facebook: 'fb' } + patch :update, params: { + id: user.id, + user: { + name: 'mo khan', + email: 'mo@mokhan.ca', + city: 'Calgary', + website: 'http://mokhan.ca/', + twitter: 'mocheen', + facebook: 'fb' + } + } end it "updates the users settings" do diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index d17728cb..5e0510d9 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -14,7 +14,7 @@ describe PasswordsController do it "sends a password reset email for the user" do allow(PasswordReset).to receive(:send_reset_instructions_to) - post :create, user: { email: email } + post :create, params: { user: { email: email } } expect(PasswordReset).to have_received(:send_reset_instructions_to).with(email) expect(response).to redirect_to(new_session_path) @@ -28,13 +28,13 @@ describe PasswordsController do it "loads the password reset token" do allow(User).to receive(:find_by).with(reset_password_token: reset_token).and_return(user) - get :edit, id: reset_token + get :edit, params: { id: reset_token } expect(assigns(:user)).to eql(user) end it "redirects to the homepage if the user cannot be found" do allow(User).to receive(:find_by).with(reset_password_token: reset_token).and_return(nil) - get :edit, id: reset_token + get :edit, params: { id: reset_token } expect(response).to redirect_to(root_path) end end @@ -47,7 +47,7 @@ describe PasswordsController do it "resets the users password" do allow(PasswordReset).to receive(:reset).with(reset_token, password).and_return(user) - patch :update, id: reset_token, user: { password: password } + patch :update, params: { id: reset_token, user: { password: password } } expect(PasswordReset).to have_received(:reset).with(reset_token, password) expect(response).to redirect_to(new_session_path) end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 83851499..da463d6b 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -16,7 +16,7 @@ describe ProfilesController do let(:creation) { create(:creation, user: user) } before :each do - get :show, id: user.id + get :show, params: { id: user.id } end it "returns a successful response" do diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 15ae43eb..d00353d3 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -7,7 +7,7 @@ describe RegistrationsController do it 'creates a new user' do allow(User).to receive(:login).with('mo@cakeside.com', 'password').and_return(user_session) - post :create, user: { name: 'mo', email: 'mo@cakeside.com', password: 'password' } + post :create, params: { user: { name: 'mo', email: 'mo@cakeside.com', password: 'password' } } expect(User.count).to eql(1) expect(response).to redirect_to(my_dashboard_path) @@ -16,7 +16,7 @@ describe RegistrationsController do end it 'displays errors' do - post :create, user: { name: 'mo', email: 'mo', password: 'password', password_confirmation: 'password' } + post :create, params: { user: { name: 'mo', email: 'mo', password: 'password', password_confirmation: 'password' } } expect(response).to redirect_to(new_session_path) expect(flash[:error]).to_not be_empty end diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb index 1e71471e..a227c175 100644 --- a/spec/controllers/search_controller_spec.rb +++ b/spec/controllers/search_controller_spec.rb @@ -18,7 +18,7 @@ describe SearchController do let!(:tutorial) { create(:tutorial, :description => 'cake') } let!(:other_tutorial) { create(:tutorial, :description => 'donut') } - before { get :index, { :q => 'cake' } } + before { get :index, params: { q: 'cake' } } it "returns a successful response" do expect(response).to be_success diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 200a28e4..79244518 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -30,7 +30,7 @@ describe SessionsController do before :each do allow(User).to receive(:login).with(email, password).and_return(user_session) - post :create, session: { email: email, password: password } + post :create, params: { session: { email: email, password: password } } end it "returns a valid session" do @@ -48,7 +48,7 @@ describe SessionsController do end it "returns an error" do - post :create, session: { email: 'x', password: 'y' } + post :create, params: { session: { email: 'x', password: 'y' } } expect(response).to redirect_to(login_path) expect(flash[:error]).to_not be_empty end @@ -61,7 +61,7 @@ describe SessionsController do before :each do session[:raphael] = user_session.key allow(controller).to receive(:user_session).and_return(user_session) - delete :destroy, id: "me" + delete :destroy, params: { id: "me" } end it { expect(session[:raphael]).to be_nil } diff --git a/spec/controllers/tutorials_controller_spec.rb b/spec/controllers/tutorials_controller_spec.rb index 6aa99f96..87443695 100644 --- a/spec/controllers/tutorials_controller_spec.rb +++ b/spec/controllers/tutorials_controller_spec.rb @@ -23,7 +23,7 @@ describe TutorialsController do before :each do user.tutorials << tutorial - get :show, :id => tutorial.to_param + get :show, params: { id: tutorial.to_param } end it "assigns the requested tutorial" do |
