File tree Expand file tree Collapse file tree 5 files changed +14
-20
lines changed
Expand file tree Collapse file tree 5 files changed +14
-20
lines changed Original file line number Diff line number Diff line change 11class V1 ::AdminController < ApplicationController
2- before_action :admin?
2+ before_action :admin?
33
4- def index
5- @measure = current_user . measures
6- json_response ( @measure )
7- end
4+ def index
5+ @measure = current_user . measures
6+ json_response ( @measure )
7+ end
88end
Original file line number Diff line number Diff line change 11class Measure < ApplicationRecord
22 belongs_to :user
33
4- before_save { self . body_part_name = body_part_name ? body_part_name . split ( ' ' ) . map ( &:capitalize ) . join ( ' ' ) : body_part_name }
4+ before_save { self . body_part_name = body_part_name ? body_part_name . split ( ' ' ) . map ( &:capitalize ) . join ( ' ' ) : body_part_name }
55
66 has_one :body_part , dependent : :destroy
77 has_many :measurements , dependent : :destroy
88
99 validates_presence_of ( :body_part_name )
1010
11-
12- validates :body_part_name , uniqueness : true
13-
11+ validates :body_part_name , uniqueness : true
1412end
Original file line number Diff line number Diff line change 11class User < ApplicationRecord
22 has_secure_password
3- before_save { self . email = email . downcase }
3+ before_save { self . email = email . downcase }
44
5- validates_length_of :password , minimum : 6
5+ validates_length_of :password , minimum : 6
66
77 has_many :measures , dependent : :destroy
88
99 validates_presence_of ( :name , :email , :password_digest )
1010
11- VALID_EMAIL_REGEX = /\A [\w +\- .]+@[a-z\d \- ]+(\. [a-z\d \- ]+)*\. [a-z]+\z /i . freeze
11+ VALID_EMAIL_REGEX = /\A [\w +\- .]+@[a-z\d \- ]+(\. [a-z\d \- ]+)*\. [a-z]+\z /i . freeze
1212
1313 validates_length_of :email , maximum : 255
14- validates :email , uniqueness : { scope : :id } , format : { with : VALID_EMAIL_REGEX }
15-
16-
17-
18- end
14+ validates :email , uniqueness : { scope : :id } , format : { with : VALID_EMAIL_REGEX }
15+ end
Original file line number Diff line number Diff line change 1919 end
2020
2121 it { should validate_length_of ( :password ) . is_at_least ( 6 ) }
22-
2322end
Original file line number Diff line number Diff line change 11require 'rails_helper'
22
3- RSpec . describe " V1::Admins" , type : :request do
4- # initialize test data
3+ RSpec . describe ' V1::Admins' , type : :request do
4+ # initialize test data
55 let ( :user ) { create ( :user ) }
66 let ( :admin ) { create ( :user , admin : true ) }
77 let! ( :measures ) { create_list ( :measure , 10 , user_id : admin . id ) }
You can’t perform that action at this time.
0 commit comments