think_feel_do_dashboard 1.1.14 → 1.1.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,27 +72,57 @@ describe Group do
72
72
  expect(moderating_participant.errors.full_messages.include?("Is admin can't be destroyed.")).to be_truthy
73
73
  end
74
74
 
75
- it ".create_moderator catches and displays error" do
76
- allow_any_instance_of(Participant).to receive(:valid?) { false }
77
- membership_count = Membership.count
78
- participant_count = Participant.count
79
- profile_count = SocialNetworking::Profile.count
80
- groupie = Group.new(arm_id: arms(:arm1).id, moderator_id: clinician2.id, title: "Test")
81
-
82
- expect { groupie.save! }.to raise_error
83
- expect(groupie.errors.full_messages.include?("There were errors: Validation failed: ")).to be_truthy
84
- expect(Membership.count).to eq membership_count
85
- expect(Participant.count).to eq participant_count
86
- expect(SocialNetworking::Profile.count).to eq profile_count
75
+ describe "saving" do
76
+ let(:invalid_group) do
77
+ Group.new(
78
+ arm_id: social_arm.id,
79
+ moderator_id: clinician2.id,
80
+ title: "Test")
81
+ end
82
+
83
+ describe "when invalid" do
84
+ before do
85
+ allow_any_instance_of(Participant)
86
+ .to receive(:valid?) { false }
87
+ end
88
+
89
+ it "moderator is not created" do
90
+ expect { invalid_group.save! }
91
+ .to raise_error(ActiveRecord::RecordInvalid)
92
+ expect { invalid_group.save }
93
+ .to_not change { Membership.count }
94
+ expect { invalid_group.save }
95
+ .to_not change { Participant.count }
96
+ expect { invalid_group.save }
97
+ .to_not change { SocialNetworking::Profile.count }
98
+ end
99
+ end
87
100
  end
88
101
 
89
- it ".create_moderator allows a participant to active nearly a century later" do
90
- groupie = Group.create(arm_id: arms(:arm1).id, moderator_id: clinician2.id, title: "Test")
102
+ describe ".create" do
103
+ let(:valid_group) do
104
+ Group.create!(
105
+ arm_id: social_arm.id,
106
+ moderator_id: clinician2.id,
107
+ title: "Test")
108
+ end
91
109
 
92
- expect(groupie.moderating_participant).to_not be_nil
110
+ before do
111
+ valid_group.reload
112
+ end
113
+
114
+ it "sets a participant to be active almost a year later" do
115
+ Timecop.travel Time.zone.today.advance(days: 365) do
116
+ expect(valid_group.moderating_participant)
117
+ .to_not be_nil
118
+ end
119
+ end
93
120
 
94
- Timecop.travel Time.zone.today.advance(years: 99) do
95
- expect(groupie.moderating_participant.memberships.first.active?).to be_truthy
121
+ it "sets a participant to be inactive a year later" do
122
+ Timecop.travel Time.zone.today.advance(days: 366) do
123
+ expect(valid_group.moderating_participant)
124
+ .to be_nil
125
+ end
96
126
  end
97
127
  end
98
128
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: think_feel_do_dashboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.14
4
+ version: 1.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Carty-Fickes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-03-23 00:00:00.000000000 Z
13
+ date: 2016-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails