Commit 74ed31b04b8d03c7f300b68f7b0fc8582bb05038
1 parent
78becdf1
Exists in
master
and in
1 other branch
Setting app id once - on create.
Showing
2 changed files
with
11 additions
and
7 deletions
Show diff stats
app/models/app.rb
... | ... | @@ -10,7 +10,7 @@ class App |
10 | 10 | # There seems to be a Mongoid bug making it impossible to use String identity with references_many feature: |
11 | 11 | # https://github.com/mongoid/mongoid/issues/703 |
12 | 12 | # Using 32 character string as a workaround. |
13 | - before_save :on => :create do |r| | |
13 | + before_create do |r| | |
14 | 14 | r.id = ActiveSupport::SecureRandom.hex |
15 | 15 | end |
16 | 16 | ... | ... |
spec/controllers/apps_controller_spec.rb
1 | 1 | require 'spec_helper' |
2 | 2 | |
3 | 3 | describe AppsController do |
4 | - | |
4 | + render_views | |
5 | + | |
5 | 6 | it_requires_authentication |
6 | 7 | it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete} |
7 | 8 | |
... | ... | @@ -32,7 +33,6 @@ describe AppsController do |
32 | 33 | end |
33 | 34 | |
34 | 35 | describe "GET /apps/:id" do |
35 | - render_views | |
36 | 36 | context 'logged in as an admin' do |
37 | 37 | before(:each) do |
38 | 38 | @user = Factory(:admin) |
... | ... | @@ -151,10 +151,6 @@ describe AppsController do |
151 | 151 | end |
152 | 152 | |
153 | 153 | context "when the update is successful" do |
154 | - before do | |
155 | - @app.should_receive(:update_attributes).and_return(true) | |
156 | - end | |
157 | - | |
158 | 154 | it "should redirect to the app page" do |
159 | 155 | put :update, :id => @app.id, :app => {} |
160 | 156 | response.should redirect_to(app_path(@app)) |
... | ... | @@ -165,6 +161,14 @@ describe AppsController do |
165 | 161 | request.flash[:success].should match(/success/) |
166 | 162 | end |
167 | 163 | end |
164 | + | |
165 | + context "changing name" do | |
166 | + it "should redirect to app page" do | |
167 | + id = @app.id | |
168 | + put :update, :id => id, :app => {:name => "new name"} | |
169 | + response.should redirect_to(app_path(id)) | |
170 | + end | |
171 | + end | |
168 | 172 | |
169 | 173 | context "when the update is unsuccessful" do |
170 | 174 | it "should render the edit page" do | ... | ... |