scidea-hsfc-policies 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +0 -0
- data/MIT-LICENSE +7 -0
- data/README.md +50 -0
- data/Rakefile +2 -0
- data/app/views/registrations/_hsfc_policies.html.erb +4 -0
- data/config/cucumber.yml +8 -0
- data/config/environment.rb +18 -0
- data/config/locales/en.yml +13 -0
- data/config/locales/fr.yml +22 -0
- data/features/support/env.rb +23 -0
- data/features/support/hooks.rb +16 -0
- data/features/support/paths.rb +36 -0
- data/features/support/seed_user_roles.rb +16 -0
- data/features/support/selectors.rb +66 -0
- data/lib/generators/scidea/hsfc/policies/migrations_generator.rb +15 -0
- data/lib/generators/scidea/hsfc/policies/removal_migrations_generator.rb +15 -0
- data/lib/generators/scidea/hsfc/policies/templates/removal/scidea_hsfc_policies_99_remove.rb +15 -0
- data/lib/generators/scidea/hsfc/policies/templates/scidea_hsfc_policies_01_install.rb +15 -0
- data/lib/scidea/hsfc/policies/engine.rb +22 -0
- data/lib/scidea/hsfc/policies/helpers/policies_helper.rb +30 -0
- data/lib/scidea/hsfc/policies/models/profile.rb +17 -0
- data/lib/scidea/hsfc/policies/version.rb +7 -0
- data/lib/scidea/hsfc/policies.rb +7 -0
- data/lib/scidea-hsfc-policies.rb +1 -0
- data/spec/factories/profiles.rb +4 -0
- data/spec/helpers/policies_helper_spec.rb +28 -0
- data/spec/models/profile_spec.rb +6 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/controller_macros.rb +15 -0
- data/spec/views/registrations/_hsfc_policies.html.erb_spec.rb +35 -0
- metadata +77 -0
data/CHANGELOG
ADDED
File without changes
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Scitent, Inc.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Scidea HSFC Policies
|
2
|
+
|
3
|
+
Adds policy-related information to user profiles in Scitent's Scidea LMS platform. This gem is only useful in the context of the proprietary Scidea platform.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
1. Add `scidea-hsfc-policies` to your Scidea Gemfile:
|
8
|
+
|
9
|
+
```
|
10
|
+
# Gemfile
|
11
|
+
gem 'scidea-hsfc-policies'
|
12
|
+
```
|
13
|
+
|
14
|
+
2. Add the installation migrations to your ``db/migrate/`` folder:
|
15
|
+
|
16
|
+
```
|
17
|
+
rails g scidea:hsfc:policies:migrations
|
18
|
+
```
|
19
|
+
|
20
|
+
## Development Environment and Testing
|
21
|
+
|
22
|
+
The gem is configured to use rspec and cucumber tests. Because there are so many dependencies upon the Scidea core, rspec and cucumber have been configured to launch an instance of the core application with the plugin's resources tied in. The features and specs of the plugin, however, are the only ones executed when you run cucumber and rspec, respectively.
|
23
|
+
|
24
|
+
To set up your environment for testing, perform the following:
|
25
|
+
|
26
|
+
1. In your local Scidea core instance, add the following line to the Gemfile:
|
27
|
+
|
28
|
+
```
|
29
|
+
# Gemfile
|
30
|
+
gem 'scidea-hsfc-policies', :path => 'LOCAL_PATH_TO_scidea-hsfc-policies'
|
31
|
+
```
|
32
|
+
|
33
|
+
2. Add the scidea gem to the scidea-hsfc-policies Gemfile and add the path to your Scidea core instance. Then, copy the contents of the Scidea core Gemfile *after* ``gemspec``, and paste it to the end of the Gemfile in the scidea-hsfc-policies code. When you run rspec/cucumber, they require this Gemfile, thus you need all of the gems that Scidea core requires as well.
|
34
|
+
|
35
|
+
```
|
36
|
+
source 'http://rubygems.org'
|
37
|
+
|
38
|
+
gemspec
|
39
|
+
|
40
|
+
gem 'scidea', :path => 'LOCAL_PATH_TO_SCIDEA-CORE'
|
41
|
+
|
42
|
+
# contents of scidea core Gemfile here....
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
From scidea-hsfc-policies, you can run ``rspec`` and ``cucumber``. Note that FactoryGirl factories from the Scidea core are included in the testing runtime and added to whatever you include in ``spec/factories``. The database configuration from the Scidea core will also be used. You must run all rake operations for that database in the context of the Scidea core folder. They will not work in the scidea-hsfc-policies folder.
|
47
|
+
|
48
|
+
----
|
49
|
+
|
50
|
+
Copyright 2012 Scitent, Inc. See the file MIT-LICENSE for terms.
|
data/Rakefile
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
<%= form.inputs :id => "policy-fields" do %>
|
2
|
+
<%= form.input :agrees_to_privacy_policy, :label => hsfc_policies_privacy_policy_label(params[:locale]), :as => :boolean %>
|
3
|
+
<%= form.input :agrees_to_terms, :label => hsfc_policies_terms_label(params[:locale]), :as => :boolean %>
|
4
|
+
<% end %>
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features -r features
|
7
|
+
wip: --tags @wip:3 --wip features
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Load local Gemfile and get the path to the local core application
|
2
|
+
# (from standard rails config/boot.rb)
|
3
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
4
|
+
begin
|
5
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.setup
|
8
|
+
rescue Bundler::GemNotFound => e
|
9
|
+
STDERR.puts e.message
|
10
|
+
STDERR.puts "Try running `bundle install`."
|
11
|
+
exit!
|
12
|
+
end if File.exist?(gemfile)
|
13
|
+
|
14
|
+
# get only the paths constants; let scidea core load all gems
|
15
|
+
require 'scidea/paths.rb'
|
16
|
+
|
17
|
+
# Load and initialize the Scidea core application
|
18
|
+
require File.expand_path('../config/environment', Scidea::APP_PATH)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Sample localization file for English. Add more files in this directory for other locales.
|
2
|
+
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
3
|
+
|
4
|
+
en:
|
5
|
+
|
6
|
+
registration:
|
7
|
+
privacy: 'I agree to the <a>Privacy Policy</a>'
|
8
|
+
terms_and_conditions: 'I agree to the <a>Terms and Conditions</a>'
|
9
|
+
|
10
|
+
formtastic:
|
11
|
+
labels:
|
12
|
+
terms_record:
|
13
|
+
terms_of_service: 'I agree to the Terms and Conditions'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# French translations
|
2
|
+
|
3
|
+
fr:
|
4
|
+
|
5
|
+
registration:
|
6
|
+
privacy: "J’accepte la <a>politique de confidentialité</a>"
|
7
|
+
terms_and_conditions: "J’accepte les <a>conditions générales</a>"
|
8
|
+
|
9
|
+
formtastic:
|
10
|
+
labels:
|
11
|
+
terms_record:
|
12
|
+
terms_of_service: "J’accepte les conditions générales"
|
13
|
+
|
14
|
+
activerecord:
|
15
|
+
errors:
|
16
|
+
models:
|
17
|
+
profile:
|
18
|
+
attributes:
|
19
|
+
agrees_to_terms:
|
20
|
+
accepted: "doit être accepté"
|
21
|
+
agrees_to_privacy_policy:
|
22
|
+
accepted: "doit être accepté"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= "test"
|
2
|
+
|
3
|
+
require File.expand_path("../../../config/environment", __FILE__)
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
|
6
|
+
|
7
|
+
require 'rspec/expectations'
|
8
|
+
require 'cucumber/rails'
|
9
|
+
require 'email_spec'
|
10
|
+
require 'email_spec/cucumber'
|
11
|
+
|
12
|
+
# Remove this line if your app doesn't have a database.
|
13
|
+
# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
|
14
|
+
DatabaseCleaner.strategy = :transaction
|
15
|
+
|
16
|
+
Cucumber::Rails::World.use_transactional_fixtures = false
|
17
|
+
|
18
|
+
Before do
|
19
|
+
page.driver.options[:resynchronize] = true
|
20
|
+
end
|
21
|
+
|
22
|
+
# load local factories which will be added to the factories from scidea.
|
23
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../spec/factories/*.rb')).each {|f| require f }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# see https://github.com/cucumber/cucumber/wiki/Hooks
|
2
|
+
|
3
|
+
AfterConfiguration do |config| # run once after cucumber configuration load
|
4
|
+
end
|
5
|
+
|
6
|
+
Before do |scenario|
|
7
|
+
SeedUserRoles.seed
|
8
|
+
end
|
9
|
+
|
10
|
+
After do |scenario| # each scenario
|
11
|
+
SeedUserRoles.clean
|
12
|
+
end
|
13
|
+
|
14
|
+
at_exit do # after all scenarios are finished (global tear-down)
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module NavigationHelpers
|
2
|
+
# Maps a name to a path. Used by the
|
3
|
+
#
|
4
|
+
# When /^I go to (.+)$/ do |page_name|
|
5
|
+
#
|
6
|
+
# step definition in web_steps.rb
|
7
|
+
#
|
8
|
+
def path_to(page_name)
|
9
|
+
case page_name
|
10
|
+
|
11
|
+
when /the home\s?page/
|
12
|
+
'/'
|
13
|
+
|
14
|
+
when /the registration page/
|
15
|
+
'/users/sign_up'
|
16
|
+
|
17
|
+
# Add more mappings here.
|
18
|
+
# Here is an example that pulls values out of the Regexp:
|
19
|
+
#
|
20
|
+
# when /^(.*)'s profile page$/i
|
21
|
+
# user_profile_path(User.find_by_login($1))
|
22
|
+
|
23
|
+
else
|
24
|
+
begin
|
25
|
+
page_name =~ /the (.*) page/
|
26
|
+
path_components = $1.split(/\s+/)
|
27
|
+
self.send(path_components.push('path').join('_').to_sym)
|
28
|
+
rescue Object => e
|
29
|
+
raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
|
30
|
+
"Now, go and add a mapping in #{__FILE__}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
World(NavigationHelpers)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module SeedUserRoles
|
2
|
+
def self.seed
|
3
|
+
Role.public || Factory( :role_public )
|
4
|
+
Role.learner || Factory( :role_learner )
|
5
|
+
Role.user_admin || Factory(:role_user_admin)
|
6
|
+
Role.course_admin || Factory(:role_course_admin)
|
7
|
+
Role.product_admin || Factory(:role_product_admin)
|
8
|
+
Role.tech_support || Factory(:role_tech_support)
|
9
|
+
Role.scitent_admin || Factory(:role_scitent_admin)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.clean
|
13
|
+
Role.destroy_all
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module HtmlSelectorsHelpers
|
2
|
+
# Maps a name to a selector. Used primarily by the
|
3
|
+
#
|
4
|
+
# When /^(.+) within (.+)$/ do |step, scope|
|
5
|
+
#
|
6
|
+
# step definitions in web_steps.rb
|
7
|
+
#
|
8
|
+
def selector_for(locator)
|
9
|
+
case locator
|
10
|
+
|
11
|
+
when /the page/
|
12
|
+
"html > body"
|
13
|
+
|
14
|
+
when /manage menu/
|
15
|
+
".manage-menu"
|
16
|
+
|
17
|
+
when /([^"]*) tab content/
|
18
|
+
tab_pane_id = locator.match(/([^"]*) tab content/)[1].downcase.gsub(' ','-')
|
19
|
+
"##{tab_pane_id}.tab-pane"
|
20
|
+
|
21
|
+
when /expandable row for user "([^"]*)"/
|
22
|
+
user = User.find_by_email(locator.match(/expandable row for user "([^"]*)"/)[1])
|
23
|
+
"#users-found > .table-blue-zebra > table > tbody > tr + tr.expandable section#user-#{user.id}"
|
24
|
+
|
25
|
+
when /the seminar applications widget/
|
26
|
+
"#portlet-seminar-applications"
|
27
|
+
|
28
|
+
when /^the "([^"]*)" table$/
|
29
|
+
table_ancestor_id = locator.match(/the "([^"]*)" table/)[1].downcase.gsub(' ','-')
|
30
|
+
"##{table_ancestor_id} table"
|
31
|
+
|
32
|
+
when /cell (\d+) of row (\d+) of the "([^"]*)" table/
|
33
|
+
cell_index, row_index, table_ancestor_id = locator.match(/cell (\d+) of row (\d+) of the "([^"]*)" table/).to_a.drop(1)
|
34
|
+
"##{table_ancestor_id.downcase.gsub(' ','-')} table tbody tr:nth-child(#{row_index}) td:nth-child(#{cell_index})"
|
35
|
+
|
36
|
+
when /cell (\d+) of the header row of the "([^"]*)" table/
|
37
|
+
cell_index, table_ancestor_id = locator.match(/cell (\d+) of the header row of the "([^"]*)" table/).to_a.drop(1)
|
38
|
+
"##{table_ancestor_id.downcase.gsub(' ','-')} table thead tr:first-child th:nth-child(#{cell_index})"
|
39
|
+
|
40
|
+
|
41
|
+
# Add more mappings here.
|
42
|
+
# Here is an example that pulls values out of the Regexp:
|
43
|
+
#
|
44
|
+
# when /the (notice|error|info) flash/
|
45
|
+
# ".flash.#{$1}"
|
46
|
+
|
47
|
+
# You can also return an array to use a different selector
|
48
|
+
# type, like:
|
49
|
+
#
|
50
|
+
# when /the header/
|
51
|
+
# [:xpath, "//header"]
|
52
|
+
|
53
|
+
# This allows you to provide a quoted selector as the scope
|
54
|
+
# for "within" steps as was previously the default for the
|
55
|
+
# web steps:
|
56
|
+
when /"(.+)"/
|
57
|
+
$1
|
58
|
+
|
59
|
+
else
|
60
|
+
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
|
61
|
+
"Now, go and add a mapping in #{__FILE__}"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
World(HtmlSelectorsHelpers)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'scidea/plugins/update_migration_generator'
|
2
|
+
|
3
|
+
module Scidea
|
4
|
+
module Hsfc
|
5
|
+
module Policies
|
6
|
+
class MigrationsGenerator < Scidea::Plugins::UpdateMigrationGenerator
|
7
|
+
MigrationsGenerator.source_root(File.expand_path('templates', File.dirname(__FILE__) ) )
|
8
|
+
|
9
|
+
def plugin_migrations_path
|
10
|
+
MigrationsGenerator.source_root
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'scidea/plugins/remove_migration_generator'
|
2
|
+
|
3
|
+
module Scidea
|
4
|
+
module Hsfc
|
5
|
+
module Policies
|
6
|
+
class RemovalMigrationsGenerator < Scidea::Plugins::RemoveMigrationGenerator
|
7
|
+
RemovalMigrationsGenerator.source_root(File.expand_path('templates/removal', File.dirname(__FILE__) ) )
|
8
|
+
|
9
|
+
def plugin_migrations_path
|
10
|
+
RemovalMigrationsGenerator.source_root
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ScideaHsfcPolicies99Remove < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Setting.where(:name => 'Registration: Privacy Policy URL (en)').destroy_all
|
4
|
+
Setting.where(:name => 'Registration: Privacy Policy URL (fr)').destroy_all
|
5
|
+
Setting.where(:name => 'Registration: Terms and Conditions URL (en)').destroy_all
|
6
|
+
Setting.where(:name => 'Registration: Terms and Conditions URL (fr)').destroy_all
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
Setting.find_or_create_by_name(:name => 'Registration: Privacy Policy URL (en)', :value => '#')
|
11
|
+
Setting.find_or_create_by_name(:name => 'Registration: Privacy Policy URL (fr)', :value => '#')
|
12
|
+
Setting.find_or_create_by_name(:name => 'Registration: Terms and Conditions URL (en)', :value => '#')
|
13
|
+
Setting.find_or_create_by_name(:name => 'Registration: Terms and Conditions URL (fr)', :value => '#')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ScideaHsfcPolicies01Install < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
Setting.find_or_create_by_name(:name => 'Registration: Privacy Policy URL (en)', :value => '#')
|
4
|
+
Setting.find_or_create_by_name(:name => 'Registration: Privacy Policy URL (fr)', :value => '#')
|
5
|
+
Setting.find_or_create_by_name(:name => 'Registration: Terms and Conditions URL (en)', :value => '#')
|
6
|
+
Setting.find_or_create_by_name(:name => 'Registration: Terms and Conditions URL (fr)', :value => '#')
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
Setting.where(:name => 'Registration: Privacy Policy URL (en)').destroy_all
|
11
|
+
Setting.where(:name => 'Registration: Privacy Policy URL (fr)').destroy_all
|
12
|
+
Setting.where(:name => 'Registration: Terms and Conditions URL (en)').destroy_all
|
13
|
+
Setting.where(:name => 'Registration: Terms and Conditions URL (fr)').destroy_all
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'models/profile'
|
2
|
+
require_relative 'helpers/policies_helper'
|
3
|
+
|
4
|
+
module Scidea
|
5
|
+
module Hsfc
|
6
|
+
module Policies
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
|
9
|
+
initializer "scidea.hsfc.policies.register_view_callbacks" do
|
10
|
+
Scidea::Plugins::Plugin.on(:registration_new_before_profile) { 'registrations/hsfc_policies' }
|
11
|
+
end
|
12
|
+
|
13
|
+
config.to_prepare do
|
14
|
+
Profile.class_eval { include Scidea::Hsfc::Policies::Models::Profile }
|
15
|
+
|
16
|
+
PluginsHelper.class_eval { include Scidea::Hsfc::Policies::Helpers::PoliciesHelper }
|
17
|
+
end
|
18
|
+
|
19
|
+
end # class Engine
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Scidea
|
2
|
+
module Hsfc
|
3
|
+
module Policies
|
4
|
+
module Helpers
|
5
|
+
module PoliciesHelper
|
6
|
+
|
7
|
+
def hsfc_policies_label(locale, setting_name, t_key)
|
8
|
+
url = Setting.value(setting_name)
|
9
|
+
label = t(t_key)
|
10
|
+
link_text = label.match(/<a>([^<]*)<\/a>/)[1]
|
11
|
+
|
12
|
+
sep = (url =~ /\?/) ? '&' : '?'
|
13
|
+
label.sub( /<a>([^<]*)<\/a>/, link_to(link_text, "#{url}#{sep}locale=#{locale}") ).html_safe
|
14
|
+
end
|
15
|
+
|
16
|
+
def hsfc_policies_privacy_policy_label(locale)
|
17
|
+
locale ||= I18n.default_locale
|
18
|
+
hsfc_policies_label(locale, "Registration: Privacy Policy URL (#{locale})", 'registration.privacy')
|
19
|
+
end
|
20
|
+
|
21
|
+
def hsfc_policies_terms_label(locale)
|
22
|
+
locale ||= I18n.default_locale
|
23
|
+
hsfc_policies_label(locale, "Registration: Terms and Conditions URL (#{locale})", 'registration.terms_and_conditions')
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Scidea
|
2
|
+
module Hsfc
|
3
|
+
module Policies
|
4
|
+
module Models
|
5
|
+
module Profile
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
validates :agrees_to_privacy_policy, :acceptance => true, :on => :create
|
10
|
+
validates :agrees_to_terms, :acceptance => true, :on => :create
|
11
|
+
end
|
12
|
+
|
13
|
+
end # profile
|
14
|
+
end # models
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'scidea/hsfc/policies'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Scidea::Hsfc::Policies::Helpers::PoliciesHelper do
|
4
|
+
let(:locale) { 'en' }
|
5
|
+
|
6
|
+
describe "hsfc_policies_privacy_policy_label" do
|
7
|
+
before do
|
8
|
+
helper.stub(:'t').and_return("This is the <a>policy</a>")
|
9
|
+
Setting.stub(:value).and_return("#")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return the translation with the url interpolated" do
|
13
|
+
helper.hsfc_policies_privacy_policy_label(locale).should == "This is the <a href=\"#?locale=en\">policy</a>"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "hsfc_policies_terms_label" do
|
19
|
+
before do
|
20
|
+
helper.stub(:'t').and_return("This is the <a>terms</a>")
|
21
|
+
Setting.stub(:value).and_return("#")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return the translation with the url interpolated" do
|
25
|
+
helper.hsfc_policies_terms_label(locale).should == "This is the <a href=\"#?locale=en\">terms</a>"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end #describe
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
ENV["RAILS_ENV"] ||= 'test'
|
2
|
+
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'rspec'
|
8
|
+
|
9
|
+
require 'rspec/rails'
|
10
|
+
require 'rspec_tag_matchers'
|
11
|
+
require 'cancan/matchers'
|
12
|
+
require 'paperclip/matchers'
|
13
|
+
|
14
|
+
require File.expand_path("../../features/support/seed_user_roles.rb", __FILE__)
|
15
|
+
|
16
|
+
# Requires supporting files with custom matchers and macros, etc,
|
17
|
+
# in ./support/ and its subdirectories.
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.mock_with :rspec
|
22
|
+
config.use_transactional_fixtures = true
|
23
|
+
|
24
|
+
config.before(:suite) do
|
25
|
+
DatabaseCleaner.strategy = :transaction
|
26
|
+
DatabaseCleaner.clean_with(:truncation)
|
27
|
+
::SeedUserRoles.seed
|
28
|
+
end
|
29
|
+
|
30
|
+
config.before(:each) do
|
31
|
+
DatabaseCleaner.start
|
32
|
+
end
|
33
|
+
|
34
|
+
config.after(:each) do
|
35
|
+
DatabaseCleaner.clean
|
36
|
+
end
|
37
|
+
|
38
|
+
config.after(:suite) do
|
39
|
+
::SeedUserRoles.clean
|
40
|
+
end
|
41
|
+
|
42
|
+
config.include Devise::TestHelpers, :type => :controller
|
43
|
+
config.include Devise::TestHelpers, :type => :view
|
44
|
+
config.extend ControllerMacros, :type => :controller
|
45
|
+
end
|
46
|
+
|
47
|
+
# load local factories which will be added to the factories from scidea.
|
48
|
+
Rails.configuration.after_initialize do
|
49
|
+
FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)]
|
50
|
+
FactoryGirl.find_definitions
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ControllerMacros
|
2
|
+
def login_scitent_admin
|
3
|
+
before(:each) do
|
4
|
+
@request.env["devise.mapping"] = Devise.mappings[:users]
|
5
|
+
sign_in Factory(:user_scitent_admin)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def login_learner
|
10
|
+
before(:each) do
|
11
|
+
@request.env["devise.mapping"] = Devise.mappings[:users]
|
12
|
+
sign_in Factory(:user_learner)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "registrations/_hsfc_policies.html.erb" do
|
4
|
+
let(:profile) { Factory.build :profile }
|
5
|
+
|
6
|
+
def render_partial
|
7
|
+
form = Formtastic::FormBuilder.new(:profile, profile, view, {}, nil)
|
8
|
+
render 'registrations/hsfc_policies', :form => form
|
9
|
+
end
|
10
|
+
|
11
|
+
before do
|
12
|
+
view.stub(:hsfc_policies_privacy_policy_label).and_return('privacy')
|
13
|
+
view.stub(:hsfc_policies_terms_label).and_return('terms')
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should render checkbox for privacy policy" do
|
17
|
+
render_partial
|
18
|
+
assert_select "input[type=checkbox][name*=agrees_to_privacy_policy]", :count => 1
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should render checkbox for terms and condtions" do
|
22
|
+
render_partial
|
23
|
+
assert_select "input[type=checkbox][name*=agrees_to_terms]", :count => 1
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should call terms helper method" do
|
27
|
+
view.should_receive(:hsfc_policies_privacy_policy_label)
|
28
|
+
render_partial
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should call privacy helper method" do
|
32
|
+
view.should_receive(:hsfc_policies_terms_label)
|
33
|
+
render_partial
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: scidea-hsfc-policies
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Phoenix Team
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-19 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: HSFC Policies augments standard user profile to include agreements for
|
15
|
+
privacy policy and terms and conditions. These items appear on the registration
|
16
|
+
form above the standard profile and are required.
|
17
|
+
email:
|
18
|
+
- phoenix@scitent.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- app/views/registrations/_hsfc_policies.html.erb
|
24
|
+
- lib/scidea/hsfc/policies.rb
|
25
|
+
- lib/scidea/hsfc/policies/engine.rb
|
26
|
+
- lib/scidea/hsfc/policies/helpers/policies_helper.rb
|
27
|
+
- lib/scidea/hsfc/policies/models/profile.rb
|
28
|
+
- lib/scidea/hsfc/policies/version.rb
|
29
|
+
- lib/scidea-hsfc-policies.rb
|
30
|
+
- lib/generators/scidea/hsfc/policies/removal_migrations_generator.rb
|
31
|
+
- lib/generators/scidea/hsfc/policies/templates/removal/scidea_hsfc_policies_99_remove.rb
|
32
|
+
- lib/generators/scidea/hsfc/policies/templates/scidea_hsfc_policies_01_install.rb
|
33
|
+
- lib/generators/scidea/hsfc/policies/migrations_generator.rb
|
34
|
+
- config/environment.rb
|
35
|
+
- config/locales/fr.yml
|
36
|
+
- config/locales/en.yml
|
37
|
+
- config/cucumber.yml
|
38
|
+
- features/support/seed_user_roles.rb
|
39
|
+
- features/support/env.rb
|
40
|
+
- features/support/selectors.rb
|
41
|
+
- features/support/paths.rb
|
42
|
+
- features/support/hooks.rb
|
43
|
+
- spec/helpers/policies_helper_spec.rb
|
44
|
+
- spec/views/registrations/_hsfc_policies.html.erb_spec.rb
|
45
|
+
- spec/factories/profiles.rb
|
46
|
+
- spec/support/controller_macros.rb
|
47
|
+
- spec/models/profile_spec.rb
|
48
|
+
- spec/spec_helper.rb
|
49
|
+
- MIT-LICENSE
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- CHANGELOG
|
53
|
+
homepage: https://github.com/phoenix-scitent/scidea-hsfc-policies
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.10
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Policy-related customizations to HSFC instance of Scidea
|
77
|
+
test_files: []
|