think_feel_do_dashboard 1.1.10 → 1.1.11

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: 756096b8c05829aa2f884e5f5ab81834a30182cd
4
- data.tar.gz: 2b043dfeb1edcef2f67d667847973f9ba97ea13d
3
+ metadata.gz: 4bf5728c5a9df450ae129c254a23c30f0ec281c2
4
+ data.tar.gz: d012a44b1f4557932ea6cbf9af80e5d3a1231bcb
5
5
  SHA512:
6
- metadata.gz: b2bcbc0c9712fdcbce7764f240e017cda1f9afe4f3997eed5b9972da1888ff26af792abfd05d481511668750384e435dbdd2480754f8d67b9c5b0c297526405e
7
- data.tar.gz: f8557e0f51915803abf6d4ee827daffbb46bb2aee866d16649dfaccf88a34c78b46328897d8cdbd53ec8dbda8a2d561cae570f442642a5d759074f32bba109ce
6
+ metadata.gz: f43672ab1ae2d80a6a8aa71573565c0770103ca0f90a6217fca39198d2535874bc3ec9c42a40d68bc00ddc4139bddd00dfa861aeb921ee89f209f7c1838e1d9e
7
+ data.tar.gz: 6a6bb8414e58b61c2233aef4d0559ffb9e28c0d5146b3d456eac0392395e192ed668b16de8a787f10a7793dc6e830566d9f330484d09ee253fcdcf77c915198c
@@ -4,7 +4,7 @@ module ThinkFeelDoDashboard
4
4
  # Allows Coaches/Clinicians to moderate.
5
5
  # That is, log in as a participant
6
6
  class ModeratorsController < ApplicationController
7
- before_action :authenticate_user!, :set_group
7
+ before_action :set_group
8
8
 
9
9
  # POST /coach/groups/:group_id/moderates
10
10
  def create
@@ -17,6 +17,9 @@ module ThinkFeelDoDashboard
17
17
 
18
18
  def set_group
19
19
  @group = Group.find(params[:group_id])
20
+
21
+ rescue ActiveRecord::RecordNotFound => e
22
+ redirect_to root_path, alert: e.message
20
23
  end
21
24
  end
22
25
  end
@@ -5,9 +5,8 @@ module ThinkFeelDoDashboard
5
5
  # Allows for the creation, updating, and deletion of social networking
6
6
  # profile questions
7
7
  class ProfileQuestionsController < ApplicationController
8
- before_action :authenticate_user!
9
8
  before_action :set_profile_question, except: [:index, :new, :create]
10
- before_action :set_group
9
+ before_action :set_group, :authorize_group_access!
11
10
 
12
11
  def index
13
12
  @profile_questions = ::SocialNetworking::ProfileQuestion
@@ -53,14 +52,23 @@ module ThinkFeelDoDashboard
53
52
 
54
53
  private
55
54
 
55
+ def authorize_group_access!
56
+ authorize! :moderate, @group
57
+ end
58
+
56
59
  def set_group
57
60
  @group = Group.find(params[:group_id])
58
- authorize! :moderate, @group
61
+
62
+ rescue ActiveRecord::RecordNotFound => e
63
+ redirect_to root_path, alert: e.message
59
64
  end
60
65
 
61
66
  def set_profile_question
62
67
  @profile_question = ::SocialNetworking::ProfileQuestion
63
68
  .find(params[:id])
69
+
70
+ rescue ActiveRecord::RecordNotFound => e
71
+ redirect_to root_path, alert: e.message
64
72
  end
65
73
 
66
74
  def profile_question_params
@@ -1,4 +1,4 @@
1
1
  # Version number of engine
2
2
  module ThinkFeelDoDashboard
3
- VERSION = "1.1.10".freeze
3
+ VERSION = "1.1.11".freeze
4
4
  end
@@ -0,0 +1,53 @@
1
+ require "rails_helper"
2
+
3
+ module ThinkFeelDoDashboard
4
+ RSpec.describe ModeratorsController, type: :controller do
5
+ routes { Engine.routes }
6
+
7
+ describe "POST create" do
8
+ context "for authenticated users" do
9
+ let(:user) { instance_double(User, admin?: true) }
10
+
11
+ before do
12
+ sign_in_user user
13
+ end
14
+
15
+ describe "when Group is found" do
16
+ before do
17
+ expect(Group)
18
+ .to receive(:find) do
19
+ instance_double(
20
+ Group,
21
+ moderating_participant: user)
22
+ end
23
+ expect(controller).to receive(:sign_in).with(user)
24
+ allow(controller)
25
+ .to receive_message_chain("social_networking.social_networking_profile_path")
26
+ .and_return "hello_world"
27
+ end
28
+
29
+ it "should respond with a redirect to the moderator's profile page" do
30
+ post :create, group_id: 1
31
+
32
+ expect(response.status).to eq 302
33
+ expect(response.body).to match(/hello_world/)
34
+ end
35
+ end
36
+
37
+ describe "when Group is not found" do
38
+ it "should respond with a redirect" do
39
+ post :create, group_id: 1
40
+
41
+ expect(response.status).to eq 302
42
+ end
43
+ end
44
+ end
45
+
46
+ context "for unauthenticated users" do
47
+ before { post :create, group_id: 1 }
48
+
49
+ it_behaves_like "a rejected user action"
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,63 @@
1
+ require "rails_helper"
2
+
3
+ module ThinkFeelDoDashboard
4
+ module SocialNetworking
5
+ RSpec.describe ProfileQuestionsController, type: :controller do
6
+ routes { Engine.routes }
7
+
8
+ describe "GET edit" do
9
+ context "for authenticated users" do
10
+ let(:group) { instance_double(Group) }
11
+ let(:user) { instance_double(User, admin?: true) }
12
+
13
+ before do
14
+ sign_in_user user
15
+ end
16
+
17
+ describe "when ProfileQuestion is found" do
18
+ before do
19
+ expect(::SocialNetworking::ProfileQuestion)
20
+ .to receive(:find) do
21
+ double("ProfileQuestion")
22
+ end
23
+ end
24
+
25
+ describe "when Group is found" do
26
+ before do
27
+ expect(Group).to receive(:find) { group }
28
+ end
29
+
30
+ it "should respond with a redirect to the moderator's profile page" do
31
+ get :edit, group_id: 1, id: 1
32
+
33
+ expect(response.status).to eq 200
34
+ end
35
+ end
36
+
37
+ describe "when Group is not found" do
38
+ it "should respond with a redirect" do
39
+ get :edit, group_id: 1, id: 1
40
+
41
+ expect(response.status).to eq 302
42
+ end
43
+ end
44
+ end
45
+
46
+ describe "when ProfileQuestion is not found" do
47
+ it "should respond with a redirect" do
48
+ get :edit, group_id: 1, id: 1
49
+
50
+ expect(response.status).to eq 302
51
+ end
52
+ end
53
+ end
54
+
55
+ context "for unauthenticated users" do
56
+ before { get :edit, group_id: 1, id: 1 }
57
+
58
+ it_behaves_like "a rejected user action"
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -16,7 +16,7 @@ ActiveRecord::Schema.define(version: 20150410175659) do
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
18
18
 
19
- create_table "arms", force: true do |t|
19
+ create_table "arms", force: :cascade do |t|
20
20
  t.string "title", default: ""
21
21
  t.boolean "is_social", default: false
22
22
  t.datetime "created_at"
@@ -25,14 +25,14 @@ ActiveRecord::Schema.define(version: 20150410175659) do
25
25
  t.boolean "can_message_after_membership_complete", default: true, null: false
26
26
  end
27
27
 
28
- create_table "coach_assignments", force: true do |t|
28
+ create_table "coach_assignments", force: :cascade do |t|
29
29
  t.integer "coach_id", null: false
30
30
  t.integer "participant_id", null: false
31
31
  t.datetime "created_at"
32
32
  t.datetime "updated_at"
33
33
  end
34
34
 
35
- create_table "groups", force: true do |t|
35
+ create_table "groups", force: :cascade do |t|
36
36
  t.string "title"
37
37
  t.datetime "created_at"
38
38
  t.datetime "updated_at"
@@ -40,7 +40,7 @@ ActiveRecord::Schema.define(version: 20150410175659) do
40
40
  t.integer "moderator_id"
41
41
  end
42
42
 
43
- create_table "memberships", force: true do |t|
43
+ create_table "memberships", force: :cascade do |t|
44
44
  t.integer "group_id", null: false
45
45
  t.integer "participant_id", null: false
46
46
  t.date "end_date"
@@ -50,7 +50,7 @@ ActiveRecord::Schema.define(version: 20150410175659) do
50
50
  t.boolean "is_complete", default: false
51
51
  end
52
52
 
53
- create_table "participants", force: true do |t|
53
+ create_table "participants", force: :cascade do |t|
54
54
  t.string "email", default: "", null: false
55
55
  t.string "phone_number"
56
56
  t.string "study_id"
@@ -75,21 +75,21 @@ ActiveRecord::Schema.define(version: 20150410175659) do
75
75
  add_index "participants", ["reset_password_token"], name: "index_participants_on_reset_password_token", unique: true, using: :btree
76
76
  add_index "participants", ["study_id"], name: "index_participants_on_study_id", unique: true, using: :btree
77
77
 
78
- create_table "slideshow_anchors", force: true do |t|
78
+ create_table "slideshow_anchors", force: :cascade do |t|
79
79
  t.integer "bit_core_slideshow_id"
80
80
  t.string "target_name"
81
81
  t.datetime "created_at"
82
82
  t.datetime "updated_at"
83
83
  end
84
84
 
85
- create_table "social_networking_profile_questions", force: true do |t|
85
+ create_table "social_networking_profile_questions", force: :cascade do |t|
86
86
  t.integer "group_id"
87
87
  t.text "question_text"
88
88
  t.datetime "created_at"
89
89
  t.datetime "updated_at"
90
90
  end
91
91
 
92
- create_table "social_networking_profiles", force: true do |t|
92
+ create_table "social_networking_profiles", force: :cascade do |t|
93
93
  t.integer "participant_id"
94
94
  t.string "icon_name"
95
95
  t.boolean "active"
@@ -97,21 +97,21 @@ ActiveRecord::Schema.define(version: 20150410175659) do
97
97
  t.datetime "updated_at"
98
98
  end
99
99
 
100
- create_table "social_networking_shared_items", force: true do |t|
100
+ create_table "social_networking_shared_items", force: :cascade do |t|
101
101
  t.integer "participant_id"
102
102
  t.boolean "is_public"
103
103
  t.datetime "created_at"
104
104
  t.datetime "updated_at"
105
105
  end
106
106
 
107
- create_table "user_roles", force: true do |t|
107
+ create_table "user_roles", force: :cascade do |t|
108
108
  t.integer "user_id"
109
109
  t.string "role_class_name"
110
110
  t.datetime "created_at"
111
111
  t.datetime "updated_at"
112
112
  end
113
113
 
114
- create_table "users", force: true do |t|
114
+ create_table "users", force: :cascade do |t|
115
115
  t.string "email"
116
116
  t.datetime "created_at"
117
117
  t.datetime "updated_at"
@@ -371970,3 +371970,9 @@ PG::DuplicateTable: ERROR: relation "participants" already exists
371970
371970
   (0.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20141211143757')
371971
371971
   (0.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20141215203425')
371972
371972
   (0.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20150213215118')
371973
+ ActiveRecord::SchemaMigration Load (3.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
371974
+ Migrating to CreateParticipants (20141020185953)
371975
+  (0.4ms) BEGIN
371976
+ DEPRECATION WARNING: `#timestamps` was called without specifying an option for `null`. In Rails 5, this behavior will change to `null: false`. You should manually specify `null: true` to prevent the behavior of your existing migrations from changing. (called from block in change at /Users/usabilitymonitor/Desktop/Github/think_feel_do_dashboard/spec/dummy/db/migrate/20141020185953_create_participants.rb:8)
371977
+  (21.6ms) CREATE TABLE "participants" ("id" serial primary key, "email" character varying DEFAULT '' NOT NULL, "phone_number" character varying, "study_id" character varying, "created_at" timestamp, "updated_at" timestamp) 
371978
+  (0.3ms) ROLLBACK