diff --git a/app/models/app.rb b/app/models/app.rb index e7b3fae..073be68 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -10,7 +10,7 @@ class App # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature: # https://github.com/mongoid/mongoid/issues/703 # Using 32 character string as a workaround. - before_save :on => :create do |r| + before_create do |r| r.id = ActiveSupport::SecureRandom.hex end diff --git a/spec/controllers/apps_controller_spec.rb b/spec/controllers/apps_controller_spec.rb index 7eb420a..81468dd 100644 --- a/spec/controllers/apps_controller_spec.rb +++ b/spec/controllers/apps_controller_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' describe AppsController do - + render_views + it_requires_authentication it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete} @@ -32,7 +33,6 @@ describe AppsController do end describe "GET /apps/:id" do - render_views context 'logged in as an admin' do before(:each) do @user = Factory(:admin) @@ -151,10 +151,6 @@ describe AppsController do end context "when the update is successful" do - before do - @app.should_receive(:update_attributes).and_return(true) - end - it "should redirect to the app page" do put :update, :id => @app.id, :app => {} response.should redirect_to(app_path(@app)) @@ -165,6 +161,14 @@ describe AppsController do request.flash[:success].should match(/success/) end end + + context "changing name" do + it "should redirect to app page" do + id = @app.id + put :update, :id => id, :app => {:name => "new name"} + response.should redirect_to(app_path(id)) + end + end context "when the update is unsuccessful" do it "should render the edit page" do -- libgit2 0.21.2