spec: move user to shared context

This commit is contained in:
Georg Gadinger 2020-04-30 22:57:00 +02:00
parent 54532c71e1
commit 137743001f
7 changed files with 2 additions and 10 deletions

View File

@ -4,7 +4,6 @@
require "rails_helper" require "rails_helper"
describe Ajax::AnswerController, :ajax_controller, type: :controller do describe Ajax::AnswerController, :ajax_controller, type: :controller do
let(:user) { FactoryBot.create(:user) }
let(:question) { FactoryBot.create(:question, user: FactoryBot.build(:user, privacy_allow_stranger_answers: asker_allows_strangers)) } let(:question) { FactoryBot.create(:question, user: FactoryBot.build(:user, privacy_allow_stranger_answers: asker_allows_strangers)) }
let(:asker_allows_strangers) { true } let(:asker_allows_strangers) { true }

View File

@ -4,7 +4,6 @@
require "rails_helper" require "rails_helper"
describe Ajax::CommentController, :ajax_controller, type: :controller do describe Ajax::CommentController, :ajax_controller, type: :controller do
let(:user) { FactoryBot.create(:user) }
let(:answer) { FactoryBot.create(:answer, user: FactoryBot.create(:user)) } let(:answer) { FactoryBot.create(:answer, user: FactoryBot.create(:user)) }
describe "#create" do describe "#create" do

View File

@ -3,8 +3,6 @@
require "rails_helper" require "rails_helper"
describe Ajax::FriendController, :ajax_controller, type: :controller do describe Ajax::FriendController, :ajax_controller, type: :controller do
let(:user) { FactoryBot.create(:user) }
describe "#create" do describe "#create" do
let(:params) do let(:params) do
{ {

View File

@ -4,8 +4,6 @@
require "rails_helper" require "rails_helper"
describe Ajax::InboxController, :ajax_controller, type: :controller do describe Ajax::InboxController, :ajax_controller, type: :controller do
let(:user) { FactoryBot.create(:user) }
describe "#create" do describe "#create" do
subject { post(:create) } subject { post(:create) }

View File

@ -3,8 +3,6 @@
require "rails_helper" require "rails_helper"
describe Ajax::QuestionController, :ajax_controller, type: :controller do describe Ajax::QuestionController, :ajax_controller, type: :controller do
let(:user) { FactoryBot.create(:user) }
describe "#create" do describe "#create" do
shared_examples "creates the question" do |check_for_inbox = true| shared_examples "creates the question" do |check_for_inbox = true|
it "creates the question" do it "creates the question" do

View File

@ -4,8 +4,6 @@
require "rails_helper" require "rails_helper"
describe Ajax::SmileController, :ajax_controller, type: :controller do describe Ajax::SmileController, :ajax_controller, type: :controller do
let(:user) { FactoryBot.create(:user) }
describe "#create" do describe "#create" do
let(:params) do let(:params) do
{ {

View File

@ -1,6 +1,8 @@
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_context "AjaxController context" do RSpec.shared_context "AjaxController context" do
let(:user) { FactoryBot.create(:user) }
shared_examples "returns the expected response" do shared_examples "returns the expected response" do
it "returns the expected response" do it "returns the expected response" do
expect(JSON.parse(subject.body)).to match(expected_response) expect(JSON.parse(subject.body)).to match(expected_response)