Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorkasyanchuk/rails_time_travel
https://github.com/igorkasyanchuk/rails_time_travel
rails rails-development staging timecop
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/igorkasyanchuk/rails_time_travel
- Owner: igorkasyanchuk
- License: mit
- Created: 2021-01-15T22:47:56.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T13:21:07.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T07:00:45.701Z (9 months ago)
- Topics: rails, rails-development, staging, timecop
- Language: HTML
- Homepage: https://www.railsjazz.com/
- Size: 223 KB
- Stars: 17
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Rails Time Travel
![CI](https://github.com/igorkasyanchuk/rails_time_travel/workflows/MiniTest/badge.svg)
[![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
[![https://www.patreon.com/igorkasyanchuk](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/patron.svg?raw=true)](https://www.patreon.com/igorkasyanchuk)
[![Listed on OpenSource-Heroes.com](https://opensource-heroes.com/badge-v1.svg)](https://opensource-heroes.com/r/igorkasyanchuk/rails_time_travel)Time travel with `timecop` for your Rails app (in development, staging or other env).
Very often you need to create objects or other things in the "past". With thins gem and excellent `timecop` gem you can freeze time to any date/time.
For developers & QA's.
## Usage
Open `/rails/time_travel` to see
[](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/time_travel.png?raw=true)
Now you can adjust the datetime. Once you are done - just reset time (you will see a red button).
Note, that this datetime change is related only to your session.
## Installation
Add this line to your application's Gemfile:
```ruby
group :development do
gem 'rails_time_travel' # you can also use it on staging env or production
end
```## Limitations
- this approach has all limitation which timecop has. In addition it won't work on your background jobs or SQL's with `NOW()`, because this gem doesn't change system time and background job is a separate process.
- selected datetime is static, it means that value is freezed, if you need to change it you need to reset or adjust it with buttons## Contributing
* `BUNDLE_GEMFILE=gemfiles/rails_6_1.gemfile bundle exec rake test` to run for Rails 6.1
* `BUNDLE_GEMFILE=gemfiles/rails_6_0.gemfile bundle exec rake test` to run for Rails 6.0
* `BUNDLE_GEMFILE=gemfiles/rails_5_2.gemfile bundle exec rake test` to run for Rails 5.2## TODO
- jump to a specific datetime with datetime picker?
- CI for Rails 4.X
- protect with password (for example how I did in rails_performance gem)
- go the the future?
- make datetime not static? (use lambda)## Credits
https://stackoverflow.com/questions/32129741/can-you-use-timecop-gem-for-development-in-rails
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
[](https://www.railsjazz.com/?utm_source=github&utm_medium=bottom&utm_campaign=rails_time_travel)