Commit 25d141bdbef8a84e7b042ea2a8fdcb335583698c
Exists in
master
and in
1 other branch
Merge branch 'master' of github.com:jdpace/errbit
Showing
4 changed files
with
24 additions
and
19 deletions
Show diff stats
app/controllers/apps_controller.rb
... | ... | @@ -2,6 +2,7 @@ class AppsController < InheritedResources::Base |
2 | 2 | |
3 | 3 | before_filter :require_admin!, :except => [:index, :show] |
4 | 4 | before_filter :parse_email_at_notices_or_set_default, :only => [:create, :update] |
5 | + respond_to :html | |
5 | 6 | |
6 | 7 | def show |
7 | 8 | where_clause = {} |
... | ... | @@ -24,34 +25,29 @@ class AppsController < InheritedResources::Base |
24 | 25 | end |
25 | 26 | |
26 | 27 | def new |
27 | - build_resource.watchers.build | |
28 | - @app.issue_tracker = IssueTracker.new | |
28 | + plug_params build_resource | |
29 | 29 | new! |
30 | 30 | end |
31 | 31 | |
32 | 32 | def edit |
33 | - resource.watchers.build if resource.watchers.none? | |
34 | - resource.issue_tracker = IssueTracker.new if resource.issue_tracker.nil? | |
33 | + plug_params resource | |
35 | 34 | edit! |
36 | 35 | end |
37 | 36 | |
38 | - def create | |
39 | - create! :success => 'Great success! Configure your app with the API key below' | |
40 | - end | |
41 | - | |
42 | - def update | |
43 | - update! :success => "Good news everyone! '#{resource.name}' was successfully updated." | |
44 | - end | |
45 | - | |
46 | - def destroy | |
47 | - destroy! :success => "'#{resource.name}' was successfully destroyed." | |
48 | - end | |
49 | - | |
50 | 37 | protected |
51 | 38 | def begin_of_association_chain |
52 | 39 | current_user unless current_user.admin? |
53 | 40 | end |
54 | 41 | |
42 | + def interpolation_options | |
43 | + {:app_name => resource.name} | |
44 | + end | |
45 | + | |
46 | + def plug_params app | |
47 | + app.watchers.build if app.watchers.none? | |
48 | + app.issue_tracker = IssueTracker.new if app.issue_tracker.nil? | |
49 | + end | |
50 | + | |
55 | 51 | # email_at_notices is edited as a string, and stored as an array. |
56 | 52 | def parse_email_at_notices_or_set_default |
57 | 53 | if params[:app] && val = params[:app][:email_at_notices] | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +InheritedResources.flash_keys = [:success, :error] | ... | ... |
config/locales/en.yml
... | ... | @@ -3,3 +3,11 @@ |
3 | 3 | |
4 | 4 | en: |
5 | 5 | hello: "Hello world" |
6 | + flash: | |
7 | + apps: | |
8 | + create: | |
9 | + success: Great success! Configure your app with the API key below | |
10 | + update: | |
11 | + success: "Good news everyone! '%{app_name}' was successfully updated." | |
12 | + destroy: | |
13 | + success: "'%{app_name}' was successfully destroyed." | ... | ... |
spec/controllers/apps_controller_spec.rb
... | ... | @@ -201,7 +201,7 @@ describe AppsController do |
201 | 201 | |
202 | 202 | it "should display a message" do |
203 | 203 | post :create, :app => {} |
204 | - request.flash[:notice].should match(/success/) | |
204 | + request.flash[:success].should match(/success/) | |
205 | 205 | end |
206 | 206 | end |
207 | 207 | end |
... | ... | @@ -219,7 +219,7 @@ describe AppsController do |
219 | 219 | |
220 | 220 | it "should display a message" do |
221 | 221 | put :update, :id => @app.id, :app => {} |
222 | - request.flash[:notice].should match(/success/) | |
222 | + request.flash[:success].should match(/success/) | |
223 | 223 | end |
224 | 224 | end |
225 | 225 | |
... | ... | @@ -424,7 +424,7 @@ describe AppsController do |
424 | 424 | |
425 | 425 | it "should display a message" do |
426 | 426 | delete :destroy, :id => @app.id |
427 | - request.flash[:notice].should match(/success/) | |
427 | + request.flash[:success].should match(/success/) | |
428 | 428 | end |
429 | 429 | |
430 | 430 | it "should redirect to the apps page" do | ... | ... |