enju_seed 0.2.0.beta.1 → 0.2.0.beta.2

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: 1822f4c15dae152625288a9a7cb4f1a9a7035756
4
- data.tar.gz: 778cd3501db1631ad1dfb9c36f99ff07263b7947
3
+ metadata.gz: 1a5115e104c01e18061ebd6473839714fe356958
4
+ data.tar.gz: 364f450af294a58c233e772a742a60c4ba148ee2
5
5
  SHA512:
6
- metadata.gz: 644ae0a3e0e4a8ca5e649d5b22a7f3c9ee4a6b7cf8d4c99b974f0344609914ec4dc40850c5d9cb8f7fbc34905953d3a098c96fc5af5b2d37ceab30a81bb76d0a
7
- data.tar.gz: dbb0e9fce535cf6f6321d085e6e8d5778ef4af09ddee701d0fbc8e39b8921567720b64d87c488003d0c6751f4c6e88a6268d23bf9cf499cd624e124acf7a37c3
6
+ metadata.gz: edb305dc899a0d3e2b2a572fea5a72add6d33f1caab6f101048f4579afdeb6e71f6681405ad8d0b3adb821edcb49efff13560359c1b73fac087381e0696abd41
7
+ data.tar.gz: 5773a64a5c22d7ebb168b184e59ba8589faf275c9ed0a3e49e35ca4211c93012f0947acd8884d222dba1588e0ddf3f860dee5020017f63edcbe5901d98f9a22b
@@ -28,11 +28,7 @@
28
28
  <%= render 'submenu_checkout', profile: @profile %>
29
29
  <% end %>
30
30
  <ul>
31
- <%- if flash[:query] -%>
32
- <li><%= link_to t('page.back'), profiles_path(query: flash[:query]) -%></li>
33
- <% else %>
34
- <li><%= back_to_index %></li>
35
- <% end %>
31
+ <li><%= link_to t('page.back'), :back %></li>
36
32
  <% if user_signed_in? %>
37
33
  <% if policy(@profile).update? %>
38
34
  <li><%= link_to t('page.edit'), edit_profile_path(@profile) -%></li>
@@ -10,7 +10,6 @@ require 'cocoon'
10
10
  require 'kramdown'
11
11
  require 'rails_autolink'
12
12
  require 'sitemap_generator'
13
- require 'statesman'
14
13
  require 'browser'
15
14
 
16
15
  module EnjuSeed
@@ -1,3 +1,3 @@
1
1
  module EnjuSeed
2
- VERSION = "0.2.0.beta.1"
2
+ VERSION = "0.2.0.beta.2"
3
3
  end
@@ -1,4 +1,3 @@
1
- # -*- encoding: utf-8 -*-
2
1
  require 'rails_helper'
3
2
 
4
3
  describe MyAccountsController do
@@ -7,7 +6,7 @@ describe MyAccountsController do
7
6
  describe "GET show" do
8
7
  describe "When logged in as Administrator" do
9
8
  before(:each) do
10
- sign_in User.where(username: 'enjuadmin').first
9
+ sign_in User.friendly.find('enjuadmin')
11
10
  end
12
11
 
13
12
  it "assigns the requested user as @user" do
@@ -9,3 +9,4 @@ Rails.application.config.assets.version = '1.0'
9
9
  # Precompile additional assets.
10
10
  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
11
11
  # Rails.application.config.assets.precompile += %w( search.js )
12
+ Rails.application.config.assets.precompile += %w( *.png icons/*.png *.gif )
@@ -0,0 +1,90 @@
1
+ # FriendlyId Global Configuration
2
+ #
3
+ # Use this to set up shared configuration options for your entire application.
4
+ # Any of the configuration options shown here can also be applied to single
5
+ # models by passing arguments to the `friendly_id` class method or defining
6
+ # methods in your model.
7
+ #
8
+ # To learn more, check out the guide:
9
+ #
10
+ # http://norman.github.io/friendly_id/file.Guide.html
11
+
12
+ if Rails::VERSION::MAJOR == 4
13
+ FriendlyId.defaults do |config|
14
+ # ## Reserved Words
15
+ #
16
+ # Some words could conflict with Rails's routes when used as slugs, or are
17
+ # undesirable to allow as slugs. Edit this list as needed for your app.
18
+ config.use :reserved
19
+
20
+ config.reserved_words = %w(new edit index session login logout users admin
21
+ stylesheets assets javascripts images)
22
+
23
+ # ## Friendly Finders
24
+ #
25
+ # Uncomment this to use friendly finders in all models. By default, if
26
+ # you wish to find a record by its friendly id, you must do:
27
+ #
28
+ # MyModel.friendly.find('foo')
29
+ #
30
+ # If you uncomment this, you can do:
31
+ #
32
+ # MyModel.find('foo')
33
+ #
34
+ # This is significantly more convenient but may not be appropriate for
35
+ # all applications, so you must explicity opt-in to this behavior. You can
36
+ # always also configure it on a per-model basis if you prefer.
37
+ #
38
+ # Something else to consider is that using the :finders addon boosts
39
+ # performance because it will avoid Rails-internal code that makes runtime
40
+ # calls to `Module.extend`.
41
+ #
42
+ config.use :finders
43
+ #
44
+ # ## Slugs
45
+ #
46
+ # Most applications will use the :slugged module everywhere. If you wish
47
+ # to do so, uncomment the following line.
48
+ #
49
+ # config.use :slugged
50
+ #
51
+ # By default, FriendlyId's :slugged addon expects the slug column to be named
52
+ # 'slug', but you can change it if you wish.
53
+ #
54
+ # config.slug_column = 'slug'
55
+ #
56
+ # When FriendlyId can not generate a unique ID from your base method, it appends
57
+ # a UUID, separated by a single dash. You can configure the character used as the
58
+ # separator. If you're upgrading from FriendlyId 4, you may wish to replace this
59
+ # with two dashes.
60
+ #
61
+ # config.sequence_separator = '-'
62
+ #
63
+ # ## Tips and Tricks
64
+ #
65
+ # ### Controlling when slugs are generated
66
+ #
67
+ # As of FriendlyId 5.0, new slugs are generated only when the slug field is
68
+ # nil, but if you're using a column as your base method can change this
69
+ # behavior by overriding the `should_generate_new_friendly_id` method that
70
+ # FriendlyId adds to your model. The change below makes FriendlyId 5.0 behave
71
+ # more like 4.0.
72
+ #
73
+ # config.use Module.new {
74
+ # def should_generate_new_friendly_id?
75
+ # slug.blank? || <your_column_name_here>_changed?
76
+ # end
77
+ # }
78
+ #
79
+ # FriendlyId uses Rails's `parameterize` method to generate slugs, but for
80
+ # languages that don't use the Roman alphabet, that's not usually suffient. Here
81
+ # we use the Babosa library to transliterate Russian Cyrillic slugs to ASCII. If
82
+ # you use this, don't forget to add "babosa" to your Gemfile.
83
+ #
84
+ # config.use Module.new {
85
+ # def normalize_friendly_id(text)
86
+ # text.to_slug.normalize! :transliterations => [:russian, :latin]
87
+ # end
88
+ # }
89
+ end
90
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe UserHasRole do
5
+ #pending "add some examples to (or delete) #{__FILE__}"
6
+
7
+ end
8
+
9
+ # == Schema Information
10
+ #
11
+ # Table name: user_has_roles
12
+ #
13
+ # id :integer not null, primary key
14
+ # user_id :integer
15
+ # role_id :integer
16
+ # created_at :datetime
17
+ # updated_at :datetime
18
+ #
@@ -8,7 +8,9 @@ abort("The Rails environment is running in production mode!") if Rails.env.produ
8
8
  require 'spec_helper'
9
9
  require 'rspec/rails'
10
10
  require 'factory_girl'
11
+ require 'rspec/active_model/mocks'
11
12
  require 'sunspot_matchers'
13
+ require 'pundit/rspec'
12
14
  # Add additional requires below this line. Rails is not loaded until this point!
13
15
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
14
16
 
@@ -0,0 +1,35 @@
1
+ require "spec_helper"
2
+
3
+ describe RolesController do
4
+ describe "routing" do
5
+
6
+ it "recognizes and generates #index" do
7
+ { :get => "/roles" }.should route_to(:controller => "roles", :action => "index")
8
+ end
9
+
10
+ #it "recognizes and generates #new" do
11
+ # { :get => "/roles/new" }.should route_to(:controller => "roles", :action => "new")
12
+ #end
13
+
14
+ it "recognizes and generates #show" do
15
+ { :get => "/roles/1" }.should route_to(:controller => "roles", :action => "show", :id => "1")
16
+ end
17
+
18
+ it "recognizes and generates #edit" do
19
+ { :get => "/roles/1/edit" }.should route_to(:controller => "roles", :action => "edit", :id => "1")
20
+ end
21
+
22
+ #it "recognizes and generates #create" do
23
+ # { :post => "/roles" }.should route_to(:controller => "roles", :action => "create")
24
+ #end
25
+
26
+ it "recognizes and generates #update" do
27
+ { :put => "/roles/1" }.should route_to(:controller => "roles", :action => "update", :id => "1")
28
+ end
29
+
30
+ #it "recognizes and generates #destroy" do
31
+ # { :delete => "/roles/1" }.should route_to(:controller => "roles", :action => "destroy", :id => "1")
32
+ #end
33
+
34
+ end
35
+ end
@@ -37,7 +37,7 @@ RSpec.configure do |config|
37
37
  # Prevents you from mocking or stubbing a method that does not exist on
38
38
  # a real object. This is generally recommended, and will default to
39
39
  # `true` in RSpec 4.
40
- mocks.verify_partial_doubles = true
40
+ mocks.verify_partial_doubles = false
41
41
  end
42
42
 
43
43
  # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe "my_accounts/show" do
4
+ fixtures :all
5
+
6
+ before(:each) do
7
+ @profile = assign(:profile, profiles(:admin))
8
+ end
9
+
10
+ describe "when logged in as Librarian" do
11
+ before(:each) do
12
+ @profile = assign(:profile, profiles(:librarian2))
13
+ user = users(:librarian1)
14
+ view.stub(:current_user).and_return(user)
15
+ end
16
+
17
+ it "renders attributes in <p>" do
18
+ allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
19
+ render
20
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
21
+ rendered.should match(/Checkout/)
22
+ end
23
+
24
+ it "cannot be deletable by other librarian" do
25
+ allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
26
+ render
27
+ end
28
+ end
29
+
30
+ describe "when logged in as User" do
31
+ before(:each) do
32
+ @profile = assign(:profile, profiles(:user2))
33
+ user = users(:librarian1)
34
+ view.stub(:current_user).and_return(user)
35
+ end
36
+
37
+ it "renders attributes in <p>" do
38
+ allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
39
+ render
40
+ rendered.should match(/Checkout/)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe "profiles/edit" do
4
+ fixtures :all
5
+
6
+ before(:each) do
7
+ @profile = assign(:profile, profiles(:admin))
8
+ assign(:user_groups, UserGroup.all)
9
+ assign(:libraries, Library.all)
10
+ assign(:roles, Role.all)
11
+ assign(:available_languages, Language.available_languages)
12
+ view.stub(:current_user).and_return(User.friendly.find('enjuadmin'))
13
+ end
14
+
15
+ describe "when logged in as librarian" do
16
+ before(:each) do
17
+ @profile = assign(:profile, profiles(:librarian2))
18
+ user = users(:librarian1)
19
+ view.stub(:current_user).and_return(user)
20
+ end
21
+
22
+ it "renders the edit user form" do
23
+ allow(view).to receive(:policy).and_return double(destroy?: true)
24
+ render
25
+ assert_select "form", action: profiles_path(@profile), method: "post" do
26
+ assert_select "input#profile_user_number", name: "profile[user_number]"
27
+ end
28
+ end
29
+
30
+ it "should not display 'delete' link" do
31
+ allow(view).to receive(:policy).and_return double(destroy?: false)
32
+ render
33
+ expect(rendered).not_to have_selector("a[href='#{profile_path(@profile.id)}'][data-method='delete']")
34
+ end
35
+
36
+ it "should disable role selection" do
37
+ allow(view).to receive(:policy).and_return double(destroy?: true)
38
+ render
39
+ expect(rendered).to have_selector("select#profile_user_attributes_user_has_role_attributes_role_id[disabled='disabled']")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe "profiles/index" do
4
+ fixtures :all
5
+
6
+ before(:each) do
7
+ assign(:profiles, Profile.page(1))
8
+ admin = User.friendly.find('enjuadmin')
9
+ view.stub(:current_user).and_return(admin)
10
+ view.stub(:params).and_return(ActionController::Parameters.new)
11
+ end
12
+
13
+ it "renders a list of profiles" do
14
+ allow(view).to receive(:policy).and_return double(create?: true, update?: true, destroy?: true)
15
+ render
16
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
17
+ assert_select "tr>td", :text => 'enjuadmin'
18
+ end
19
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "profiles/new" do
4
+ fixtures :user_groups
5
+
6
+ before(:each) do
7
+ assign(:profile, stub_model(Profile,
8
+ :user_group_id => 1
9
+ ).as_new_record)
10
+ assign(:user_groups, UserGroup.all)
11
+ assign(:libraries, Library.all)
12
+ assign(:roles, Role.all)
13
+ assign(:available_languages, Language.available_languages)
14
+ view.stub(:current_user).and_return(User.find('enjuadmin'))
15
+ end
16
+
17
+ it "renders new user form" do
18
+ render
19
+
20
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
21
+ assert_select "form", action: profiles_path, method: "post" do
22
+ assert_select "input#profile_user_number", name: "profile[user_number]"
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe "profiles/show" do
4
+ fixtures :all
5
+
6
+ before(:each) do
7
+ @profile = assign(:profile, profiles(:admin))
8
+ view.stub(:current_user).and_return(User.friendly.find('enjuadmin'))
9
+ end
10
+
11
+ it "renders attributes in <p>" do
12
+ allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
13
+ render
14
+ # Run the generator again with the --webrat flag if you want to use webrat matchers
15
+ rendered.should match(/Checkout/)
16
+ end
17
+
18
+ describe "when logged in as Librarian" do
19
+ before(:each) do
20
+ @profile = assign(:profile, profiles(:librarian2))
21
+ user = users(:librarian1)
22
+ view.stub(:current_user).and_return(user)
23
+ end
24
+
25
+ it "cannot be deletable by other librarian" do
26
+ allow(view).to receive(:policy).and_return double(update?: true, destroy?: true)
27
+ render
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enju_seed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.beta.1
4
+ version: 0.2.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kosuke Tanabe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -182,30 +182,16 @@ dependencies:
182
182
  name: paperclip
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: '4.3'
188
- type: :runtime
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: '4.3'
195
- - !ruby/object:Gem::Dependency
196
- name: statesman
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
185
+ - - ">="
200
186
  - !ruby/object:Gem::Version
201
- version: '1.3'
187
+ version: '0'
202
188
  type: :runtime
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
- - - "~>"
192
+ - - ">="
207
193
  - !ruby/object:Gem::Version
208
- version: '1.3'
194
+ version: '0'
209
195
  - !ruby/object:Gem::Dependency
210
196
  name: kramdown
211
197
  requirement: !ruby/object:Gem::Requirement
@@ -360,6 +346,34 @@ dependencies:
360
346
  - - ">="
361
347
  - !ruby/object:Gem::Version
362
348
  version: '0'
349
+ - !ruby/object:Gem::Dependency
350
+ name: capybara
351
+ requirement: !ruby/object:Gem::Requirement
352
+ requirements:
353
+ - - ">="
354
+ - !ruby/object:Gem::Version
355
+ version: '0'
356
+ type: :development
357
+ prerelease: false
358
+ version_requirements: !ruby/object:Gem::Requirement
359
+ requirements:
360
+ - - ">="
361
+ - !ruby/object:Gem::Version
362
+ version: '0'
363
+ - !ruby/object:Gem::Dependency
364
+ name: rspec-activemodel-mocks
365
+ requirement: !ruby/object:Gem::Requirement
366
+ requirements:
367
+ - - ">="
368
+ - !ruby/object:Gem::Version
369
+ version: '0'
370
+ type: :development
371
+ prerelease: false
372
+ version_requirements: !ruby/object:Gem::Requirement
373
+ requirements:
374
+ - - ">="
375
+ - !ruby/object:Gem::Version
376
+ version: '0'
363
377
  - !ruby/object:Gem::Dependency
364
378
  name: sunspot_matchers
365
379
  requirement: !ruby/object:Gem::Requirement
@@ -473,6 +487,7 @@ files:
473
487
  - spec/dummy/config/initializers/devise.rb
474
488
  - spec/dummy/config/initializers/enju_leaf.rb
475
489
  - spec/dummy/config/initializers/filter_parameter_logging.rb
490
+ - spec/dummy/config/initializers/friendly_id.rb
476
491
  - spec/dummy/config/initializers/inflections.rb
477
492
  - spec/dummy/config/initializers/mime_types.rb
478
493
  - spec/dummy/config/initializers/secret_token.rb
@@ -685,13 +700,20 @@ files:
685
700
  - spec/fixtures/users.yml
686
701
  - spec/models/profile_spec.rb
687
702
  - spec/models/role_spec.rb
703
+ - spec/models/user_has_role_spec.rb
688
704
  - spec/rails_helper.rb
689
705
  - spec/requests/profiles_spec.rb
690
706
  - spec/routing/profiles_routing_spec.rb
707
+ - spec/routing/roles_routing_spec.rb
691
708
  - spec/routing/users_spec.rb
692
709
  - spec/spec_helper.rb
693
710
  - spec/support/controller_macros.rb
694
711
  - spec/support/devise.rb
712
+ - spec/views/my_accounts/show.html.erb_spec.rb
713
+ - spec/views/profiles/edit.html.erb_spec.rb
714
+ - spec/views/profiles/index.html.erb_spec.rb
715
+ - spec/views/profiles/new.html.erb_spec.rb
716
+ - spec/views/profiles/show.html.erb_spec.rb
695
717
  homepage: https://github.com/next-l/enju_seed
696
718
  licenses: []
697
719
  metadata: {}
@@ -742,6 +764,7 @@ test_files:
742
764
  - spec/dummy/config/initializers/devise.rb
743
765
  - spec/dummy/config/initializers/enju_leaf.rb
744
766
  - spec/dummy/config/initializers/filter_parameter_logging.rb
767
+ - spec/dummy/config/initializers/friendly_id.rb
745
768
  - spec/dummy/config/initializers/inflections.rb
746
769
  - spec/dummy/config/initializers/mime_types.rb
747
770
  - spec/dummy/config/initializers/secret_token.rb
@@ -957,10 +980,17 @@ test_files:
957
980
  - spec/fixtures/users.yml
958
981
  - spec/models/profile_spec.rb
959
982
  - spec/models/role_spec.rb
983
+ - spec/models/user_has_role_spec.rb
960
984
  - spec/rails_helper.rb
961
985
  - spec/requests/profiles_spec.rb
962
986
  - spec/routing/profiles_routing_spec.rb
987
+ - spec/routing/roles_routing_spec.rb
963
988
  - spec/routing/users_spec.rb
964
989
  - spec/spec_helper.rb
965
990
  - spec/support/controller_macros.rb
966
991
  - spec/support/devise.rb
992
+ - spec/views/my_accounts/show.html.erb_spec.rb
993
+ - spec/views/profiles/edit.html.erb_spec.rb
994
+ - spec/views/profiles/index.html.erb_spec.rb
995
+ - spec/views/profiles/new.html.erb_spec.rb
996
+ - spec/views/profiles/show.html.erb_spec.rb