myrails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +74 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/myrails +3 -0
- data/bin/setup +8 -0
- data/lib/myrails/templates/assets/animate.scss +3340 -0
- data/lib/myrails/templates/assets/application.css.sass +6 -0
- data/lib/myrails/templates/assets/application.js +10 -0
- data/lib/myrails/templates/assets/bootstrap_themes/cerulean.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/cosmo.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/cyborg.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/darkly.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/flatly.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/journal.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/lumen.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/paper.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/readable.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/sandstone.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/simplex.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/slate.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/spacelab.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/superhero.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/united.scss +11 -0
- data/lib/myrails/templates/assets/bootstrap_themes/yeti.scss +11 -0
- data/lib/myrails/templates/assets/will_paginate.scss +104 -0
- data/lib/myrails/templates/db/mysql_database.yml +55 -0
- data/lib/myrails/templates/db/sqlite3_database.yml +28 -0
- data/lib/myrails/templates/heroku/Procfile +1 -0
- data/lib/myrails/templates/heroku/puma.rb +15 -0
- data/lib/myrails/templates/layout/_error_messages.html.haml +6 -0
- data/lib/myrails/templates/layout/_info_messages.html.haml +9 -0
- data/lib/myrails/templates/layout/_nav.html.haml +24 -0
- data/lib/myrails/templates/layout/_success_message.html.haml +3 -0
- data/lib/myrails/templates/layout/application.html.haml +14 -0
- data/lib/myrails/templates/layout/footers/css/footer-distributed-with-address-and-phones.scss +168 -0
- data/lib/myrails/templates/layout/footers/css/footer-distributed-with-contact-form.scss +200 -0
- data/lib/myrails/templates/layout/footers/css/footer-distributed-with-search.scss +140 -0
- data/lib/myrails/templates/layout/footers/css/footer-distributed.scss +74 -0
- data/lib/myrails/templates/layout/footers/footer-distributed-with-address-and-phones.html.haml +45 -0
- data/lib/myrails/templates/layout/footers/footer-distributed-with-contact-form.html.haml +33 -0
- data/lib/myrails/templates/layout/footers/footer-distributed-with-search.html.haml +19 -0
- data/lib/myrails/templates/layout/footers/footer-distributed.html.haml +24 -0
- data/lib/myrails/templates/mailer/dev_mail_interceptor.rb +27 -0
- data/lib/myrails/templates/mailer/sendgrid.rb +8 -0
- data/lib/myrails/templates/presenters/base.rb +33 -0
- data/lib/myrails/templates/presenters/presenter.rb +19 -0
- data/lib/myrails/templates/presenters/presenter_config.rb +4 -0
- data/lib/myrails/templates/presenters/presenter_spec.rb +17 -0
- data/lib/myrails/templates/rails/application_helper.rb +49 -0
- data/lib/myrails/templates/rails/controller.rb +12 -0
- data/lib/myrails/templates/rails/model.rb +2 -0
- data/lib/myrails/templates/rails/pundit.rb +26 -0
- data/lib/myrails/templates/rspec/controller.rb +98 -0
- data/lib/myrails/templates/rspec/database_cleaner.rb +18 -0
- data/lib/myrails/templates/rspec/devise.rb +38 -0
- data/lib/myrails/templates/rspec/factory.rb +5 -0
- data/lib/myrails/templates/rspec/factory_girl.rb +3 -0
- data/lib/myrails/templates/rspec/files.rb +3 -0
- data/lib/myrails/templates/rspec/javascript.rb +8 -0
- data/lib/myrails/templates/rspec/mailer.rb +7 -0
- data/lib/myrails/templates/rspec/model.rb +5 -0
- data/lib/myrails/templates/rspec/pundit.rb +28 -0
- data/lib/myrails/templates/rspec/pundit_matchers.rb +47 -0
- data/lib/myrails/templates/rspec/router.rb +7 -0
- data/lib/myrails/templates/rspec/shoulda_matchers.rb +16 -0
- data/lib/myrails/templates/rspec/silence_backtrace.rb +8 -0
- data/lib/myrails/templates/ui/index.html.haml +6 -0
- data/lib/myrails/templates/ui/ui_controller.rb +8 -0
- data/lib/myrails/version.rb +3 -0
- data/lib/myrails.rb +399 -0
- data/myrails.gemspec +37 -0
- data/spec/controllers/sam_controller_spec.rb +98 -0
- data/spec/myrails_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +197 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
# @author Lovell McIlwain
|
2
|
+
#
|
3
|
+
# Mail interceptor for development and test emails
|
4
|
+
require 'socket'
|
5
|
+
class DevMailInterceptor
|
6
|
+
def self.delivering_email(message)
|
7
|
+
dev_text = "\n\n\n------------\n"
|
8
|
+
dev_text += "To address is: #{message.to.to_a.join(", ")}\n"
|
9
|
+
dev_text += "CC address is: #{message.cc.to_a.join(", ")}\n"
|
10
|
+
dev_text += "BCC address is: #{message.bcc.to_a.join(", ")}\n"
|
11
|
+
|
12
|
+
message.subject = "[#{Socket.gethostname}] [#{Rails.env}] #{message.subject}"
|
13
|
+
message.to = '<%= options[:email]%>'
|
14
|
+
message.cc = ""
|
15
|
+
message.bcc = ""
|
16
|
+
append_address_info(message, dev_text)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.append_address_info(part, dev_text)
|
20
|
+
case part.content_type
|
21
|
+
when %r{^text/plain} then part.body = part.body.to_s + dev_text
|
22
|
+
when %r{^text/html} then part.body = part.body.to_s + ("<pre>#{dev_text}</pre>").html_safe
|
23
|
+
end
|
24
|
+
part.parts.each { |p| append_address_info(p, dev_text)}
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# config.action_mailer.delivery_method = :smtp
|
2
|
+
# config.action_mailer.smtp_settings = { address: 'smtp.sendgrid.net',
|
3
|
+
# port: 587,
|
4
|
+
# domain: 'yourdomain.com',
|
5
|
+
# user_name: 'someuser',
|
6
|
+
# password: 'somepassword',
|
7
|
+
# authentication: 'plain',
|
8
|
+
# enable_starttls_auto: true }
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# @author Lovell McIlwain
|
2
|
+
#
|
3
|
+
# Class every presenter class should inherit from
|
4
|
+
class BasePresenter
|
5
|
+
# Initialize class with object to be presented and the view it is to be presented on
|
6
|
+
def initialize(object, template)
|
7
|
+
@object = object
|
8
|
+
@template = template
|
9
|
+
end
|
10
|
+
|
11
|
+
# Same as application helper short date
|
12
|
+
def format_date(date)
|
13
|
+
date.strftime("%Y-%m-%d")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
# Class method to call the object by its class
|
18
|
+
def self.presents(name)
|
19
|
+
define_method(name) do
|
20
|
+
@object
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Accessor for template methods
|
25
|
+
def t
|
26
|
+
@template
|
27
|
+
end
|
28
|
+
|
29
|
+
# In the event a method called can't be found, default to the template methods
|
30
|
+
def method_missing(*args, &block)
|
31
|
+
@template.send(*args, &block)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# @author Lovell McIlwain
|
2
|
+
#
|
3
|
+
# Presenter class for object views
|
4
|
+
class <%= options[:name].camelize %>Presenter < BasePresenter
|
5
|
+
# Reference initialized object_presenter as object
|
6
|
+
presents :<%= options[:name]%>
|
7
|
+
|
8
|
+
# delegate :attribute, to: :object, allow_nil: true
|
9
|
+
|
10
|
+
# Return concatenated full name
|
11
|
+
def name
|
12
|
+
<%= options[:name]%>.attribute + " " + <%= options[:name]%>.attribute
|
13
|
+
end
|
14
|
+
|
15
|
+
# Return edit path
|
16
|
+
def edit_link
|
17
|
+
link_to :Edit, edit_<%= options[:name]%>_path(<%= options[:name]%>)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
require 'rails_helper'
|
3
|
+
#
|
4
|
+
describe <%= options[:name].camelize %>Presenter do
|
5
|
+
include_behavior
|
6
|
+
|
7
|
+
let(:presenter) {<%= options[:name].camelize %>Presenter.new(<%= options[:name] %>, view)}
|
8
|
+
let(:<%= options[:name] %>) {create :<%= options[:name] %>}
|
9
|
+
|
10
|
+
it 'returns name' do
|
11
|
+
expect(presenter.name).to eq object.attribute + " " + object.attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'returns edit path' do
|
15
|
+
expect(presenter.edit_link).to eq link_to :Edit, edit_<%= options[:name] %>_path(<%= options[:name] %>)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
# Long date format
|
3
|
+
#
|
4
|
+
# @param date [Date] the date object
|
5
|
+
# @return day date month year - hour:minutes AM/PM
|
6
|
+
def long_date(date)
|
7
|
+
date.strftime("%A %d %B %Y - %H:%M %p") rescue 'unknown'
|
8
|
+
end
|
9
|
+
|
10
|
+
# Medium date format
|
11
|
+
#
|
12
|
+
# @param date [Date] the date object
|
13
|
+
# @return month/date/year at hour:minutes AM/PM
|
14
|
+
def medium_date(date)
|
15
|
+
date.strftime("%m/%d/%Y at %H:%M %p") rescue 'unknown'
|
16
|
+
end
|
17
|
+
|
18
|
+
# Another style of medium date format
|
19
|
+
#
|
20
|
+
# @param date [Date] the date object
|
21
|
+
# @return day/MONTH/YEAR
|
22
|
+
# Produces -> 18 October 2015
|
23
|
+
def medium_date2(date)
|
24
|
+
date.strftime("%d %B %Y") rescue 'unknown'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Short date format
|
28
|
+
#
|
29
|
+
# @param date [Date] the date object
|
30
|
+
# @return year-month-date
|
31
|
+
def short_date(date)
|
32
|
+
date.strftime("%Y-%m-%d") rescue 'unknown'
|
33
|
+
end
|
34
|
+
|
35
|
+
# US date format
|
36
|
+
#
|
37
|
+
# @param date [Date] the date object
|
38
|
+
# @return year-month-date
|
39
|
+
def us_date(date)
|
40
|
+
date.strftime("%m/%d/%Y at %H:%M %p") rescue 'unknown'
|
41
|
+
end
|
42
|
+
|
43
|
+
def present(object, klass = nil)
|
44
|
+
klass ||= "#{object.class}Presenter".constantize
|
45
|
+
presenter = klass.new(object, self)
|
46
|
+
yield presenter if block_given?
|
47
|
+
presenter
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= options[:name].pluralize.camelize %>Controller < ApplicationController
|
2
|
+
# before_action :<%= options[:name].singularize %>, only: []
|
3
|
+
private
|
4
|
+
|
5
|
+
def <%= options[:name].singularize %>
|
6
|
+
@<%= options[:name] %> = Object.find(params[:id])
|
7
|
+
end
|
8
|
+
|
9
|
+
def <%= options[:name].singularize %>_params
|
10
|
+
params.require(:<%= options[:name] %>).permit()
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# @author Lovell McIlwain
|
2
|
+
#
|
3
|
+
# Authorization for article objects
|
4
|
+
class <%= options[:name].camelize %>Policy < ApplicationPolicy
|
5
|
+
# Allow all users to access new article objects
|
6
|
+
def new?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
# Allows owner of an article to edit the article
|
11
|
+
def edit?
|
12
|
+
user == record.user
|
13
|
+
end
|
14
|
+
|
15
|
+
# Allows all users to create article objects
|
16
|
+
alias_method :create?, :new?
|
17
|
+
|
18
|
+
# Allows all users to view article objects
|
19
|
+
alias_method :show?, :new?
|
20
|
+
|
21
|
+
# Allows owner of an article to update an article object
|
22
|
+
alias_method :update?, :edit?
|
23
|
+
|
24
|
+
# Allows owner of an object to remove an object
|
25
|
+
alias_method :destroy?, :edit?
|
26
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
# Does this controller require authentication?
|
4
|
+
describe <%= options[:name].camelize %>Controller do
|
5
|
+
# let(:user) {create :user}
|
6
|
+
let(:<%= options[:name].pluralize %>) {[]}
|
7
|
+
let(:<%= options[:name].singularize %>) {create :<%= options[:name].singularize %>}
|
8
|
+
|
9
|
+
# before {sign_in user}
|
10
|
+
|
11
|
+
describe 'GET index' do
|
12
|
+
before do
|
13
|
+
3.times {<%= options[:name].pluralize %> << create(:<%= options[:name].singularize %>)}
|
14
|
+
get :index
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'sets @<%= options[:name].pluralize %>' do
|
18
|
+
expect(assigns[:<%= options[:name].pluralize %>]).to eq <%= options[:name].pluralize %>
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'GET show' do
|
23
|
+
before {get :show, params: {id: <%= options[:name].singularize %>.id}}
|
24
|
+
|
25
|
+
it 'sets @<%= options[:name].singularize %>' do
|
26
|
+
expect(assigns[:<%= options[:name].singularize %>]).to eq <%= options[:name].singularize %>
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'GET new' do
|
31
|
+
before {get :new}
|
32
|
+
|
33
|
+
it 'sets @<%= options[:name].singularize %>' do
|
34
|
+
expect(assigns[:<%= options[:name].singularize %>]).to be_a_new <%= options[:name].singularize.camelize %>
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'POST create' do
|
39
|
+
context 'successful create' do
|
40
|
+
before {post :create, params: {<%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>)}}
|
41
|
+
|
42
|
+
subject(:<%= options[:name].first %>){assigns[:<%= options[:name].singularize %>]}
|
43
|
+
|
44
|
+
it 'redirects to :show'
|
45
|
+
it 'sets @<%= options[:name].singularize %>'
|
46
|
+
it 'sets flash[:success]'
|
47
|
+
it 'tags the current_user as creator'
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'unsuccessful create' do
|
51
|
+
before {post :create, params: {<%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>, attr: nil)}}
|
52
|
+
|
53
|
+
it 'renders :new template'
|
54
|
+
it 'sets @<%= options[:name].singularize %>'
|
55
|
+
it 'sets flash[:error]'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'GET edit' do
|
60
|
+
before {get :edit, params: {id: <%= options[:name].singularize %>.id}}
|
61
|
+
|
62
|
+
it 'sets @<%= options[:name].singularize %>' do
|
63
|
+
expect(assigns[:<%= options[:name].singularize %>]).to eq <%= options[:name].singularize %>
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'PUT/PATCH update' do
|
68
|
+
context 'successful update' do
|
69
|
+
before {put :update, params: {id: <%= options[:name].singularize %>.id, <%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>)}}
|
70
|
+
|
71
|
+
subject(:<%= options[:name].first %>) {assigns[:<%= options[:name].singularize %>]}
|
72
|
+
|
73
|
+
it 'redirects to :show'
|
74
|
+
it 'sets @<%= options[:name].singularize %>'
|
75
|
+
it 'sets flash[:success]'
|
76
|
+
it 'tags current_user as updater'
|
77
|
+
end
|
78
|
+
|
79
|
+
context 'unsuccessful update' do
|
80
|
+
before {put :update, params: {id: <%= options[:name].singularize %>.id, <%= options[:name].singularize %>: attributes_for(:<%= options[:name].singularize %>, attr: nil)}}
|
81
|
+
|
82
|
+
it 'renders :edit template'
|
83
|
+
it 'sets @<%= options[:name].singularize %>'
|
84
|
+
it 'sets flash[:error]'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe 'DELETE destroy' do
|
89
|
+
before {delete :destroy, params: {id: <%= options[:name].singularize %>.id}}
|
90
|
+
|
91
|
+
it 'redirects to :index' do
|
92
|
+
expect(response).to redirect_to <%= options[:name].pluralize %>_path
|
93
|
+
end
|
94
|
+
it 'sets @<%= options[:name].singularize %>'
|
95
|
+
it 'deletes @<%= options[:name].singularize %>'
|
96
|
+
it 'sets flash[success]'
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
# => database cleaner configs
|
3
|
+
config.before(:suite) do
|
4
|
+
DatabaseCleaner.clean_with(:truncation)
|
5
|
+
end
|
6
|
+
config.before(:each) do
|
7
|
+
DatabaseCleaner.strategy = :transaction
|
8
|
+
end
|
9
|
+
config.before(:each, :js => true) do
|
10
|
+
DatabaseCleaner.strategy = :truncation
|
11
|
+
end
|
12
|
+
config.before(:each) do
|
13
|
+
DatabaseCleaner.start
|
14
|
+
end
|
15
|
+
config.after(:each) do
|
16
|
+
DatabaseCleaner.clean
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.include Devise::Test::ControllerHelpers, type: :controller
|
3
|
+
# config.include Devise::TestHelpers, type: :controller
|
4
|
+
config.include Devise::TestHelpers, type: :view
|
5
|
+
end
|
6
|
+
|
7
|
+
# Authenticate without going through the login process
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.include Warden::Test::Helpers
|
10
|
+
config.before :suite do
|
11
|
+
Warden.test_mode!
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
config.after :each do
|
17
|
+
Warden.test_reset!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
#
|
21
|
+
=begin
|
22
|
+
Reference: https://github.com/plataformatec/devise/wiki/How-To:-Test-with-Capybara
|
23
|
+
|
24
|
+
To use authentication bypass use the following for loging in:
|
25
|
+
|
26
|
+
user = FactoryGirl.create(:user)
|
27
|
+
login_as(user, :scope => :user)
|
28
|
+
|
29
|
+
if within a test you need to logout a user use:
|
30
|
+
logout(:user)
|
31
|
+
=end
|
32
|
+
|
33
|
+
def sign_in_with(user)
|
34
|
+
click_link 'Sign In'
|
35
|
+
fill_in 'user_email', with: user.email
|
36
|
+
fill_in 'user_password', with: 'somepassword'
|
37
|
+
click_button 'Log in'
|
38
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module JavascriptHelper
|
2
|
+
# Basecamp trix uses hidden input to populate its editor
|
3
|
+
def fill_in_trix_editor(id, value)
|
4
|
+
find(:xpath, "//*[@id='#{id}']", visible: false).set(value)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
# Example of use in feature test: fill_in_trix_editor("blog_comment_body_trix_input_blog_comment_#{blog_comment.id}", "some text")
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Use with Pundit Matches: https://github.com/chrisalley/pundit-matchers
|
2
|
+
require 'rails_helper'
|
3
|
+
describe <%= options[:name].camelize %>Policy do
|
4
|
+
subject { <%= options[:name].camelize %>Policy.new(user, <%= options[:name] %>) }
|
5
|
+
|
6
|
+
let(:<%= options[:name] %>) { create :<%= options[:name] %> }
|
7
|
+
|
8
|
+
context 'for a visitor' do
|
9
|
+
it {is_expected.to permit_action(:new)}
|
10
|
+
it {is_expected.to permit_action(:create)}
|
11
|
+
it {is_expected.to permit_action(:show)}
|
12
|
+
it {is_expected.to forbid_action(:edit)}
|
13
|
+
it {is_expected.to forbid_action(:update)}
|
14
|
+
it {is_expected.to forbid_action(:destroy)}
|
15
|
+
end
|
16
|
+
|
17
|
+
context "for an admin" do
|
18
|
+
|
19
|
+
let(:user) { <%= options[:name] %>.user }
|
20
|
+
|
21
|
+
it {is_expected.to permit_action(:new)}
|
22
|
+
it {is_expected.to permit_action(:create)}
|
23
|
+
it {is_expected.to permit_action(:show)}
|
24
|
+
it {is_expected.to permit_action(:edit)}
|
25
|
+
it {is_expected.to permit_action(:update)}
|
26
|
+
it {is_expected.to permit_action(:destroy)}
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
RSpec::Matchers.define :permitted_to do |action|
|
2
|
+
match do |policy|
|
3
|
+
policy.public_send("#{action}?")
|
4
|
+
end
|
5
|
+
|
6
|
+
failure_message do |policy|
|
7
|
+
"#{policy.class} does not permit #{action} on #{policy.record} for #{policy.user.inspect}."
|
8
|
+
end
|
9
|
+
|
10
|
+
failure_message_when_negated do |policy|
|
11
|
+
"#{policy.class} does not forbid #{action} on #{policy.record} for #{policy.user.inspect}."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def pundit_error
|
16
|
+
Pundit::NotAuthorizedError
|
17
|
+
end
|
18
|
+
|
19
|
+
=begin
|
20
|
+
|
21
|
+
example: spec/policies/projects_policy_spec.rb
|
22
|
+
|
23
|
+
require 'rails_helper'
|
24
|
+
|
25
|
+
describe ProjectPolicy do
|
26
|
+
subject { ProjectPolicy.new(user, project) }
|
27
|
+
let(:project) { Fabricate :project }
|
28
|
+
|
29
|
+
|
30
|
+
context 'for a visitor' do
|
31
|
+
it { should_not permitted_to(:create) }
|
32
|
+
it { should_not permitted_to(:new) }
|
33
|
+
it { should_not permitted_to(:update) }
|
34
|
+
it { should_not permitted_to(:edit) }
|
35
|
+
end
|
36
|
+
|
37
|
+
context "for an admin" do
|
38
|
+
let(:user) { Fabricate(:user, admin: true) }
|
39
|
+
|
40
|
+
it { should permitted_to(:create) }
|
41
|
+
it { should permitted_to(:new) }
|
42
|
+
it { should permitted_to(:update) }
|
43
|
+
it { should permitted_to(:edit) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
=end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Controller test doesn't seem to use default url option when redirecting to an associated record. Uses http://test.com. This is an attmept to unify this and capybara which uses http://www.example.com.
|
2
|
+
# Add this method to the before action of any controller specs that needed it. Found it useful to use this when using shared examples.
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.before(:each) do
|
5
|
+
@request.host = 'localhost:3000'
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Shoulda::Matchers.configure do |config|
|
2
|
+
config.integrate do |with|
|
3
|
+
# Choose a test framework:
|
4
|
+
with.test_framework :rspec
|
5
|
+
# with.test_framework :minitest
|
6
|
+
# with.test_framework :minitest_4
|
7
|
+
# with.test_framework :test_unit
|
8
|
+
|
9
|
+
# Choose one or more libraries:
|
10
|
+
# with.library :active_record
|
11
|
+
# with.library :active_model
|
12
|
+
# with.library :action_controller
|
13
|
+
# Or, choose the following (which implies all of the above):
|
14
|
+
with.library :rails
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
%section.ui-index
|
2
|
+
%ul
|
3
|
+
- Dir.glob('app/views/ui/*.html.haml').sort.each do |file|
|
4
|
+
- wireframe = File.basename(file,'.html.haml')
|
5
|
+
- unless wireframe == 'index' || wireframe.match(/^_/)
|
6
|
+
%li= link_to wireframe.titleize, action: wireframe unless wireframe == 'index'
|