Skip to content

Cleaning#36

Open
Teacher-droid wants to merge 11 commits intoistarengwa:updateSpecsfrom
Teacher-droid:development
Open

Cleaning#36
Teacher-droid wants to merge 11 commits intoistarengwa:updateSpecsfrom
Teacher-droid:development

Conversation

@Teacher-droid
Copy link

Cleaning trash

Copy link

@Nicolas-Hermet Nicolas-Hermet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vous avez galéré un peu non ?

Sinon pour moi, hormis le code commenté, tout est legit.

Comment on lines +6 to +9
let!(:user) { FactoryBot.create(:user) }
let!(:project) { FactoryBot.create(:project) }
let!(:housing) { FactoryBot.build(:housing) }
let!(:housing1) { FactoryBot.build(:housing, project_id: nil) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est sensé fonctionner avec juste create. Normalement si FactoryBot est bien configuré c'est lui qui est appelé lors du create

Copy link

@Monrocq Monrocq Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui on a perdu bcp de temps a chercher pourquoi il ne reconnait pas les méthodes implicites. Pour ne pas trop perdre de temps on lui à explicitement indiqué depuis quelle classe elles appartiennent

Comment on lines +4 to +15
=begin

#### SCHEDULE

# >> INDEX current_user if @projects include curent_user's project, render response status (200),
# >> Show project == curent_user if =! raise error, render,
# >> Create project --> To check that the project count added 1 project, render response status (200) if project.save else raise error
# >> Update --> project == curent_user if =! raise error, Project.update effective, raise_error if status: :unprocessable_entity
# >> Destroy --> project == curent_user if =! raise error, To check that the project count remove 1 project
# >>

=end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean Code implique qu'on ne laisse pas de code commenté (ni de commentaires d'aileurs) 😉

RSpec.describe ProjectsController, type: :request do
context 'GET / Index' do
let(:user) { create(:user) }
let(:project) { build(:project, user_id: current_user.id)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bien joué le build 👍

Comment on lines +36 to +70
=begin
describe '#show' do
context 'when a non-user/no_owner_user try to go on url show' do
it 'respond with unauthorized_show'
end

context 'when an authorized user render the show' do
it "send project's json to the view"
end
end


context '#create' do
describe "check that one project linked to an user been created" do
it 'create a project' do
get :create
expect(response).to have_http_status(200)
end
end
end


context '#update' do
describe "when a no_owner_user proceed for an update" do
it 'respond with unauthorized_update' do
get :update
expect(response).to have_http_status(200)
end
end
end

context '#destroy' do
describe "when a no_owner_user proceed for a project destruction" do
it 'respond with unauthorized_destroy'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem : jamais de code commenté.
Il vaut mieux rien.

# require only the support files necessary.
#
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alors cette ligne est sensé require tous les fichiers de spec.
Du coup pourquoi elle est commentée ? Yavait un problème avec ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lors de lancement de rails generate rspec:install des modifications se sont vu instancier dans le fichier rails_helper.rb
Sans oublier que pour une raison inconnue le DatabaseCleaner.clean_with(:truncation) causait problème chez certaines machines

Comment on lines -46 to -54
DatabaseCleaner.clean_with(:truncation)
DatabaseCleaner.strategy = :transaction
end
# start the transaction strategy as examples are run
config.around(:each) do |example|
DatabaseCleaner.cleaning do
example.run
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alors pour le coup, dans un code legacy, il faut toujours se méfier. S'il faut certains tests existant utilise des "vraie" créations en base qu'il faut nettoyer.

Pas de soucis pour supprimer ces lignes mais il faut savoir que dans la vraie vie on aurait fait une PR rien que pour ça ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants