Conversation
add a README and a license file
fix gemfile lock
…nt test, update component test, destroy component test within a 74% coverage
Nicolas-Hermet
left a comment
There was a problem hiding this comment.
Vous avez galéré un peu non ?
Sinon pour moi, hormis le code commenté, tout est legit.
| let!(:user) { FactoryBot.create(:user) } | ||
| let!(:project) { FactoryBot.create(:project) } | ||
| let!(:housing) { FactoryBot.build(:housing) } | ||
| let!(:housing1) { FactoryBot.build(:housing, project_id: nil) } |
There was a problem hiding this comment.
C'est sensé fonctionner avec juste create. Normalement si FactoryBot est bien configuré c'est lui qui est appelé lors du create
There was a problem hiding this comment.
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
| =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 |
There was a problem hiding this comment.
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)} |
| =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' | ||
|
|
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
Alors cette ligne est sensé require tous les fichiers de spec.
Du coup pourquoi elle est commentée ? Yavait un problème avec ?
There was a problem hiding this comment.
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
| 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 |
There was a problem hiding this comment.
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 ;)
Cleaning trash