faalis 2.0.8 → 2.1.0

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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -0
  3. data.tar.gz.sig +0 -0
  4. data/Rakefile +15 -9
  5. data/app/assets/javascripts/faalis/dashboard/application.js.erb +4 -3
  6. data/app/assets/javascripts/faalis/dashboard/init.js.coffee +1 -1
  7. data/{spec/dummy/public/favicon.ico → app/assets/javascripts/faalis/dashboard/lib/amd.js.coffee.erb} +0 -0
  8. data/app/assets/stylesheets/faalis/dashboard/share.scss +5 -0
  9. data/app/controllers/faalis/assets_controller.rb +6 -0
  10. data/app/controllers/faalis/dashboard/user_messages_controller.rb +27 -0
  11. data/app/models/application_record.rb +3 -0
  12. data/app/models/faalis/group.rb +4 -3
  13. data/app/models/faalis/permission.rb +2 -2
  14. data/app/models/faalis/user.rb +1 -7
  15. data/app/models/faalis/user_message.rb +6 -0
  16. data/app/policies/faalis/user_message_policy.rb +9 -0
  17. data/app/policies/faalis/user_policy.rb +1 -1
  18. data/app/views/faalis/dashboard/resource/edit.html.slim +1 -1
  19. data/app/views/faalis/dashboard/resource/show.html.slim +1 -2
  20. data/app/views/faalis/dashboard/shared/_header.html.erb +2 -2
  21. data/app/views/faalis/dashboard/user_messages/_form.html.slim +0 -0
  22. data/app/views/faalis/dashboard/user_messages/create.js.erb +0 -0
  23. data/app/views/faalis/dashboard/user_messages/destroy.js.erb +0 -0
  24. data/app/views/faalis/dashboard/user_messages/new.html.slim +72 -0
  25. data/app/views/layouts/faalis/dashboard.html.erb +2 -1
  26. data/config/locales/faalis.en.yml +2 -1
  27. data/config/routes.rb +6 -21
  28. data/db/migrate/20160310105736_create_faalis_user_messages.rb +16 -0
  29. data/lib/faalis.rb +1 -1
  30. data/lib/faalis/configuration.rb +79 -52
  31. data/lib/faalis/dashboard/dsl.rb +1 -0
  32. data/lib/faalis/dashboard/models/sidebar.rb +42 -16
  33. data/lib/faalis/dashboard/sections/resource.rb +152 -130
  34. data/lib/faalis/dashboard/sections/resource_create.rb +1 -3
  35. data/lib/faalis/engine.rb +7 -5
  36. data/lib/faalis/orm.rb +5 -5
  37. data/lib/faalis/version.rb +1 -1
  38. data/{spec → test}/dummy/README.rdoc +0 -0
  39. data/{spec → test}/dummy/Rakefile +0 -0
  40. data/{spec → test}/dummy/app/assets/javascripts/application.js +0 -0
  41. data/{spec → test}/dummy/app/assets/javascripts/dashboard/application.js +0 -0
  42. data/{spec → test}/dummy/app/assets/stylesheets/application.css +0 -0
  43. data/{spec → test}/dummy/app/assets/stylesheets/dashboard/ltr/application.css +0 -0
  44. data/{spec → test}/dummy/app/assets/stylesheets/dashboard/rtl/application.css +0 -0
  45. data/{spec → test}/dummy/app/assets/stylesheets/ltr/application.css +0 -0
  46. data/{spec → test}/dummy/app/assets/stylesheets/rtl/application.css +0 -0
  47. data/{spec → test}/dummy/app/controllers/api_controller.rb +0 -0
  48. data/{spec → test}/dummy/app/controllers/application_controller.rb +0 -0
  49. data/{spec → test}/dummy/app/controllers/dashboard/application_controller.rb +0 -0
  50. data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
  51. data/{spec → test}/dummy/app/policies/application_policy.rb +0 -0
  52. data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
  53. data/{spec → test}/dummy/bin/bundle +0 -0
  54. data/{spec → test}/dummy/bin/rails +0 -0
  55. data/{spec → test}/dummy/bin/rake +0 -0
  56. data/{spec → test}/dummy/config.ru +0 -0
  57. data/{spec → test}/dummy/config/application.rb +0 -0
  58. data/{spec → test}/dummy/config/boot.rb +0 -0
  59. data/{spec → test}/dummy/config/database.yml +0 -0
  60. data/{spec → test}/dummy/config/environment.rb +0 -0
  61. data/{spec → test}/dummy/config/environments/development.rb +0 -0
  62. data/{spec → test}/dummy/config/environments/production.rb +0 -0
  63. data/{spec → test}/dummy/config/environments/test.rb +2 -0
  64. data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  65. data/{spec → test}/dummy/config/initializers/devise.rb +0 -0
  66. data/{spec → test}/dummy/config/initializers/faalis.rb +0 -0
  67. data/{spec → test}/dummy/config/initializers/faalis_assets.rb +0 -0
  68. data/{spec → test}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  69. data/{spec → test}/dummy/config/initializers/formstatic.rb +0 -0
  70. data/{spec → test}/dummy/config/initializers/formtastic.rb +0 -0
  71. data/{spec → test}/dummy/config/initializers/inflections.rb +0 -0
  72. data/{spec → test}/dummy/config/initializers/kaminari_config.rb +0 -0
  73. data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
  74. data/{spec → test}/dummy/config/initializers/secret_token.rb +0 -0
  75. data/{spec → test}/dummy/config/initializers/session_store.rb +0 -0
  76. data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +0 -0
  77. data/{spec → test}/dummy/config/locales/en.yml +0 -0
  78. data/{spec → test}/dummy/config/routes.rb +0 -0
  79. data/test/dummy/db/test.sqlite3 +0 -0
  80. data/{spec → test}/dummy/lib/templates/slim/scaffold/_form.html.slim +0 -0
  81. data/test/dummy/log/test.log +0 -0
  82. data/{spec → test}/dummy/public/404.html +0 -0
  83. data/{spec → test}/dummy/public/422.html +0 -0
  84. data/{spec → test}/dummy/public/500.html +0 -0
  85. data/test/dummy/public/favicon.ico +0 -0
  86. data/test/fabricators/faalis/groups.rb +27 -0
  87. data/test/fabricators/faalis/permissions.rb +14 -0
  88. data/test/fabricators/faalis/users.rb +17 -0
  89. data/test/generators/install_generator_test.rb +84 -0
  90. data/test/integration/faalis/authentication_test.rb +36 -0
  91. data/test/integration/faalis/dashboard_test.rb +64 -0
  92. data/test/test_helper.rb +72 -0
  93. metadata +291 -150
  94. metadata.gz.sig +1 -0
  95. data/app/controllers/faalis/api/v1/conversations_controller.rb +0 -120
  96. data/app/controllers/faalis/api/v1/groups_controller.rb +0 -71
  97. data/app/controllers/faalis/api/v1/logs_controller.rb +0 -12
  98. data/app/controllers/faalis/api/v1/permissions_controller.rb +0 -61
  99. data/app/controllers/faalis/api/v1/profiles_controller.rb +0 -42
  100. data/app/controllers/faalis/api/v1/users_controller.rb +0 -75
  101. data/lib/faalis_application.rb +0 -446
  102. data/lib/faalis_plugin.rb +0 -477
  103. data/spec/factories/faalis/groups.rb +0 -31
  104. data/spec/factories/faalis/permissions.rb +0 -16
  105. data/spec/factories/faalis/users.rb +0 -23
  106. data/spec/features/dashboard_spec.rb +0 -36
  107. data/spec/features/record_not_found_spec.rb +0 -24
  108. data/spec/features/sign_in_spec.rb +0 -37
  109. data/spec/generators/install_spec.rb +0 -58
  110. data/spec/models/faalis/group_spec.rb +0 -32
  111. data/spec/models/faalis/permission_spec.rb +0 -15
  112. data/spec/models/faalis/user_spec.rb +0 -100
  113. data/spec/policies/faalis/admin_only_policy_spec.rb +0 -39
  114. data/spec/policies/faalis/application_policy_spec.rb +0 -49
  115. data/spec/spec_helper.rb +0 -89
  116. data/spec/support/factory_girl.rb +0 -3
@@ -1,31 +0,0 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
2
-
3
- def group(role)
4
- # get existing group or create new one
5
- Faalis::Group.where(role: role).first || FactoryGirl.create("#{role}_group")
6
- end
7
-
8
- FactoryGirl.define do
9
- factory :guest_group, :class => 'Faalis::Group' do |f|
10
- name 'Guest'
11
- role 'guest'
12
- end
13
-
14
- factory :admin_group, :class => 'Faalis::Group' do
15
- name 'Admin'
16
- role 'admin'
17
- end
18
-
19
- # This is a random group
20
- factory :manager_group, :class => 'Faalis::Group' do
21
- name 'Manager'
22
- role 'manager'
23
-
24
- permissions do
25
- [:index, :show, :update, :create, :destroy].map do |x|
26
- define_permission(x, :group)
27
- end
28
- end
29
- end
30
-
31
- end
@@ -1,16 +0,0 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
2
-
3
- def define_permission(action, model)
4
- perm = Faalis::Permission.find_by(permission_type: action,
5
- model: "Faalis::#{model.to_s.titleize}")
6
- perm || FactoryGirl.create("#{action}_#{model}")
7
- end
8
-
9
- FactoryGirl.define do
10
- [:index, :show, :update, :create, :destroy].each do |action|
11
- factory "#{action}_group".to_sym, :class => 'Faalis::Permission' do
12
- model 'Faalis::Group'
13
- permission_type action
14
- end
15
- end
16
- end
@@ -1,23 +0,0 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
2
-
3
- FactoryGirl.define do
4
- factory :user, 'class'.to_sym => 'Faalis::User' do
5
- first_name Faker::Name.first_name
6
- last_name Faker::Name.first_name
7
- sequence :email do |n|
8
- "person#{n}@example.com"
9
- end
10
-
11
- factory :admin do
12
- groups { [group(:admin)] }
13
- end
14
-
15
- factory :manager do
16
- groups { [group(:manager)] }
17
- end
18
-
19
- factory :guest do
20
- groups { [group(:guest)] }
21
- end
22
- end
23
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'Dashboard section' do
4
- before do
5
- @admin = create(:admin, password: '123123123',
6
- password_confirmation: '123123123')
7
-
8
- @guest = create(:guest, password: '123123123',
9
- password_confirmation: '123123123')
10
- @faalis = Faalis::Engine.routes.url_helpers
11
- end
12
-
13
- scenario 'loads normally after logging in.' do
14
- login_as(@admin, scope: :user)
15
- path = "/#{Faalis::Engine.dashboard_namespace}"
16
- visit faalis.dashboard_index_path
17
- expect(page).not_to have_text('404')
18
- expect(page).not_to have_text('Oops!')
19
- expect(page).to have_text('Faalis')
20
- expect(page).to have_text('Dashboard')
21
- expect(page).to have_text('User Management')
22
- expect(current_path).to eq(path)
23
- end
24
-
25
- scenario 'does not load with anonymous users' do
26
- visit @faalis.dashboard_index_path
27
- expect(current_path).to eq(@faalis.user_session_path)
28
- end
29
-
30
- scenario 'does not provide authentication section for guests' do
31
- visit @faalis.dashboard_index_path
32
- expect(page).not_to have_text('User Management')
33
- expect(page).not_to have_text('Users')
34
- expect(page).not_to have_text('Groups')
35
- end
36
- end
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'Dashboard resource finder exception' do
4
- before do
5
-
6
- @admin = create(:admin, password: '123123123',
7
- password_confirmation: '123123123')
8
- login_as(@admin, scope: :user)
9
- @faalis = Faalis::Engine.routes.url_helpers
10
- end
11
-
12
- scenario 'User try to find a resource which does not exists via js format.' do
13
- visit @faalis.dashboard_auth_user_path({ id: 3242, format: :js})
14
- expect(page).to have_text('error_message(')
15
- end
16
-
17
- scenario 'User try to find a valid resource' do
18
- visit @faalis.dashboard_auth_user_path({ id: 1 })
19
- expect(page).not_to have_text('404')
20
- expect(page).to have_text('User')
21
- expect(page).not_to have_text('Oops!')
22
- end
23
-
24
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- feature 'Sign in page', js: true do
4
- before do
5
- @admin = build(:admin, password: '123123123',
6
- password_confirmation: '123123123',
7
- email: 'admin@example.com')
8
-
9
- @admin.save
10
- @guest = create(:guest, password: '123123123',
11
- password_confirmation: '123123123')
12
- @faalis = Faalis::Engine.routes.url_helpers
13
- end
14
-
15
- scenario 'is up and running' do
16
- visit @faalis.user_session_path
17
-
18
- expect(page).to have_text('Sign In')
19
- expect(page).to have_css('.login-box-msg')
20
- expect(page).to have_selector('#user_email')
21
- expect(page).to have_selector('#user_password')
22
- end
23
-
24
- scenario 'allow user to successfully log in using valid credentials' do
25
- visit @faalis.dashboard_index_path
26
-
27
- fill_in 'user_email', with: @admin.email
28
- fill_in 'user_password', with: '123123123'
29
-
30
- click_button 'sign_in'
31
-
32
- expect(page).to have_text('Dashboard')
33
- expect(page).not_to have_text('Sign In')
34
- expect(current_path).to eq(@faalis.dashboard_index_path)
35
-
36
- end
37
- end
@@ -1,58 +0,0 @@
1
- require 'fileutils'
2
- require 'spec_helper'
3
- require 'generator_spec/test_case'
4
- require 'generators/faalis/install_generator'
5
-
6
- describe Faalis::Generators::InstallGenerator, type: :generator do
7
- include GeneratorSpec::TestCase
8
-
9
- destination File.expand_path('../../dummy/tmp', __FILE__)
10
-
11
- def file_exists(path)
12
- p = destination_root
13
- assert_file "#{p}/#{path}"
14
- end
15
-
16
- def content_of(path)
17
- full_path = "#{destination_root}/#{path}"
18
- File.read(full_path)
19
- end
20
-
21
- before :all do
22
- prepare_destination
23
-
24
- path = File.expand_path('../../dummy/tmp/', __FILE__)
25
-
26
- FileUtils.mkdir_p("#{path}/config/initializers")
27
- FileUtils.mkdir_p("#{path}/app/controllers")
28
- FileUtils.mkdir_p("#{path}/db")
29
-
30
- FileUtils.touch("#{path}/config/routes.rb")
31
- FileUtils.touch("#{path}/Gemfile")
32
- FileUtils.touch("#{path}/config/initializers/assets.rb")
33
- FileUtils.touch("#{path}/config/initializers/formtastic.rb")
34
- FileUtils.touch("#{path}/db/seeds.rb")
35
-
36
-
37
- FileUtils.touch("#{path}/app/controllers/application_controller.rb")
38
- run_generator
39
- end
40
-
41
- it 'copies the config files' do
42
- file_exists('config/initializers/faalis.rb')
43
- file_exists('config/initializers/devise.rb')
44
- file_exists('db/seeds.rb')
45
- file_exists('app/controllers/api_controller.rb')
46
- file_exists('app/controllers/dashboard/application_controller.rb')
47
- file_exists('app/policies/application_policy.rb')
48
- end
49
-
50
- it 'copies the Javascripts manifest for dashboard' do
51
- file_exists('app/assets/javascripts/dashboard/application.js')
52
- end
53
-
54
- it 'copies stylesheet filese' do
55
- file_exists('app/assets/stylesheets/dashboard/ltr/application.css')
56
- file_exists('app/assets/stylesheets/dashboard/rtl/application.css')
57
- end
58
- end
@@ -1,32 +0,0 @@
1
- # == Schema Information
2
- #
3
- # Table name: faalis_groups
4
- #
5
- # id :integer not null, primary key
6
- # name :string
7
- # role :string
8
- # created_at :datetime
9
- # updated_at :datetime
10
- #
11
-
12
- require 'spec_helper'
13
-
14
- describe Faalis::Group do
15
-
16
- context 'Validation' do
17
- it 'would not be valid if group already exists' do
18
- group(:admin)
19
- group = build(:admin_group)
20
-
21
- expect(group).not_to be_valid
22
- end
23
-
24
- it 'would not be valid without a name and role name' do
25
- group1 = build(:admin_group, name: '')
26
- group2 = build(:admin_group, role: '')
27
-
28
- expect(group1).not_to be_valid
29
- expect(group2).not_to be_valid
30
- end
31
- end
32
- end
@@ -1,15 +0,0 @@
1
- # == Schema Information
2
- #
3
- # Table name: faalis_permissions
4
- #
5
- # id :integer not null, primary key
6
- # model :string
7
- # permission_type :string
8
- # created_at :datetime
9
- # updated_at :datetime
10
- #
11
-
12
- require 'spec_helper'
13
-
14
- describe Faalis::Permission do
15
- end
@@ -1,100 +0,0 @@
1
- # == Schema Information
2
- #
3
- # Table name: faalis_users
4
- #
5
- # id :integer not null, primary key
6
- # email :string default(""), not null
7
- # encrypted_password :string default(""), not null
8
- # reset_password_token :string
9
- # reset_password_sent_at :datetime
10
- # remember_created_at :datetime
11
- # sign_in_count :integer default("0")
12
- # current_sign_in_at :datetime
13
- # last_sign_in_at :datetime
14
- # current_sign_in_ip :string
15
- # last_sign_in_ip :string
16
- # first_name :string
17
- # last_name :string
18
- # group_id :integer default("2")
19
- # failed_attempts :integer default("0")
20
- # unlock_token :string
21
- # locked_at :datetime
22
- # created_at :datetime
23
- # updated_at :datetime
24
- #
25
-
26
- require 'spec_helper'
27
-
28
- describe Faalis::User do
29
-
30
-
31
- let(:fake_password) { Faker::Internet.password(8) }
32
-
33
- before :all do
34
- group(:admin)
35
- group(:guest)
36
- end
37
-
38
- context 'Validation' do
39
- it 'is not valid without a password' do
40
- expect(build(:user)).not_to be_valid
41
- end
42
-
43
-
44
- it 'is not valid without of a valid email' do
45
- user1 = build(:user, password: fake_password, email: '')
46
- user2 = build(:user, password: fake_password, email: 'some_email')
47
-
48
- expect(user1).not_to be_valid
49
- expect(user2).not_to be_valid
50
- end
51
- end
52
-
53
- describe 'Groups & Roles' do
54
-
55
- it 'have a "roles" method which returns an array of its roles.' do
56
- user = create(:user, password: fake_password)
57
-
58
- expect(user.roles).to be_a_kind_of(Array)
59
- expect(user.roles).to include('guest')
60
- end
61
-
62
- it 'are in "Guest" group if no group provided' do
63
- user = create(:user, password: fake_password)
64
- expect(user.groups.size).to eq(1)
65
- #expect(user.groups.first).to be_a_kind_of(Faalis::Group)
66
- end
67
-
68
- it 'have a functional many to many to group' do
69
- user = create(:user, groups: [group(:admin)],
70
- password: fake_password)
71
-
72
- expect(user.groups.size).to eq(1)
73
- expect(user.groups.first).to be_a_kind_of(Faalis::Group)
74
- end
75
-
76
- it 'can be in serveral groups' do
77
- user1 = create(:user,
78
- groups: [group(:admin), group(:guest)],
79
- password: fake_password)
80
-
81
- user2 = create(:user,
82
- password: fake_password)
83
-
84
- user2.groups << group(:admin)
85
-
86
- expect(user1.groups.size).to eq(2)
87
- expect(user2.groups.size).to eq(2)
88
-
89
- end
90
-
91
- it 'should not join to `guest` group when using build' do
92
- user = build(:user,
93
- password: fake_password)
94
- expect(user.groups.size).to eq(0)
95
-
96
- user.save
97
- expect(user.groups.size).to eq(1)
98
- end
99
- end
100
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Faalis::AdminOnlyPolicy do
4
- subject { Faalis::AdminOnlyPolicy.new(user, entity) }
5
-
6
- # We use Group as an entity because we don't have
7
- # too much models
8
- let(:entity) { group(:admin) }
9
-
10
- context 'for visitors' do
11
- let(:user) { nil }
12
-
13
- [:index, :show, :update, :create, :destroy].each do |action|
14
- it "denies access to #{action} on the protected entity" do
15
- expect(subject.send("#{action}?")).not_to be(true)
16
- end
17
- end
18
- end
19
-
20
- context 'for guest users' do
21
- let(:user) { create(:user, password: '123123123') }
22
-
23
- [:index, :show, :update, :create, :destroy].each do |action|
24
- it "denies access to #{action} on the protected entity" do
25
- expect(subject.send("#{action}?")).not_to be(true)
26
- end
27
- end
28
- end
29
-
30
- context 'for admin users' do
31
- let(:user) { create(:admin, password: '123123123') }
32
-
33
- [:index, :show, :update, :create, :destroy].each do |action|
34
- it "denies access to #{action} on the protected entity" do
35
- expect(subject.send("#{action}?")).to be(true)
36
- end
37
- end
38
- end
39
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Faalis::ApplicationPolicy do
4
- subject { Faalis::ApplicationPolicy.new(user, entity) }
5
-
6
- # We use Group as an entity because we don't have
7
- # too much models
8
- let(:entity) { group(:admin) }
9
-
10
- context 'for visitors' do
11
- let(:user) { nil }
12
-
13
- [:index, :show, :update, :create, :destroy].each do |action|
14
- it "denies access to #{action} on the protected entity" do
15
- expect(subject.send("#{action}?")).not_to be(true)
16
- end
17
- end
18
- end
19
-
20
- context 'for guest users' do
21
- let(:user) { create(:user, password: '123123123') }
22
-
23
- [:index, :show, :update, :create, :destroy].each do |action|
24
- it "denies access to #{action} on the protected entity" do
25
- expect(subject.send("#{action}?")).not_to be(true)
26
- end
27
- end
28
- end
29
-
30
- context 'for admin users' do
31
- let(:user) { create(:admin, password: '123123123') }
32
-
33
- [:index, :show, :update, :create, :destroy].each do |action|
34
- it "grants access to #{action} on the protected entity" do
35
- expect(subject.send("#{action}?")).to be(true)
36
- end
37
- end
38
- end
39
-
40
- context 'for users who have the right' do
41
- let(:user) { create(:manager, password: '123123123') }
42
-
43
- [:index, :show, :update, :create, :destroy].each do |action|
44
- it "denies access to #{action} on the protected entity" do
45
- expect(subject.send("#{action}?")).to be(true)
46
- end
47
- end
48
- end
49
- end