tenon 1.0.15 → 1.0.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1113d2e336c7bb39401c7000d5adf08482d2523
4
- data.tar.gz: 502bfd2c4086090b8cb25a3fd66ac84240757ca3
3
+ metadata.gz: 756d9629ad6ec902635f465f95855733cadada97
4
+ data.tar.gz: 74971b9e5f7a49503264b97a3db09a2192ad1f9c
5
5
  SHA512:
6
- metadata.gz: 206b38bca3565c932cd9ed1ca0c9877dc12989dfa558eca04e03c758d318477a925ffbd92d4b0aa1be648d5f32ae814b3ead53f83e7a5dd57e71ebe5fed12687
7
- data.tar.gz: 51f8fb44d61453d1016138a075eb135cc9954cceffe188a0d8f8d6b874118b867a5133db7e332298549f2082a892881b1b4a0103defbfead4e2dfc418aae341f
6
+ metadata.gz: 90e2292261eebe09714988e27131662ab48ded4f1f2116154d73e1983813bf42840940aab6f00b3839d3e34082526b37c4f3865abbdb31a84ed55360bb25ee03
7
+ data.tar.gz: 32373fc17fda817e1af02640e252dc6058734d4575e70f9d2202155022226eb05cd6d1b09da9e4e3244d93a7e96d503a797d0b3cc55f7667bc9984aa06c12959
@@ -44,7 +44,7 @@ module Tenon
44
44
  end
45
45
 
46
46
  self.resource = resource.decorate
47
- respond_with(resource.decorate, location: polymorphic_index_path)
47
+ respond_with(resource.decorate, location: after_update_path)
48
48
  end
49
49
 
50
50
  def create
@@ -54,7 +54,7 @@ module Tenon
54
54
  flash[:notice] = "#{human_name} saved successfully."
55
55
  save_item_version if resource.respond_to?(:versions)
56
56
  end
57
- respond_with(resource.decorate, location: polymorphic_index_path, status: 201)
57
+ respond_with(resource.decorate, location: after_create_path, status: (201 if resource.valid?))
58
58
  end
59
59
 
60
60
  def destroy
@@ -120,6 +120,18 @@ module Tenon
120
120
  singular_name.titleize
121
121
  end
122
122
 
123
+ def after_create_path
124
+ if Tenon.config.after_create_path == :edit && resource.valid?
125
+ polymorphic_path([:edit, resource])
126
+ else
127
+ polymorphic_index_path
128
+ end
129
+ end
130
+
131
+ def after_update_path
132
+ after_create_path
133
+ end
134
+
123
135
  def polymorphic_index_path
124
136
  polymorphic_path([klass])
125
137
  end
@@ -18,6 +18,11 @@ Tenon.configure do |config|
18
18
  }
19
19
  }
20
20
 
21
+ # Set the default after_update and after_create path
22
+ # :edit or :index
23
+ config.after_update_path = :edit
24
+ config.after_create_path = :edit
25
+
21
26
  # Set up languages for front-end internationalization
22
27
  # Currently Tenon is anglo-centric so you don't need to
23
28
  # specify English.
data/lib/tenon/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tenon
2
- VERSION = '1.0.15'
2
+ VERSION = '1.0.16'
3
3
  end
data/lib/tenon.rb CHANGED
@@ -22,6 +22,7 @@ module Tenon
22
22
  end
23
23
 
24
24
  class Configuration
25
- attr_accessor :mobile_layout, :languages, :seo_callout, :front_end
25
+ attr_accessor :mobile_layout, :languages, :seo_callout, :front_end,
26
+ :after_create_path, :after_update_path
26
27
  end
27
28
  end
@@ -15,6 +15,7 @@ describe Tenon::PostsController do
15
15
  before do
16
16
  controller.stub(:current_user) { user }
17
17
  controller.stub(:polymorphic_index_path) { posts_path }
18
+ controller.stub(:after_update_path) { posts_path }
18
19
  end
19
20
 
20
21
  describe 'PATCH update' do
@@ -7,7 +7,7 @@ require 'spec_helper'
7
7
  describe Tenon::GalleriesController do
8
8
  routes { Tenon::Engine.routes }
9
9
 
10
- let(:gallery) { double.as_null_object }
10
+ let(:gallery) { mock_model(Tenon::Gallery).as_null_object }
11
11
 
12
12
  before do
13
13
  controller.stub(:current_user) { user }
@@ -158,7 +158,7 @@ describe Tenon::GalleriesController do
158
158
  context 'with a successful save' do
159
159
  it 'should redirect to index' do
160
160
  post :create, gallery: params
161
- expect(response).to redirect_to('/tenon/galleries')
161
+ expect(response).to redirect_to("/tenon/galleries/#{assigns[:gallery].id}/edit")
162
162
  end
163
163
  end
164
164
  end
@@ -205,7 +205,7 @@ describe Tenon::GalleriesController do
205
205
  context 'with a successful save' do
206
206
  it 'should redirect to index' do
207
207
  patch :update, gallery: params, id: 1
208
- expect(response).to redirect_to('/tenon/galleries')
208
+ expect(response).to redirect_to("/tenon/galleries/#{assigns[:gallery].id}/edit")
209
209
  end
210
210
 
211
211
  it 'should set the flash' do
@@ -216,6 +216,8 @@ describe Tenon::GalleriesController do
216
216
  end
217
217
 
218
218
  describe 'DELETE destroy' do
219
+ let(:gallery) { double.as_null_object }
220
+
219
221
  before do
220
222
  Tenon::Gallery.stub(:find) { gallery }
221
223
  end
@@ -60,7 +60,6 @@ describe 'An admin', js: true do
60
60
 
61
61
  # Save it
62
62
  click_button 'Save'
63
- expect(page).to have_content('My Test Event')
64
63
  expect(page).to have_content('Event saved successfully.')
65
64
  end
66
65
  end
@@ -87,7 +86,6 @@ describe 'An admin', js: true do
87
86
 
88
87
  # Save it
89
88
  click_button 'Save'
90
- expect(page).to have_content('My Test Event')
91
89
  expect(page).to have_content('Event saved successfully.')
92
90
  end
93
91
  end
@@ -35,7 +35,6 @@ describe 'An admin', js: true do
35
35
  fill_in 'gallery[title]', with: 'My Test Gallery'
36
36
  click_button 'Save'
37
37
  end
38
- expect(page).to have_content('My Test Gallery')
39
38
  expect(page).to have_content('Gallery saved successfully.')
40
39
  end
41
40
  end
@@ -76,7 +75,6 @@ describe 'An admin', js: true do
76
75
  fill_in 'gallery[title]', with: 'My Test Gallery'
77
76
  click_button 'Save'
78
77
  end
79
- expect(page).to have_content('My Test Gallery')
80
78
  expect(page).to have_content('Gallery saved successfully.')
81
79
  end
82
80
  end
@@ -54,7 +54,6 @@ describe 'An admin', js: true do
54
54
  fill_in 'page[title]', with: 'My Test Page'
55
55
  click_button 'Save'
56
56
  end
57
- expect(page).to have_content('My Test Page')
58
57
  expect(page).to have_content('Page saved successfully.')
59
58
  end
60
59
  end
@@ -80,7 +79,6 @@ describe 'An admin', js: true do
80
79
  fill_in 'page[title]', with: 'My Test Page'
81
80
  click_button 'Save'
82
81
  end
83
- expect(page).to have_content('My Test Page')
84
82
  expect(page).to have_content('Page saved successfully.')
85
83
  end
86
84
  end
@@ -50,7 +50,6 @@ describe 'An admin', js: true do
50
50
  fill_in 'post[title]', with: 'My Test Post'
51
51
  click_button 'Save'
52
52
  end
53
- expect(page).to have_content('My Test Post')
54
53
  expect(page).to have_content('Post saved successfully.')
55
54
  end
56
55
  end
@@ -75,7 +74,6 @@ describe 'An admin', js: true do
75
74
  fill_in 'post[title]', with: 'My Test Post'
76
75
  click_button 'Save'
77
76
  end
78
- expect(page).to have_content('My Test Post')
79
77
  expect(page).to have_content('Post saved successfully.')
80
78
  end
81
79
  end
@@ -58,7 +58,6 @@ describe 'An admin', js: true do
58
58
  fill_in 'tenon_callout[button_text]', with: 'Go!'
59
59
  click_button 'Save'
60
60
  end
61
- expect(page).to have_content('My Test TenonCallout')
62
61
  expect(page).to have_content('Tenon Callout saved successfully.')
63
62
  end
64
63
  end
@@ -83,7 +82,6 @@ describe 'An admin', js: true do
83
82
  fill_in 'tenon_callout[title]', with: 'My Test TenonCallout'
84
83
  click_button 'Save'
85
84
  end
86
- expect(page).to have_content('My Test TenonCallout')
87
85
  expect(page).to have_content('Tenon Callout saved successfully.')
88
86
  end
89
87
  end
@@ -53,7 +53,6 @@ describe 'An admin', js: true do
53
53
  fill_in 'user[password_confirmation]', with: 'password123'
54
54
  click_button 'Save'
55
55
  end
56
- expect(page).to have_content('test@user.com')
57
56
  expect(page).to have_content('User saved successfully.')
58
57
  end
59
58
  end
@@ -80,7 +79,6 @@ describe 'An admin', js: true do
80
79
  fill_in 'user[email]', with: 'test@user.com'
81
80
  click_button 'Save'
82
81
  end
83
- expect(page).to have_content('test@user.com')
84
82
  expect(page).to have_content('User saved successfully.')
85
83
  end
86
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.15
4
+ version: 1.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - factor[e] design initiative
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_errors
@@ -1366,7 +1366,6 @@ files:
1366
1366
  - spec/features/tenon/assets_spec.rb
1367
1367
  - spec/features/tenon/comments_spec.rb
1368
1368
  - spec/features/tenon/contacts_spec.rb
1369
- - spec/features/tenon/events/events_form_spec.rb
1370
1369
  - spec/features/tenon/events_spec.rb
1371
1370
  - spec/features/tenon/galleries_spec.rb
1372
1371
  - spec/features/tenon/pages_spec.rb
@@ -1480,7 +1479,6 @@ test_files:
1480
1479
  - spec/features/tenon/assets_spec.rb
1481
1480
  - spec/features/tenon/comments_spec.rb
1482
1481
  - spec/features/tenon/contacts_spec.rb
1483
- - spec/features/tenon/events/events_form_spec.rb
1484
1482
  - spec/features/tenon/events_spec.rb
1485
1483
  - spec/features/tenon/galleries_spec.rb
1486
1484
  - spec/features/tenon/pages_spec.rb
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
- include RequestHelpers
3
-
4
- describe 'Using the event form', js: true do
5
- let!(:admin) { create(:admin) }
6
-
7
- before do
8
- login(admin)
9
- end
10
-
11
- context 'when doing everything right' do
12
- it 'should save the event' do
13
- visit new_event_path
14
- fill_in 'event[title]', with: 'My Test Event'
15
-
16
- # Manually testing the datepickers is outside the scope of this spec
17
- page.execute_script("$('#event_starts_at').val('#{Time.now}')")
18
- page.execute_script("$('#event_ends_at').val('#{Time.now + 1.hour}')")
19
-
20
- # Save it
21
- click_button 'Save'
22
- expect(page).to have_content('My Test Event')
23
- expect(page).to have_content('Event saved successfully.')
24
- end
25
- end
26
-
27
- context 'when doing something wrong' do
28
- it 'should not save the page' do
29
- visit new_event_path
30
- within('form#new_event') do
31
- click_button 'Save'
32
- end
33
- expect(page).to have_content("Title can't be blank")
34
- expect(page).to have_content("Starts at can't be blank")
35
- expect(page).to have_content("Ends at can't be blank")
36
- end
37
- end
38
- end