Comments (1)
I've eliminated all of the before :each
hooks that were setting up roles by using a before :suite
hook for this. For this to work, I had to make sure that the roles were defined after database_cleaner
truncated all existing table in the before :suite
hook in rails_helper.rb
(I just called define_roles
below their call to truncation in there). Additionally, when truncation is used for the capybara javascript examples, it needs to be set up to not truncate the roles
table. So here are the important changes:
# rails_helper.rb
...
config.before(:suite) do
...
DatabaseCleaner.clean_with(:truncation) # this line truncates all tables before the test suite runs
define_roles(:setter,:athlete) # make sure this table is created after line above runs
end
config.before(:each) do
...
DatabaseCleaner.strategy = :truncation, {except: %w[roles]}
end
...
Some people might argue that it is bad to have any data setup for the entire test suite like this. I don't fully understand their argument, so I might change my mind about this later, but for now I think it is okay because when I test the actual role model itself, I don't use the :athlete
and :setter
roles, I use dummy roles that have no special meaning in my application (e.g. :some_role
).
Also, I've left all hooks that set up stubs/mocks, and hooks that run http requests. I think the stubs and mocks can't be setup in before :all
hooks. For the before hooks that run http requests, I think they are better as shared contexts, but I need to read more about that.
from climbalytics.
Related Issues (20)
- Review Rails Insecure Defaults
- `generate_validations_for` issues when switching branches and db changes are involved
- Disable monkey patching in rspec
- Review rspec configurations and clean them up
- Validate that a gym has an address, not just a location
- Is the State model appropriate?
- Should a climb be required to belong to a gym_section? HOT 1
- Change "enter" behavior on new gym form
- remove password requirement from user profile update HOT 1
- Separate `User` model into two models
- Look into weird parameter list for ajax call to /users.json
- Style the gym picker partial HOT 1
- Create page for editing user accounts HOT 2
- Make panel_sections a partial, not something you import
- Consider refactoring `Climbalytics.getFlash()`
- Review all GET routes
- Use \A and \z instead of ^ and $ in regular expressions
- Learn more about Rails application secrete keys
- Review potential for off-site redirect security issues
- Review what goes into href attribute for a tags
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from climbalytics.