diff --git a/Gemfile.lock b/Gemfile.lock index 5ab99a8..89e142a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,195 +1,194 @@ GEM remote: https://rubygems.org/ specs: - actioncable (5.0.0) - actionpack (= 5.0.0) - nio4r (~> 1.2) + actioncable (5.0.7.2) + actionpack (= 5.0.7.2) + nio4r (>= 1.2, < 3.0) websocket-driver (~> 0.6.1) - actionmailer (5.0.0) - actionpack (= 5.0.0) - actionview (= 5.0.0) - activejob (= 5.0.0) + actionmailer (5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.0.0) - actionview (= 5.0.0) - activesupport (= 5.0.0) + actionpack (5.0.7.2) + actionview (= 5.0.7.2) + activesupport (= 5.0.7.2) rack (~> 2.0) rack-test (~> 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.0.0) - activesupport (= 5.0.0) + actionview (5.0.7.2) + activesupport (= 5.0.7.2) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (5.0.0) - activesupport (= 5.0.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.0.7.2) + activesupport (= 5.0.7.2) globalid (>= 0.3.6) - activemodel (5.0.0) - activesupport (= 5.0.0) - activerecord (5.0.0) - activemodel (= 5.0.0) - activesupport (= 5.0.0) + activemodel (5.0.7.2) + activesupport (= 5.0.7.2) + activerecord (5.0.7.2) + activemodel (= 5.0.7.2) + activesupport (= 5.0.7.2) arel (~> 7.0) - activesupport (5.0.0) + activesupport (5.0.7.2) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (~> 0.7) + i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) - addressable (2.4.0) - arel (7.0.0) - autoprefixer-rails (6.3.7) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) + arel (7.1.4) + autoprefixer-rails (9.6.1.1) execjs - awesome_print (1.7.0) + awesome_print (1.8.0) babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - bitters (1.3.2) - bourbon (>= 5.0.0.beta.6) - sass (~> 3.4) - thor (~> 0.19) + bindex (0.8.1) bourbon (5.0.0.beta.6) sass (~> 3.4.22) thor (~> 0.19.1) - builder (3.2.2) - bullet (5.1.1) + builder (3.2.3) + bullet (6.0.2) activesupport (>= 3.0.0) - uniform_notifier (~> 1.10.0) - bundler-audit (0.5.0) - bundler (~> 1.2) + uniform_notifier (~> 1.11) + bundler-audit (0.6.1) + bundler (>= 1.2.0, < 3) thor (~> 0.18) - byebug (9.0.5) - capybara (2.7.1) + byebug (11.0.1) + capybara (3.15.1) addressable - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - capybara-webkit (1.11.1) - capybara (>= 2.3.0, < 2.8.0) + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (~> 1.2) + xpath (~> 3.2) + capybara-webkit (1.15.1) + capybara (>= 2.3, < 4.0) json - coderay (1.1.1) - concurrent-ruby (1.0.2) + coderay (1.1.2) + concurrent-ruby (1.1.5) crack (0.4.3) safe_yaml (~> 1.0.0) - database_cleaner (1.5.3) - debug_inspector (0.0.2) - delayed_job (4.1.2) - activesupport (>= 3.0, < 5.1) - delayed_job_active_record (4.1.1) - activerecord (>= 3.0, < 5.1) + crass (1.0.4) + database_cleaner (1.7.0) + delayed_job (4.1.8) + activesupport (>= 3.0, < 6.1) + delayed_job_active_record (4.1.4) + activerecord (>= 3.0, < 6.1) delayed_job (>= 3.0, < 5) - diff-lcs (1.2.5) - docile (1.1.5) - dotenv (2.1.1) - dotenv-rails (2.1.1) - dotenv (= 2.1.1) - railties (>= 4.0, < 5.1) + diff-lcs (1.3) + docile (1.3.2) + dotenv (2.7.5) + dotenv-rails (2.7.5) + dotenv (= 2.7.5) + railties (>= 3.2, < 6.1) erubis (2.7.0) execjs (2.7.0) - factory_girl (4.7.0) + factory_girl (4.9.0) activesupport (>= 3.0.0) - factory_girl_rails (4.7.0) - factory_girl (~> 4.7.0) + factory_girl_rails (4.9.0) + factory_girl (~> 4.9.0) railties (>= 3.0.0) - ffi (1.9.14) - flutie (2.0.0) - formulaic (0.3.0) + ffi (1.11.1) + flutie (2.1.0) + formulaic (0.4.1) activesupport capybara i18n - globalid (0.3.6) - activesupport (>= 4.1.0) - hashdiff (0.3.0) - high_voltage (3.0.0) - honeybadger (2.6.0) - i18n (0.7.0) - jquery-rails (4.1.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + hashdiff (1.0.0) + high_voltage (3.1.2) + honeybadger (4.5.1) + i18n (1.6.0) + concurrent-ruby (~> 1.0) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.0.1) + json (2.2.0) launchy (2.4.3) addressable (~> 2.3) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) - loofah (2.0.3) + loofah (2.2.3) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.4) - mime-types (>= 1.16, < 4) - method_source (0.8.2) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) - minitest (5.9.0) + mail (2.7.1) + mini_mime (>= 0.1.1) + method_source (0.9.2) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.11.3) neat (1.8.0) sass (>= 3.3) thor (~> 0.19) - nio4r (1.2.1) - nokogiri (1.6.8) - mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) + nio4r (2.5.1) + nokogiri (1.10.4) + mini_portile2 (~> 2.4.0) normalize-rails (3.0.3) - pg (0.18.4) - pkg-config (1.1.7) - pry (0.10.4) + pg (1.1.4) + pry (0.12.2) coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-byebug (3.4.0) - byebug (~> 9.0) + method_source (~> 0.9.0) + pry-byebug (3.7.0) + byebug (~> 11.0) pry (~> 0.10) - pry-rails (0.3.4) - pry (>= 0.9.10) - puma (3.4.0) - rack (2.0.1) - rack-canonical-host (0.2.2) + pry-rails (0.3.9) + pry (>= 0.10.4) + public_suffix (3.1.1) + puma (4.1.0) + nio4r (~> 2.0) + rack (2.0.7) + rack-canonical-host (0.2.3) addressable (> 0, < 3) rack (>= 1.0.0, < 3) - rack-mini-profiler (0.10.1) + rack-mini-profiler (1.0.2) rack (>= 1.2.0) rack-test (0.6.3) rack (>= 1.0) - rack-timeout (0.4.2) - rails (5.0.0) - actioncable (= 5.0.0) - actionmailer (= 5.0.0) - actionpack (= 5.0.0) - actionview (= 5.0.0) - activejob (= 5.0.0) - activemodel (= 5.0.0) - activerecord (= 5.0.0) - activesupport (= 5.0.0) - bundler (>= 1.3.0, < 2.0) - railties (= 5.0.0) + rack-timeout (0.5.1) + rails (5.0.7.2) + actioncable (= 5.0.7.2) + actionmailer (= 5.0.7.2) + actionpack (= 5.0.7.2) + actionview (= 5.0.7.2) + activejob (= 5.0.7.2) + activemodel (= 5.0.7.2) + activerecord (= 5.0.7.2) + activesupport (= 5.0.7.2) + bundler (>= 1.3.0) + railties (= 5.0.7.2) sprockets-rails (>= 2.0.0) - rails-dom-testing (2.0.1) - activesupport (>= 4.2.0, < 6.0) - nokogiri (~> 1.6.0) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.2.0) + loofah (~> 2.2, >= 2.2.2) rails_stdout_logging (0.0.5) - railties (5.0.0) - actionpack (= 5.0.0) - activesupport (= 5.0.0) + railties (5.0.7.2) + actionpack (= 5.0.7.2) + activesupport (= 5.0.7.2) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (11.2.2) - rb-fsevent (0.9.7) - rb-inotify (0.9.7) - ffi (>= 0.5.0) - recipient_interceptor (0.1.2) + rake (12.3.3) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + recipient_interceptor (0.2.0) mail - refills (0.1.0) - rspec-core (3.5.1) + refills (0.2.0) + regexp_parser (1.6.0) + rspec-core (3.5.4) rspec-support (~> 3.5.0) rspec-expectations (3.5.0) diff-lcs (>= 1.2.0, < 2.0) @@ -197,7 +196,7 @@ GEM rspec-mocks (3.5.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.5.0) - rspec-rails (3.5.1) + rspec-rails (3.5.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -206,72 +205,75 @@ GEM rspec-mocks (~> 3.5.0) rspec-support (~> 3.5.0) rspec-support (3.5.0) - ruby_dep (1.3.1) - safe_yaml (1.0.4) - sass (3.4.22) - sass-rails (5.0.5) + ruby_dep (1.5.0) + safe_yaml (1.0.5) + sass (3.4.25) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - shoulda-matchers (3.1.1) - activesupport (>= 4.0.0) - simple_form (3.2.1) - actionpack (> 4, < 5.1) - activemodel (> 4, < 5.1) - simplecov (0.12.0) - docile (~> 1.1.0) + shoulda-matchers (4.0.1) + activesupport (>= 4.2.0) + simple_form (4.1.0) + actionpack (>= 5.0) + activemodel (>= 5.0) + simplecov (0.17.0) + docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - skylight (0.10.5) - activesupport (>= 3.0.0) - slop (3.6.0) - spring (1.7.2) + simplecov-html (0.10.2) + skylight (4.1.2) + skylight-core (= 4.1.2) + skylight-core (4.1.2) + activesupport (>= 4.2.0) + spring (2.0.2) + activesupport (>= 4.2) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - sprockets (3.6.3) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-es6 (0.9.0) + sprockets-es6 (0.9.2) babel-source (>= 5.8.11) babel-transpiler sprockets (>= 3.0.0) - sprockets-rails (3.1.1) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - suspenders (1.41.0) - bitters (~> 1.3) - bundler (~> 1.3) - rails (~> 5.0.0) - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.5) - timecop (0.8.1) + suspenders (0.2.4) + bundler (>= 1.0.7) + rails (>= 3.0.3) + trout (>= 0.3.0) + thor (0.19.4) + thread_safe (0.3.6) + tilt (2.0.9) + timecop (0.9.1) title (0.0.7) i18n rails (>= 3.1) - tzinfo (1.2.2) + trout (0.3) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (3.0.0) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) - uniform_notifier (1.10.0) - web-console (3.3.1) + uniform_notifier (1.12.1) + web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) - debug_inspector + bindex (>= 0.4.0) railties (>= 5.0) - webmock (2.1.0) + webmock (3.7.0) addressable (>= 2.3.6) crack (>= 0.3.2) - hashdiff - websocket-driver (0.6.4) + hashdiff (>= 0.4.0, < 2.0.0) + websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) - xpath (2.0.0) - nokogiri (~> 1.3) + websocket-extensions (0.1.4) + xpath (3.2.0) + nokogiri (~> 1.8) PLATFORMS ruby @@ -328,4 +330,4 @@ RUBY VERSION ruby 2.3.1p112 BUNDLED WITH - 1.12.5 + 2.0.2 diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index 1378696..cfd03c1 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -1,37 +1,48 @@ require "rails_helper" RSpec.describe Invitation do - let(:invitation) { build(:invitation, team: team, user: new_user) } - let(:new_user) { create(:user, email: "rookie@example.com") } - let(:team) { create(:team, name: "A fine team") } - let(:team_owner) { create(:user) } + # let(:invitation) { build(:invitation, team: team, user: new_user) } + # let(:new_user) { create(:user, email: "rookie@example.com") } + # let(:team) { create(:team, name: "A fine team") } + # let(:team_owner) { create(:user) } - before do - team.update!(owner: team_owner) - team_owner.update!(team: team) - end + # before do + # team.update!(owner: team_owner) + # team_owner.update!(team: team) + # end describe "callbacks" do describe "after_save" do context "with valid data" do it "invites the user" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: new_user) invitation.save expect(new_user).to be_invited end end context "with invalid data" do - before do - invitation.team = nil - invitation.save - end + # before do + # invitation.team = nil + # invitation.save + # end it "does not save the invitation" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: nil) + invitation = Invitation.new(team: nil, user: new_user) + invitation.save expect(invitation).not_to be_valid expect(invitation).to be_new_record end it "does not mark the user as invited" do + new_user = User.new(email: nil) + team = Team.new(name: nil) + invitation = Invitation.new(team: nil, user: new_user) + invitation.save expect(new_user).not_to be_invited end end @@ -40,42 +51,67 @@ describe "#event_log_statement" do context "when the record is saved" do - before do - invitation.save - end + # before do + # invitation.save + # end it "include the name of the team" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: new_user) + invitation.save log_statement = invitation.event_log_statement expect(log_statement).to include("A fine team") end it "include the email of the invitee" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: new_user) + invitation.save log_statement = invitation.event_log_statement expect(log_statement).to include("rookie@example.com") end end context "when the record is not saved but valid" do + it "includes the name of the team" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: new_user) + invitation.save log_statement = invitation.event_log_statement expect(log_statement).to include("A fine team") end it "includes the email of the invitee" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: new_user) + invitation.save log_statement = invitation.event_log_statement expect(log_statement).to include("rookie@example.com") end it "includes the word 'PENDING'" do + new_user = User.new(email: "rookie@example.com") + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: new_user) + log_statement = invitation.event_log_statement + invitation.save expect(log_statement).to include("PENDING") end end context "when the record is not saved and not valid" do it "includes INVALID" do + team = Team.new(name: "A fine team") + invitation = Invitation.new(team: team, user: nil) invitation.user = nil - log_statement = invitation.event_log_statement + invitation.save + log_statement = invitation.event_log_statement expect(log_statement).to include("INVALID") end end