Created
September 22, 2020 15:13
-
-
Save shilovk/440c6893e991fe5e4a8926cc354c5b1a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def time_valid?(time = Time.current) | |
return true unless self.notify_on_time | |
Time.current >= 8 && Time.current <= 18 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
decribe '#time_valid?' do | |
let(:user) { create(:user) } | |
let(:user_with_time) { create(:user, :notify_on_time) } | |
it 'Time is valid for user, that can get notiies on all time' do | |
expect(user.time_valid?).to be true | |
end | |
it 'Time is valid for user_with_time, that can get notiies only through 8-18' do | |
expect(user_with_time.time_valid?(8)).to be true | |
expect(user_with_time.time_valid?(12)).to be true | |
expect(user_with_time.time_valid?(18)).to be true | |
end | |
it 'Time is not valid for user_with_time, that can get notiies only through 8-18' do | |
expect(user_with_time.time_valid?(7)).to be false | |
expect(user_with_time.time_valid?(20)).to be false | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment