Commit 25d141bdbef8a84e7b042ea2a8fdcb335583698c

Authored by Nathan Broadbent
2 parents cab37a1b 237744e5
Exists in master and in 1 other branch production

Merge branch 'master' of github.com:jdpace/errbit

app/controllers/apps_controller.rb
@@ -2,6 +2,7 @@ class AppsController < InheritedResources::Base @@ -2,6 +2,7 @@ class AppsController < InheritedResources::Base
2 2
3 before_filter :require_admin!, :except => [:index, :show] 3 before_filter :require_admin!, :except => [:index, :show]
4 before_filter :parse_email_at_notices_or_set_default, :only => [:create, :update] 4 before_filter :parse_email_at_notices_or_set_default, :only => [:create, :update]
  5 + respond_to :html
5 6
6 def show 7 def show
7 where_clause = {} 8 where_clause = {}
@@ -24,34 +25,29 @@ class AppsController < InheritedResources::Base @@ -24,34 +25,29 @@ class AppsController < InheritedResources::Base
24 end 25 end
25 26
26 def new 27 def new
27 - build_resource.watchers.build  
28 - @app.issue_tracker = IssueTracker.new 28 + plug_params build_resource
29 new! 29 new!
30 end 30 end
31 31
32 def edit 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 edit! 34 edit!
36 end 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 protected 37 protected
51 def begin_of_association_chain 38 def begin_of_association_chain
52 current_user unless current_user.admin? 39 current_user unless current_user.admin?
53 end 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 # email_at_notices is edited as a string, and stored as an array. 51 # email_at_notices is edited as a string, and stored as an array.
56 def parse_email_at_notices_or_set_default 52 def parse_email_at_notices_or_set_default
57 if params[:app] && val = params[:app][:email_at_notices] 53 if params[:app] && val = params[:app][:email_at_notices]
config/initializers/inherited_resources.rb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +InheritedResources.flash_keys = [:success, :error]
config/locales/en.yml
@@ -3,3 +3,11 @@ @@ -3,3 +3,11 @@
3 3
4 en: 4 en:
5 hello: "Hello world" 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,7 +201,7 @@ describe AppsController do
201 201
202 it "should display a message" do 202 it "should display a message" do
203 post :create, :app => {} 203 post :create, :app => {}
204 - request.flash[:notice].should match(/success/) 204 + request.flash[:success].should match(/success/)
205 end 205 end
206 end 206 end
207 end 207 end
@@ -219,7 +219,7 @@ describe AppsController do @@ -219,7 +219,7 @@ describe AppsController do
219 219
220 it "should display a message" do 220 it "should display a message" do
221 put :update, :id => @app.id, :app => {} 221 put :update, :id => @app.id, :app => {}
222 - request.flash[:notice].should match(/success/) 222 + request.flash[:success].should match(/success/)
223 end 223 end
224 end 224 end
225 225
@@ -424,7 +424,7 @@ describe AppsController do @@ -424,7 +424,7 @@ describe AppsController do
424 424
425 it "should display a message" do 425 it "should display a message" do
426 delete :destroy, :id => @app.id 426 delete :destroy, :id => @app.id
427 - request.flash[:notice].should match(/success/) 427 + request.flash[:success].should match(/success/)
428 end 428 end
429 429
430 it "should redirect to the apps page" do 430 it "should redirect to the apps page" do