Commit 7a0fdea03a925baf944d16bb062c4cf5a1cb9603
1 parent
d54402f6
Exists in
master
and in
1 other branch
specs for things that were untested
Moved too fast without thinking about tests, for a lot of things. Wrote tests for all_errs and environment params for /app/:id and /errs Tests for the Mongoid override reside in a separate fork of mongoid, found at https://github.com/mhs/mongoid/commit/e5b2b1346c73a2935c606317314b6ded07260429#diff-1 it didn't make sense to re-test this functionality.
Showing
3 changed files
with
113 additions
and
0 deletions
Show diff stats
lib/overrides/mongoid/relations/builder.rb
1 | +# ruby-fogbugz requires crack. crack adds the attributes method to strings, | |
2 | +# thus breaking the relations of Mongoid. | |
3 | +# Tests reside in a separate fork of mongoid: | |
4 | +# https://github.com/mhs/mongoid/commit/e5b2b1346c73a2935c606317314b6ded07260429#diff-1 | |
1 | 5 | module Mongoid |
2 | 6 | module Relations |
3 | 7 | class Builder | ... | ... |
spec/controllers/apps_controller_spec.rb
... | ... | @@ -74,6 +74,71 @@ describe AppsController do |
74 | 74 | assigns(:errs).size.should == 10 |
75 | 75 | end |
76 | 76 | end |
77 | + | |
78 | + context 'with resolved errors' do | |
79 | + before(:each) do | |
80 | + resolved_err = Factory.create(:err, app: @app, resolved: true) | |
81 | + Factory.create(:notice, err: resolved_err) | |
82 | + end | |
83 | + | |
84 | + context 'and no params' do | |
85 | + it 'shows only unresolved errs' do | |
86 | + get :show, id: @app.id | |
87 | + assigns(:errs).size.should == 1 | |
88 | + end | |
89 | + end | |
90 | + | |
91 | + context 'and all_errs=true params' do | |
92 | + it 'shows all errors' do | |
93 | + get :show, id: @app.id, all_errs: true | |
94 | + assigns(:errs).size.should == 2 | |
95 | + end | |
96 | + end | |
97 | + end | |
98 | + | |
99 | + context 'with environment filters' do | |
100 | + before(:each) do | |
101 | + environments = ['production', 'test', 'development', 'staging'] | |
102 | + 20.times do |i| | |
103 | + Factory.create(:err, app: @app, environment: environments[i % environments.length]) | |
104 | + end | |
105 | + end | |
106 | + | |
107 | + context 'no params' do | |
108 | + it 'shows errs for all environments' do | |
109 | + get :show, id: @app.id | |
110 | + assigns(:errs).size.should == 21 | |
111 | + end | |
112 | + end | |
113 | + | |
114 | + context 'environment production' do | |
115 | + it 'shows errs for just production' do | |
116 | + get :show, id: @app.id, environment: :production | |
117 | + assigns(:errs).size.should == 6 | |
118 | + end | |
119 | + end | |
120 | + | |
121 | + context 'environment staging' do | |
122 | + it 'shows errs for just staging' do | |
123 | + get :show, id: @app.id, environment: :staging | |
124 | + assigns(:errs).size.should == 5 | |
125 | + end | |
126 | + end | |
127 | + | |
128 | + context 'environment development' do | |
129 | + it 'shows errs for just development' do | |
130 | + get :show, id: @app.id, environment: :development | |
131 | + assigns(:errs).size.should == 5 | |
132 | + end | |
133 | + end | |
134 | + | |
135 | + context 'environment test' do | |
136 | + it 'shows errs for just test' do | |
137 | + get :show, id: @app.id, environment: :test | |
138 | + assigns(:errs).size.should == 5 | |
139 | + end | |
140 | + end | |
141 | + end | |
77 | 142 | end |
78 | 143 | |
79 | 144 | context 'logged in as a user' do | ... | ... |
spec/controllers/errs_controller_spec.rb
... | ... | @@ -54,6 +54,50 @@ describe ErrsController do |
54 | 54 | assigns(:errs).size.should == 10 |
55 | 55 | end |
56 | 56 | end |
57 | + | |
58 | + context 'with environment filters' do | |
59 | + before(:each) do | |
60 | + environments = ['production', 'test', 'development', 'staging'] | |
61 | + 20.times do |i| | |
62 | + Factory.create(:err, environment: environments[i % environments.length]) | |
63 | + end | |
64 | + end | |
65 | + | |
66 | + context 'no params' do | |
67 | + it 'shows errs for all environments' do | |
68 | + get :index | |
69 | + assigns(:errs).size.should == 21 | |
70 | + end | |
71 | + end | |
72 | + | |
73 | + context 'environment production' do | |
74 | + it 'shows errs for just production' do | |
75 | + get :index, environment: :production | |
76 | + assigns(:errs).size.should == 6 | |
77 | + end | |
78 | + end | |
79 | + | |
80 | + context 'environment staging' do | |
81 | + it 'shows errs for just staging' do | |
82 | + get :index, environment: :staging | |
83 | + assigns(:errs).size.should == 5 | |
84 | + end | |
85 | + end | |
86 | + | |
87 | + context 'environment development' do | |
88 | + it 'shows errs for just development' do | |
89 | + get :index, environment: :development | |
90 | + assigns(:errs).size.should == 5 | |
91 | + end | |
92 | + end | |
93 | + | |
94 | + context 'environment test' do | |
95 | + it 'shows errs for just test' do | |
96 | + get :index, environment: :test | |
97 | + assigns(:errs).size.should == 5 | |
98 | + end | |
99 | + end | |
100 | + end | |
57 | 101 | end |
58 | 102 | |
59 | 103 | context 'when logged in as a user' do | ... | ... |