inkwell 1.2.0 → 1.4.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/app/models/inkwell/community_user.rb +15 -0
- data/app/models/inkwell/following.rb +8 -0
- data/db/migrate/20130212130888_refactor_followings_relation.rb +27 -0
- data/db/migrate/20130212130898_refactor_user_community_relation.rb +72 -0
- data/db/migrate/20130212130908_refactor_invites_bans_mutes.rb +48 -0
- data/lib/acts_as_inkwell_community/base.rb +185 -180
- data/lib/acts_as_inkwell_user/base.rb +72 -30
- data/lib/common/base.rb +21 -0
- data/lib/inkwell/version.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130227154519_refactor_followings_relation.inkwell.rb +28 -0
- data/test/dummy/db/migrate/20130228115224_refactor_user_community_relation.inkwell.rb +73 -0
- data/test/dummy/db/migrate/20130312084529_refactor_invites_bans_mutes.inkwell.rb +49 -0
- data/test/dummy/db/schema.rb +33 -12
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +1986 -0
- data/test/dummy/log/test.log +0 -0
- data/test/dummy/spec/functional/community_spec.rb +513 -196
- data/test/dummy/spec/functional/following_spec.rb +55 -7
- data/test/dummy_without_community/db/development.sqlite3 +0 -0
- data/test/dummy_without_community/db/migrate/20130313083915_refactor_followings_relation.inkwell.rb +28 -0
- data/test/dummy_without_community/db/migrate/20130313083916_refactor_user_community_relation.inkwell.rb +73 -0
- data/test/dummy_without_community/db/migrate/20130313083917_refactor_invites_bans_mutes.inkwell.rb +49 -0
- data/test/dummy_without_community/db/schema.rb +12 -5
- data/test/dummy_without_community/db/test.sqlite3 +0 -0
- data/test/dummy_without_community/log/development.log +78 -0
- data/test/dummy_without_community/log/test.log +12652 -0
- data/test/dummy_without_community/spec/functional/following_spec.rb +20 -7
- metadata +31 -14
    
        data/test/dummy/log/test.log
    CHANGED
    
    | Binary file | 
| @@ -11,22 +11,17 @@ describe "Community" do | |
| 11 11 | 
             
                @salkar.reload
         | 
| 12 12 | 
             
                @talisman.reload
         | 
| 13 13 | 
             
                @morozovm.reload
         | 
| 14 | 
            +
                @community_1.reload
         | 
| 14 15 | 
             
              end
         | 
| 15 16 |  | 
| 16 17 | 
             
              it "user should been added to community" do
         | 
| 17 | 
            -
                 | 
| 18 | 
            -
                 | 
| 19 | 
            -
                 | 
| 20 | 
            -
                communities_info.size.should == 0
         | 
| 18 | 
            +
                ::Inkwell::CommunityUser.where(:user_id => @talisman.id, :community_id => @community_1.id).size.should == 1
         | 
| 19 | 
            +
                ::Inkwell::CommunityUser.where(:user_id => @salkar.id, :community_id => @community_1.id).empty?.should == true
         | 
| 20 | 
            +
                @salkar.communities_row.size.should == 0
         | 
| 21 21 | 
             
                @community_1.add_user :user => @salkar
         | 
| 22 22 | 
             
                @community_1.reload
         | 
| 23 23 | 
             
                @salkar.reload
         | 
| 24 | 
            -
                 | 
| 25 | 
            -
                users_ids.size.should == 2
         | 
| 26 | 
            -
                users_ids[1].should == @salkar.id
         | 
| 27 | 
            -
                communities_info = ActiveSupport::JSON.decode @salkar.communities_info
         | 
| 28 | 
            -
                communities_info.size.should == 1
         | 
| 29 | 
            -
                communities_info[0].should == {"c_id"=>@community_1.id, "a"=>"w"}
         | 
| 24 | 
            +
                ::Inkwell::CommunityUser.where(:user_id => @salkar.id, :community_id => @community_1.id).should be
         | 
| 30 25 | 
             
              end
         | 
| 31 26 |  | 
| 32 27 | 
             
              it "community's posts should been transferred to user timeline" do
         | 
| @@ -148,10 +143,7 @@ describe "Community" do | |
| 148 143 |  | 
| 149 144 | 
             
              it "user should be in community after added (include_user?)" do
         | 
| 150 145 | 
             
                @community_1.include_user?(@salkar).should == false
         | 
| 151 | 
            -
                @salkar. | 
| 152 | 
            -
                @community_1.users_ids = "[#{@salkar.id}]"
         | 
| 153 | 
            -
                @community_1.save
         | 
| 154 | 
            -
                @salkar.save
         | 
| 146 | 
            +
                ::Inkwell::CommunityUser.create :user_id => @salkar.id, :community_id => @community_1.id, :active => true
         | 
| 155 147 | 
             
                @community_1.include_user?(@salkar).should == true
         | 
| 156 148 | 
             
              end
         | 
| 157 149 |  | 
| @@ -160,10 +152,7 @@ describe "Community" do | |
| 160 152 | 
             
              end
         | 
| 161 153 |  | 
| 162 154 | 
             
              it "user should be admin" do
         | 
| 163 | 
            -
                @community_1. | 
| 164 | 
            -
                @community_1.save
         | 
| 165 | 
            -
                @community_1.reload
         | 
| 166 | 
            -
                @community_1.include_admin?(@salkar).should == true
         | 
| 155 | 
            +
                @community_1.include_admin?(@talisman).should == true
         | 
| 167 156 | 
             
              end
         | 
| 168 157 |  | 
| 169 158 | 
             
              it "user should remove himself from community" do
         | 
| @@ -175,7 +164,7 @@ describe "Community" do | |
| 175 164 | 
             
                @community_1.reload
         | 
| 176 165 | 
             
                @salkar.reload
         | 
| 177 166 | 
             
                @community_1.include_user?(@salkar).should == false
         | 
| 178 | 
            -
                 | 
| 167 | 
            +
                @community_1.admins_row.size.should == 1
         | 
| 179 168 | 
             
              end
         | 
| 180 169 |  | 
| 181 170 | 
             
              it "community owner should not remove himself from community" do
         | 
| @@ -247,9 +236,7 @@ describe "Community" do | |
| 247 236 | 
             
              end
         | 
| 248 237 |  | 
| 249 238 | 
             
              it "admin level of user should be returned" do
         | 
| 250 | 
            -
                @community_1. | 
| 251 | 
            -
                @community_1.save
         | 
| 252 | 
            -
                @community_1.admin_level_of(@salkar).should == 3
         | 
| 239 | 
            +
                @community_1.admin_level_of(@talisman).should == 0
         | 
| 253 240 | 
             
              end
         | 
| 254 241 |  | 
| 255 242 | 
             
              it "admin level of user should not be returned" do
         | 
| @@ -257,14 +244,8 @@ describe "Community" do | |
| 257 244 | 
             
              end
         | 
| 258 245 |  | 
| 259 246 | 
             
              it "admin should be added" do
         | 
| 260 | 
            -
                @community_1.admins_info = ActiveSupport::JSON.encode [{:admin_id => @salkar.id, :admin_level => 0}]
         | 
| 261 | 
            -
                @community_1.save
         | 
| 262 | 
            -
                @community_1.add_user :user => @salkar
         | 
| 263 247 | 
             
                @community_1.add_user :user => @morozovm
         | 
| 264 | 
            -
                @community_1. | 
| 265 | 
            -
                @salkar.reload
         | 
| 266 | 
            -
                @morozovm.reload
         | 
| 267 | 
            -
                @community_1.add_admin :admin => @salkar, :user => @morozovm
         | 
| 248 | 
            +
                @community_1.add_admin :admin => @talisman, :user => @morozovm
         | 
| 268 249 | 
             
                @community_1.reload
         | 
| 269 250 | 
             
                @salkar.reload
         | 
| 270 251 | 
             
                @community_1.include_admin?(@morozovm).should == true
         | 
| @@ -276,24 +257,16 @@ describe "Community" do | |
| 276 257 | 
             
                expect { @community_1.add_admin(:user => @salkar, :admin => @talisman) }.to raise_error
         | 
| 277 258 | 
             
                expect { @community_1.add_admin(:user => "@salkar", :admin => "@talisman") }.to raise_error
         | 
| 278 259 |  | 
| 279 | 
            -
                @community_1.admins_info = ActiveSupport::JSON.encode [{:admin_id => @salkar.id, :admin_level => 0}]
         | 
| 280 | 
            -
                @community_1.save
         | 
| 281 260 | 
             
                @community_1.add_user :user => @salkar
         | 
| 282 | 
            -
                @community_1.add_user :user => @morozovm
         | 
| 283 | 
            -
                @community_1.reload
         | 
| 284 | 
            -
                @salkar.reload
         | 
| 285 | 
            -
                @morozovm.reload
         | 
| 286 261 | 
             
                expect { @community_1.add_admin :admin => @salkar, :user => @salkar }.to raise_error
         | 
| 287 | 
            -
             | 
| 288 | 
            -
                @ | 
| 289 | 
            -
                ActiveSupport::JSON.decode(@community_1.admins_info).size.should == 1
         | 
| 262 | 
            +
             | 
| 263 | 
            +
                @community_1.admins_row.size.should == 1
         | 
| 290 264 | 
             
              end
         | 
| 291 265 |  | 
| 292 266 | 
             
              it "admin should be removed" do
         | 
| 293 | 
            -
                @community_1.admins_info = ActiveSupport::JSON.encode [{:admin_id => @salkar.id, :admin_level => 0}]
         | 
| 294 | 
            -
                @community_1.save
         | 
| 295 267 | 
             
                @community_1.add_user :user => @salkar
         | 
| 296 268 | 
             
                @community_1.add_user :user => @morozovm
         | 
| 269 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 297 270 | 
             
                @community_1.reload
         | 
| 298 271 | 
             
                @salkar.reload
         | 
| 299 272 | 
             
                @morozovm.reload
         | 
| @@ -306,7 +279,7 @@ describe "Community" do | |
| 306 279 | 
             
                @morozovm.reload
         | 
| 307 280 | 
             
                @community_1.include_admin?(@salkar).should == true
         | 
| 308 281 | 
             
                @community_1.include_admin?(@morozovm).should == false
         | 
| 309 | 
            -
                 | 
| 282 | 
            +
                @community_1.admins_row.size.should == 2
         | 
| 310 283 |  | 
| 311 284 | 
             
                @community_1.add_admin :admin => @salkar, :user => @morozovm
         | 
| 312 285 | 
             
                @community_1.reload
         | 
| @@ -323,14 +296,9 @@ describe "Community" do | |
| 323 296 | 
             
                expect { @community_1.remove_admin :admin => "@salkar", :user => "@morozovm" }.to raise_error
         | 
| 324 297 | 
             
                expect { @community_1.remove_admin :user => @morozovm }.to raise_error
         | 
| 325 298 |  | 
| 326 | 
            -
                @community_1.admins_info = ActiveSupport::JSON.encode [{:admin_id => @salkar.id, :admin_level => 0}]
         | 
| 327 | 
            -
                @community_1.save
         | 
| 328 299 | 
             
                @community_1.add_user :user => @salkar
         | 
| 329 300 | 
             
                @community_1.add_user :user => @morozovm
         | 
| 330 | 
            -
                @community_1. | 
| 331 | 
            -
                @salkar.reload
         | 
| 332 | 
            -
                @morozovm.reload
         | 
| 333 | 
            -
                expect { @community_1.remove_admin :user => @salkar, :admin => @salkar }.to raise_error
         | 
| 301 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 334 302 |  | 
| 335 303 | 
             
                @community_1.add_admin :admin => @salkar, :user => @morozovm
         | 
| 336 304 | 
             
                @community_1.reload
         | 
| @@ -547,19 +515,14 @@ describe "Community" do | |
| 547 515 | 
             
              end
         | 
| 548 516 |  | 
| 549 517 | 
             
              it "user should join community" do
         | 
| 550 | 
            -
                 | 
| 551 | 
            -
                 | 
| 552 | 
            -
                communities_info = ActiveSupport::JSON.decode @salkar.communities_info
         | 
| 553 | 
            -
                communities_info.size.should == 0
         | 
| 518 | 
            +
                @community_1.users_row.size.should == 1
         | 
| 519 | 
            +
                @salkar.communities_row.size.should == 0
         | 
| 554 520 | 
             
                @salkar.join @community_1
         | 
| 555 521 | 
             
                @community_1.reload
         | 
| 556 522 | 
             
                @salkar.reload
         | 
| 557 | 
            -
                 | 
| 558 | 
            -
                 | 
| 559 | 
            -
                 | 
| 560 | 
            -
                communities_info = ActiveSupport::JSON.decode @salkar.communities_info
         | 
| 561 | 
            -
                communities_info.size.should == 1
         | 
| 562 | 
            -
                communities_info[0].should == {"c_id"=>@community_1.id, "a"=>"w"}
         | 
| 523 | 
            +
                @community_1.users_row.size.should == 2
         | 
| 524 | 
            +
                @community_1.include_user?(@salkar).should == true
         | 
| 525 | 
            +
                @salkar.communities_row.should == [@community_1.id]
         | 
| 563 526 | 
             
              end
         | 
| 564 527 |  | 
| 565 528 | 
             
              it "user should leave community" do
         | 
| @@ -571,7 +534,7 @@ describe "Community" do | |
| 571 534 | 
             
                @community_1.reload
         | 
| 572 535 | 
             
                @salkar.reload
         | 
| 573 536 | 
             
                @community_1.include_user?(@salkar).should == false
         | 
| 574 | 
            -
                 | 
| 537 | 
            +
                @community_1.include_admin?(@salkar).should == false
         | 
| 575 538 | 
             
              end
         | 
| 576 539 |  | 
| 577 540 | 
             
              it "user should be kicked from community" do
         | 
| @@ -584,7 +547,6 @@ describe "Community" do | |
| 584 547 | 
             
                @community_1.reload
         | 
| 585 548 | 
             
                @salkar.reload
         | 
| 586 549 | 
             
                @community_1.include_user?(@salkar).should == false
         | 
| 587 | 
            -
                ActiveSupport::JSON.decode(@community_1.admins_info).size.should == 1
         | 
| 588 550 | 
             
              end
         | 
| 589 551 |  | 
| 590 552 | 
             
              it "post should be sended to community" do
         | 
| @@ -634,10 +596,9 @@ describe "Community" do | |
| 634 596 | 
             
              end
         | 
| 635 597 |  | 
| 636 598 | 
             
              it "admin permissions should be granted" do
         | 
| 637 | 
            -
                @community_1.admins_info = ActiveSupport::JSON.encode [{:admin_id => @salkar.id, :admin_level => 0}]
         | 
| 638 | 
            -
                @community_1.save
         | 
| 639 599 | 
             
                @community_1.add_user :user => @salkar
         | 
| 640 600 | 
             
                @community_1.add_user :user => @morozovm
         | 
| 601 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 641 602 | 
             
                @community_1.reload
         | 
| 642 603 | 
             
                @salkar.reload
         | 
| 643 604 | 
             
                @morozovm.reload
         | 
| @@ -645,27 +606,21 @@ describe "Community" do | |
| 645 606 | 
             
                @community_1.reload
         | 
| 646 607 | 
             
                @salkar.reload
         | 
| 647 608 | 
             
                @community_1.include_admin?(@morozovm).should == true
         | 
| 648 | 
            -
                @community_1.admin_level_of(@morozovm).should ==  | 
| 609 | 
            +
                @community_1.admin_level_of(@morozovm).should == 2
         | 
| 649 610 | 
             
              end
         | 
| 650 611 |  | 
| 651 612 | 
             
              it "admin permissions should be revoked" do
         | 
| 652 | 
            -
                @community_1.admins_info = ActiveSupport::JSON.encode [{:admin_id => @salkar.id, :admin_level => 0}]
         | 
| 653 | 
            -
                @community_1.save
         | 
| 654 613 | 
             
                @community_1.add_user :user => @salkar
         | 
| 655 614 | 
             
                @community_1.add_user :user => @morozovm
         | 
| 656 | 
            -
                @community_1. | 
| 657 | 
            -
                @salkar.reload
         | 
| 658 | 
            -
                @morozovm.reload
         | 
| 615 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 659 616 | 
             
                @community_1.add_admin :admin => @salkar, :user => @morozovm
         | 
| 660 | 
            -
                @community_1.reload
         | 
| 661 | 
            -
                @morozovm.reload
         | 
| 662 617 | 
             
                @community_1.include_admin?(@morozovm).should == true
         | 
| 663 618 | 
             
                @salkar.revoke_admin_permissions :user => @morozovm, :in_community => @community_1
         | 
| 664 619 | 
             
                @community_1.reload
         | 
| 665 620 | 
             
                @morozovm.reload
         | 
| 666 621 | 
             
                @community_1.include_admin?(@salkar).should == true
         | 
| 667 622 | 
             
                @community_1.include_admin?(@morozovm).should == false
         | 
| 668 | 
            -
                 | 
| 623 | 
            +
                @community_1.admins_row.size.should == 2
         | 
| 669 624 | 
             
              end
         | 
| 670 625 |  | 
| 671 626 | 
             
              it "community row should be returned for user" do
         | 
| @@ -687,10 +642,10 @@ describe "Community" do | |
| 687 642 | 
             
                @private_community.reload
         | 
| 688 643 | 
             
                @morozovm.reload
         | 
| 689 644 | 
             
                @private_community.public.should == false
         | 
| 690 | 
            -
                @private_community. | 
| 691 | 
            -
                @private_community. | 
| 692 | 
            -
                @private_community. | 
| 693 | 
            -
                 | 
| 645 | 
            +
                @private_community.writers_row.should == [@morozovm.id]
         | 
| 646 | 
            +
                @private_community.users_row.should == [@morozovm.id]
         | 
| 647 | 
            +
                @private_community.admins_row.should == [@morozovm.id]
         | 
| 648 | 
            +
                @private_community.admin_level_of(@morozovm).should == 0
         | 
| 694 649 | 
             
              end
         | 
| 695 650 |  | 
| 696 651 | 
             
              it "private community with default R access should be created" do
         | 
| @@ -700,10 +655,10 @@ describe "Community" do | |
| 700 655 | 
             
                @private_community.reload
         | 
| 701 656 | 
             
                @morozovm.reload
         | 
| 702 657 | 
             
                @private_community.public.should == false
         | 
| 703 | 
            -
                @private_community. | 
| 704 | 
            -
                @private_community. | 
| 705 | 
            -
                @private_community. | 
| 706 | 
            -
                 | 
| 658 | 
            +
                @private_community.include_user?(@morozovm).should == true
         | 
| 659 | 
            +
                @private_community.include_writer?(@morozovm).should == true
         | 
| 660 | 
            +
                @private_community.include_admin?(@morozovm).should == true
         | 
| 661 | 
            +
                @private_community.admin_level_of(@morozovm).should == 0
         | 
| 707 662 | 
             
              end
         | 
| 708 663 |  | 
| 709 664 | 
             
              it "public community with default W access should be created" do
         | 
| @@ -711,10 +666,10 @@ describe "Community" do | |
| 711 666 | 
             
                @w_community.reload
         | 
| 712 667 | 
             
                @morozovm.reload
         | 
| 713 668 | 
             
                @w_community.public.should == true
         | 
| 714 | 
            -
                @w_community. | 
| 715 | 
            -
                @w_community. | 
| 716 | 
            -
                @w_community. | 
| 717 | 
            -
                 | 
| 669 | 
            +
                @w_community.admins_row.should == [@morozovm.id]
         | 
| 670 | 
            +
                @w_community.admin_level_of(@morozovm).should == 0
         | 
| 671 | 
            +
                @w_community.writers_row.should == [@morozovm.id]
         | 
| 672 | 
            +
                @w_community.users_row.should == [@morozovm.id]
         | 
| 718 673 | 
             
              end
         | 
| 719 674 |  | 
| 720 675 | 
             
              it "public community with default R access should be created" do
         | 
| @@ -724,10 +679,11 @@ describe "Community" do | |
| 724 679 | 
             
                @community.reload
         | 
| 725 680 | 
             
                @morozovm.reload
         | 
| 726 681 | 
             
                @community.public.should == true
         | 
| 727 | 
            -
             | 
| 728 | 
            -
                 | 
| 729 | 
            -
                 | 
| 730 | 
            -
                 | 
| 682 | 
            +
             | 
| 683 | 
            +
                relation = ::Inkwell::CommunityUser.where(:user_id => @morozovm.id, :community_id => @community.id).first
         | 
| 684 | 
            +
                relation.should be
         | 
| 685 | 
            +
                relation.is_admin.should == true
         | 
| 686 | 
            +
                relation.user_access.should == "w"
         | 
| 731 687 | 
             
              end
         | 
| 732 688 |  | 
| 733 689 | 
             
              it "added to public community with default W access user should have W access" do
         | 
| @@ -738,9 +694,7 @@ describe "Community" do | |
| 738 694 | 
             
                @w_community.reload
         | 
| 739 695 | 
             
                @salkar.reload
         | 
| 740 696 | 
             
                @w_community.include_user?(@salkar).should == true
         | 
| 741 | 
            -
                 | 
| 742 | 
            -
                ActiveSupport::JSON.decode(@w_community.users_ids).should == [@morozovm.id, @salkar.id]
         | 
| 743 | 
            -
                ActiveSupport::JSON.decode(@w_community.writers_ids).should == [@morozovm.id, @salkar.id]
         | 
| 697 | 
            +
                ::Inkwell::CommunityUser.exists?(:community_id => @w_community.id, :user_id => @salkar.id, :user_access => "w").should == true
         | 
| 744 698 | 
             
              end
         | 
| 745 699 |  | 
| 746 700 | 
             
              it "added to public community with default R access user should have R access" do
         | 
| @@ -753,9 +707,7 @@ describe "Community" do | |
| 753 707 | 
             
                @community.reload
         | 
| 754 708 | 
             
                @salkar.reload
         | 
| 755 709 | 
             
                @community.include_user?(@salkar).should == true
         | 
| 756 | 
            -
                 | 
| 757 | 
            -
                ActiveSupport::JSON.decode(@community.users_ids).should == [@morozovm.id, @salkar.id]
         | 
| 758 | 
            -
                ActiveSupport::JSON.decode(@community.writers_ids).should == [@morozovm.id]
         | 
| 710 | 
            +
                ::Inkwell::CommunityUser.exists?(:community_id => @community.id, :user_id => @salkar.id, :user_access => "r").should == true
         | 
| 759 711 | 
             
              end
         | 
| 760 712 |  | 
| 761 713 | 
             
              it "added to private community with default W access user should have W access" do
         | 
| @@ -766,10 +718,9 @@ describe "Community" do | |
| 766 718 | 
             
                @salkar.reload
         | 
| 767 719 | 
             
                @private_community.reload
         | 
| 768 720 | 
             
                @private_community.include_user?(@salkar).should == true
         | 
| 769 | 
            -
                @private_community. | 
| 770 | 
            -
                @private_community. | 
| 721 | 
            +
                @private_community.users_row.should == [@morozovm.id, @salkar.id]
         | 
| 722 | 
            +
                @private_community.writers_row.should == [@morozovm.id, @salkar.id]
         | 
| 771 723 | 
             
                @salkar.communities_row.should == [@private_community.id]
         | 
| 772 | 
            -
                ActiveSupport::JSON.decode(@salkar.communities_info).should == [{"c_id" => @private_community.id, "a" => "w"}]
         | 
| 773 724 | 
             
              end
         | 
| 774 725 |  | 
| 775 726 | 
             
              it "added to private community with default R access user should have R access" do
         | 
| @@ -782,17 +733,15 @@ describe "Community" do | |
| 782 733 | 
             
                @salkar.reload
         | 
| 783 734 | 
             
                @private_community.reload
         | 
| 784 735 | 
             
                @private_community.include_user?(@salkar).should == true
         | 
| 785 | 
            -
                @private_community. | 
| 786 | 
            -
                @private_community. | 
| 736 | 
            +
                @private_community.users_row.should == [@morozovm.id, @salkar.id]
         | 
| 737 | 
            +
                @private_community.writers_row.should == [@morozovm.id]
         | 
| 787 738 | 
             
                @salkar.communities_row.should == [@private_community.id]
         | 
| 788 | 
            -
                ActiveSupport::JSON.decode(@salkar.communities_info).should == [{"c_id" => @private_community.id, "a" => "r"}]
         | 
| 789 739 | 
             
              end
         | 
| 790 740 |  | 
| 791 741 | 
             
              it "request invitation should be created (include_invitation_request?)" do
         | 
| 792 742 | 
             
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 793 743 | 
             
                @private_community.create_invitation_request @salkar
         | 
| 794 | 
            -
                @private_community. | 
| 795 | 
            -
                @private_community.invitations_uids.should == "[#{@salkar.id}]"
         | 
| 744 | 
            +
                ::Inkwell::CommunityUser.exists?(:user_id => @salkar.id, :community_id => @private_community.id, :active => false, :asked_invitation => true).should == true
         | 
| 796 745 | 
             
                @private_community.include_invitation_request?(@salkar).should == true
         | 
| 797 746 | 
             
              end
         | 
| 798 747 |  | 
| @@ -814,23 +763,20 @@ describe "Community" do | |
| 814 763 | 
             
              it "invitation request should be created" do
         | 
| 815 764 | 
             
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 816 765 | 
             
                @private_community.create_invitation_request @salkar
         | 
| 817 | 
            -
                @private_community. | 
| 818 | 
            -
                @private_community.invitations_uids.should == "[#{@salkar.id}]"
         | 
| 766 | 
            +
                ::Inkwell::CommunityUser.exists?(:user_id => @salkar.id, :community_id => @private_community.id, :active => false, :asked_invitation => true).should == true
         | 
| 819 767 | 
             
              end
         | 
| 820 768 |  | 
| 821 769 | 
             
              it "invitation request should not be created" do
         | 
| 822 770 | 
             
                expect { @community_1.create_invitation_request(@salkar) }.to raise_error
         | 
| 823 771 | 
             
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 824 | 
            -
                 | 
| 825 | 
            -
                @private_community.save
         | 
| 772 | 
            +
                ::Inkwell::CommunityUser.create :user_id => @talisman.id, :community_id => @private_community.id, :active => false, :banned => true
         | 
| 826 773 | 
             
                expect { @private_community.create_invitation_request(@talisman) }.to raise_error
         | 
| 827 774 | 
             
                @private_community.create_invitation_request(@salkar)
         | 
| 828 775 | 
             
                expect { @private_community.create_invitation_request(@salkar) }.to raise_error
         | 
| 829 776 | 
             
              end
         | 
| 830 777 |  | 
| 831 778 | 
             
              it "user should not be added to public community cause he is banned" do
         | 
| 832 | 
            -
                 | 
| 833 | 
            -
                @community_1.save
         | 
| 779 | 
            +
                ::Inkwell::CommunityUser.create :user_id => @morozovm.id, :community_id => @community_1.id, :active => false, :banned => true
         | 
| 834 780 | 
             
                expect { @morozovm.join @community_1 }.to raise_error
         | 
| 835 781 | 
             
              end
         | 
| 836 782 |  | 
| @@ -868,8 +814,8 @@ describe "Community" do | |
| 868 814 | 
             
                @salkar.reload
         | 
| 869 815 | 
             
                @private_community.reload
         | 
| 870 816 | 
             
                @private_community.include_user?(@salkar).should == true
         | 
| 871 | 
            -
                @private_community. | 
| 872 | 
            -
                @private_community. | 
| 817 | 
            +
                @private_community.users_row.should == [@morozovm.id, @salkar.id]
         | 
| 818 | 
            +
                @private_community.writers_row.should == [@morozovm.id, @salkar.id]
         | 
| 873 819 | 
             
                @salkar.communities_row.should == [@private_community.id]
         | 
| 874 820 | 
             
              end
         | 
| 875 821 |  | 
| @@ -894,8 +840,8 @@ describe "Community" do | |
| 894 840 | 
             
                @salkar.reload
         | 
| 895 841 |  | 
| 896 842 | 
             
                @private_community.include_user?(@salkar).should == true
         | 
| 897 | 
            -
                @private_community. | 
| 898 | 
            -
                @private_community. | 
| 843 | 
            +
                @private_community.users_row.should == [@morozovm.id, @salkar.id]
         | 
| 844 | 
            +
                @private_community.writers_row.should == [@morozovm.id, @salkar.id]
         | 
| 899 845 | 
             
                @salkar.communities_row.should == [@private_community.id]
         | 
| 900 846 |  | 
| 901 847 | 
             
                @private_community.remove_user :admin => @morozovm, :user => @salkar
         | 
| @@ -903,8 +849,8 @@ describe "Community" do | |
| 903 849 | 
             
                @salkar.reload
         | 
| 904 850 |  | 
| 905 851 | 
             
                @private_community.include_user?(@salkar).should == false
         | 
| 906 | 
            -
                @private_community. | 
| 907 | 
            -
                @private_community. | 
| 852 | 
            +
                @private_community.users_row.should == [@morozovm.id]
         | 
| 853 | 
            +
                @private_community.writers_row.should == [@morozovm.id]
         | 
| 908 854 | 
             
                @salkar.communities_row.should == []
         | 
| 909 855 | 
             
              end
         | 
| 910 856 |  | 
| @@ -917,9 +863,9 @@ describe "Community" do | |
| 917 863 |  | 
| 918 864 | 
             
                @private_community.include_user?(@salkar).should == true
         | 
| 919 865 | 
             
                @private_community.include_admin?(@salkar).should == true
         | 
| 920 | 
            -
                @private_community. | 
| 921 | 
            -
                @private_community. | 
| 922 | 
            -
                 | 
| 866 | 
            +
                @private_community.users_row.should == [@morozovm.id, @salkar.id]
         | 
| 867 | 
            +
                @private_community.writers_row.should == [@morozovm.id, @salkar.id]
         | 
| 868 | 
            +
                @private_community.admins_row.should == [@morozovm.id, @salkar.id]
         | 
| 923 869 | 
             
                @salkar.communities_row.should == [@private_community.id]
         | 
| 924 870 |  | 
| 925 871 | 
             
                @private_community.remove_user :admin => @morozovm, :user => @salkar
         | 
| @@ -927,9 +873,9 @@ describe "Community" do | |
| 927 873 | 
             
                @salkar.reload
         | 
| 928 874 |  | 
| 929 875 | 
             
                @private_community.include_user?(@salkar).should == false
         | 
| 930 | 
            -
                 | 
| 931 | 
            -
                @private_community. | 
| 932 | 
            -
                @private_community. | 
| 876 | 
            +
                @private_community.users_row.should == [@morozovm.id]
         | 
| 877 | 
            +
                @private_community.writers_row.should == [@morozovm.id]
         | 
| 878 | 
            +
                @private_community.admins_row.should == [@morozovm.id]
         | 
| 933 879 | 
             
                @salkar.communities_row.should == []
         | 
| 934 880 | 
             
              end
         | 
| 935 881 |  | 
| @@ -946,9 +892,6 @@ describe "Community" do | |
| 946 892 | 
             
                @private_community.reload
         | 
| 947 893 |  | 
| 948 894 | 
             
                @private_community.include_user?(@salkar).should == false
         | 
| 949 | 
            -
                ActiveSupport::JSON.decode(@private_community.admins_info).index{|item| item['admin_id'] == @salkar.id}.should == nil
         | 
| 950 | 
            -
                @private_community.users_ids.should == "[#{@morozovm.id}]"
         | 
| 951 | 
            -
                @private_community.writers_ids.should == "[#{@morozovm.id}]"
         | 
| 952 895 | 
             
                @salkar.communities_row.should == []
         | 
| 953 896 | 
             
              end
         | 
| 954 897 |  | 
| @@ -965,9 +908,7 @@ describe "Community" do | |
| 965 908 | 
             
                @private_community.reload
         | 
| 966 909 |  | 
| 967 910 | 
             
                @private_community.include_user?(@salkar).should == false
         | 
| 968 | 
            -
                 | 
| 969 | 
            -
                @private_community.users_ids.should == "[#{@morozovm.id}]"
         | 
| 970 | 
            -
                @private_community.writers_ids.should == "[#{@morozovm.id}]"
         | 
| 911 | 
            +
                ::Inkwell::CommunityUser.where(:community_id => @private_community.id).size.should == 1
         | 
| 971 912 | 
             
                @salkar.communities_row.should == []
         | 
| 972 913 | 
             
              end
         | 
| 973 914 |  | 
| @@ -987,9 +928,8 @@ describe "Community" do | |
| 987 928 |  | 
| 988 929 | 
             
                @public_community.include_user?(@salkar).should == true
         | 
| 989 930 | 
             
                @public_community.include_admin?(@salkar).should == true
         | 
| 990 | 
            -
                @public_community. | 
| 991 | 
            -
                @public_community. | 
| 992 | 
            -
                ActiveSupport::JSON.decode(@public_community.admins_info).index { |item| item['admin_id'] == @salkar.id }.should_not == nil
         | 
| 931 | 
            +
                @public_community.users_row.should == [@morozovm.id, @salkar.id]
         | 
| 932 | 
            +
                @public_community.writers_row.should == [@morozovm.id, @salkar.id]
         | 
| 993 933 | 
             
                @salkar.communities_row.should == [@public_community.id]
         | 
| 994 934 |  | 
| 995 935 | 
             
                @morozovm.kick :user => @salkar, :from_community => @public_community
         | 
| @@ -997,9 +937,8 @@ describe "Community" do | |
| 997 937 | 
             
                @public_community.reload
         | 
| 998 938 |  | 
| 999 939 | 
             
                @public_community.include_user?(@salkar).should == false
         | 
| 1000 | 
            -
                 | 
| 1001 | 
            -
                @public_community. | 
| 1002 | 
            -
                @public_community.writers_ids.should == "[#{@morozovm.id}]"
         | 
| 940 | 
            +
                @public_community.users_row.should == [@morozovm.id]
         | 
| 941 | 
            +
                @public_community.writers_row.should == [@morozovm.id]
         | 
| 1003 942 | 
             
                @salkar.communities_row.should == []
         | 
| 1004 943 | 
             
              end
         | 
| 1005 944 |  | 
| @@ -1169,13 +1108,12 @@ describe "Community" do | |
| 1169 1108 | 
             
                @public_community.reload
         | 
| 1170 1109 | 
             
                @morozovm.reload
         | 
| 1171 1110 |  | 
| 1172 | 
            -
                 | 
| 1111 | 
            +
                @public_community.include_user?(@salkar).should == true
         | 
| 1173 1112 | 
             
                @public_community.include_banned_user?(@salkar).should == false
         | 
| 1174 1113 | 
             
                @public_community.ban_user :user => @salkar, :admin => @morozovm
         | 
| 1175 1114 | 
             
                @public_community.reload
         | 
| 1176 1115 | 
             
                @public_community.include_banned_user?(@salkar).should == true
         | 
| 1177 1116 | 
             
                @public_community.include_user?(@salkar).should == false
         | 
| 1178 | 
            -
                ActiveSupport::JSON.decode(@public_community.admins_info).index{|item| item['admin_id'] == @salkar.id}.should == nil
         | 
| 1179 1117 |  | 
| 1180 1118 | 
             
                @private_community = Community.create :name => "Community", :owner_id => @morozovm.id, :public => false
         | 
| 1181 1119 | 
             
                @private_community.create_invitation_request @salkar
         | 
| @@ -1185,13 +1123,12 @@ describe "Community" do | |
| 1185 1123 | 
             
                @salkar.reload
         | 
| 1186 1124 | 
             
                @private_community.reload
         | 
| 1187 1125 |  | 
| 1188 | 
            -
                 | 
| 1126 | 
            +
                @private_community.include_user?(@salkar).should == true
         | 
| 1189 1127 | 
             
                @private_community.include_banned_user?(@salkar).should == false
         | 
| 1190 1128 | 
             
                @private_community.ban_user :user => @salkar, :admin => @morozovm
         | 
| 1191 1129 | 
             
                @private_community.reload
         | 
| 1192 1130 | 
             
                @private_community.include_banned_user?(@salkar).should == true
         | 
| 1193 1131 | 
             
                @private_community.include_user?(@salkar).should == false
         | 
| 1194 | 
            -
                ActiveSupport::JSON.decode(@private_community.admins_info).index{|item| item['admin_id'] == @salkar.id}.should == nil
         | 
| 1195 1132 | 
             
              end
         | 
| 1196 1133 |  | 
| 1197 1134 | 
             
              it "user with request invitation should be banned" do
         | 
| @@ -1288,13 +1225,13 @@ describe "Community" do | |
| 1288 1225 | 
             
                @public_community.reload
         | 
| 1289 1226 | 
             
                @morozovm.reload
         | 
| 1290 1227 |  | 
| 1291 | 
            -
                 | 
| 1228 | 
            +
                @public_community.include_admin?(@salkar).should == true
         | 
| 1292 1229 | 
             
                @public_community.include_banned_user?(@salkar).should == false
         | 
| 1293 1230 | 
             
                @morozovm.ban :user => @salkar, :in_community => @public_community
         | 
| 1294 1231 | 
             
                @public_community.reload
         | 
| 1295 1232 | 
             
                @public_community.include_banned_user?(@salkar).should == true
         | 
| 1296 1233 | 
             
                @public_community.include_user?(@salkar).should == false
         | 
| 1297 | 
            -
                 | 
| 1234 | 
            +
                @public_community.include_admin?(@salkar).should == false
         | 
| 1298 1235 | 
             
              end
         | 
| 1299 1236 |  | 
| 1300 1237 | 
             
              it "user should unban another user" do
         | 
| @@ -1561,8 +1498,7 @@ describe "Community" do | |
| 1561 1498 | 
             
              it "user should be able to request invitation to private community" do
         | 
| 1562 1499 | 
             
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 1563 1500 | 
             
                @salkar.request_invitation @private_community
         | 
| 1564 | 
            -
                @private_community. | 
| 1565 | 
            -
                @private_community.invitations_uids.should == "[#{@salkar.id}]"
         | 
| 1501 | 
            +
                ::Inkwell::CommunityUser.exists?(:user_id => @salkar.id, :community_id => @private_community.id, :active => false, :asked_invitation => true).should == true
         | 
| 1566 1502 | 
             
              end
         | 
| 1567 1503 |  | 
| 1568 1504 | 
             
              it "admin should be able to accept invitation request" do
         | 
| @@ -1573,8 +1509,8 @@ describe "Community" do | |
| 1573 1509 | 
             
                @salkar.reload
         | 
| 1574 1510 | 
             
                @private_community.reload
         | 
| 1575 1511 | 
             
                @private_community.include_user?(@salkar).should == true
         | 
| 1576 | 
            -
                @private_community. | 
| 1577 | 
            -
                @private_community. | 
| 1512 | 
            +
                @private_community.users_row.should == [@morozovm.id,@salkar.id]
         | 
| 1513 | 
            +
                @private_community.writers_row.should == [@morozovm.id,@salkar.id]
         | 
| 1578 1514 | 
             
                @salkar.communities_row.should == [@private_community.id]
         | 
| 1579 1515 | 
             
              end
         | 
| 1580 1516 |  | 
| @@ -1628,22 +1564,13 @@ describe "Community" do | |
| 1628 1564 | 
             
                @talisman.reload
         | 
| 1629 1565 | 
             
                @spy.reload
         | 
| 1630 1566 |  | 
| 1631 | 
            -
                writers_ids =  | 
| 1567 | 
            +
                writers_ids = @public_community.writers_row
         | 
| 1632 1568 | 
             
                writers_ids.include?(@salkar.id).should == true
         | 
| 1633 1569 | 
             
                writers_ids.include?(@talisman.id).should == true
         | 
| 1634 1570 | 
             
                writers_ids.include?(@spy.id).should == false
         | 
| 1635 1571 | 
             
                @public_community.include_writer?(@salkar).should == true
         | 
| 1636 1572 | 
             
                @public_community.include_writer?(@talisman).should == true
         | 
| 1637 1573 | 
             
                @public_community.include_writer?(@spy).should == false
         | 
| 1638 | 
            -
                communities_info = ActiveSupport::JSON.decode @salkar.communities_info
         | 
| 1639 | 
            -
                communities_info.size.should == 1
         | 
| 1640 | 
            -
                communities_info[0].should == {"c_id"=>@public_community.id, "a"=>"w"}
         | 
| 1641 | 
            -
                communities_info = ActiveSupport::JSON.decode @talisman.communities_info
         | 
| 1642 | 
            -
                communities_info.size.should == 2
         | 
| 1643 | 
            -
                communities_info[1].should == {"c_id" => @public_community.id, "a" => "w"}
         | 
| 1644 | 
            -
                communities_info = ActiveSupport::JSON.decode @spy.communities_info
         | 
| 1645 | 
            -
                communities_info.size.should == 1
         | 
| 1646 | 
            -
                communities_info[0].should == {"c_id" => @public_community.id, "a" => "r"}
         | 
| 1647 1574 | 
             
              end
         | 
| 1648 1575 |  | 
| 1649 1576 | 
             
              it "write access should be granted in the private community" do
         | 
| @@ -1667,25 +1594,16 @@ describe "Community" do | |
| 1667 1594 | 
             
                @talisman.reload
         | 
| 1668 1595 | 
             
                @spy.reload
         | 
| 1669 1596 |  | 
| 1670 | 
            -
                writers_ids =  | 
| 1597 | 
            +
                writers_ids = @private_community.writers_row
         | 
| 1671 1598 | 
             
                writers_ids.include?(@salkar.id).should == true
         | 
| 1672 1599 | 
             
                writers_ids.include?(@talisman.id).should == true
         | 
| 1673 1600 | 
             
                writers_ids.include?(@spy.id).should == false
         | 
| 1674 1601 | 
             
                @private_community.include_writer?(@salkar).should == true
         | 
| 1675 1602 | 
             
                @private_community.include_writer?(@talisman).should == true
         | 
| 1676 1603 | 
             
                @private_community.include_writer?(@spy).should == false
         | 
| 1677 | 
            -
             | 
| 1678 | 
            -
             | 
| 1679 | 
            -
             | 
| 1680 | 
            -
                communities_info = ActiveSupport::JSON.decode @talisman.communities_info
         | 
| 1681 | 
            -
                communities_info.size.should == 2
         | 
| 1682 | 
            -
                communities_info[1].should == {"c_id" => @private_community.id, "a" => "w"}
         | 
| 1683 | 
            -
                communities_info = ActiveSupport::JSON.decode @spy.communities_info
         | 
| 1684 | 
            -
                communities_info.size.should == 1
         | 
| 1685 | 
            -
                communities_info[0].should == {"c_id" => @private_community.id, "a" => "r"}
         | 
| 1686 | 
            -
              end
         | 
| 1687 | 
            -
             | 
| 1688 | 
            -
              it "error should not raised when W access granted to user with W access" do
         | 
| 1604 | 
            +
              end
         | 
| 1605 | 
            +
             | 
| 1606 | 
            +
              it "error should raised when W access granted to user with W access" do
         | 
| 1689 1607 | 
             
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1690 1608 | 
             
                @salkar.join @public_community
         | 
| 1691 1609 | 
             
                @talisman.join @public_community
         | 
| @@ -1696,9 +1614,8 @@ describe "Community" do | |
| 1696 1614 | 
             
                @talisman.reload
         | 
| 1697 1615 | 
             
                @spy.reload
         | 
| 1698 1616 |  | 
| 1699 | 
            -
                @public_community.set_write_access @public_community.users_row
         | 
| 1700 | 
            -
                 | 
| 1701 | 
            -
                writers_ids.should == [@morozovm.id, @salkar.id, @talisman.id, @spy.id]
         | 
| 1617 | 
            +
                expect {@public_community.set_write_access @public_community.users_row}.to raise_error
         | 
| 1618 | 
            +
                (@public_community.writers_row & [@morozovm.id, @salkar.id, @talisman.id, @spy.id]).size.should == 4
         | 
| 1702 1619 | 
             
              end
         | 
| 1703 1620 |  | 
| 1704 1621 | 
             
              it "passed empty array should not lead to error" do
         | 
| @@ -1710,7 +1627,6 @@ describe "Community" do | |
| 1710 1627 |  | 
| 1711 1628 | 
             
              it "write access should not be granted" do
         | 
| 1712 1629 | 
             
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1713 | 
            -
                expect {@public_community.set_write_access [@salkar.id, @talisman.id]}.to raise_error
         | 
| 1714 1630 | 
             
                expect {@public_community.set_write_access [@talisman.id]}.to raise_error
         | 
| 1715 1631 | 
             
                expect {@public_community.set_write_access @talisman}.to raise_error
         | 
| 1716 1632 | 
             
                expect {@public_community.set_write_access [-1]}.to raise_error
         | 
| @@ -1734,22 +1650,13 @@ describe "Community" do | |
| 1734 1650 | 
             
                @talisman.reload
         | 
| 1735 1651 | 
             
                @spy.reload
         | 
| 1736 1652 |  | 
| 1737 | 
            -
                writers_ids =  | 
| 1653 | 
            +
                writers_ids = @public_community.writers_row
         | 
| 1738 1654 | 
             
                writers_ids.include?(@salkar.id).should == false
         | 
| 1739 1655 | 
             
                writers_ids.include?(@talisman.id).should == false
         | 
| 1740 1656 | 
             
                writers_ids.include?(@spy.id).should == true
         | 
| 1741 1657 | 
             
                @public_community.include_writer?(@salkar).should == false
         | 
| 1742 1658 | 
             
                @public_community.include_writer?(@talisman).should == false
         | 
| 1743 1659 | 
             
                @public_community.include_writer?(@spy).should == true
         | 
| 1744 | 
            -
                communities_info = ActiveSupport::JSON.decode @salkar.communities_info
         | 
| 1745 | 
            -
                communities_info.size.should == 1
         | 
| 1746 | 
            -
                communities_info[0].should == {"c_id" => @public_community.id, "a" => "r"}
         | 
| 1747 | 
            -
                communities_info = ActiveSupport::JSON.decode @talisman.communities_info
         | 
| 1748 | 
            -
                communities_info.size.should == 2
         | 
| 1749 | 
            -
                communities_info[1].should == {"c_id" => @public_community.id, "a" => "r"}
         | 
| 1750 | 
            -
                communities_info = ActiveSupport::JSON.decode @spy.communities_info
         | 
| 1751 | 
            -
                communities_info.size.should == 1
         | 
| 1752 | 
            -
                communities_info[0].should == {"c_id" => @public_community.id, "a" => "w"}
         | 
| 1753 1660 | 
             
              end
         | 
| 1754 1661 |  | 
| 1755 1662 | 
             
              it "read access should be set in the private community" do
         | 
| @@ -1771,25 +1678,19 @@ describe "Community" do | |
| 1771 1678 | 
             
                @talisman.reload
         | 
| 1772 1679 | 
             
                @spy.reload
         | 
| 1773 1680 |  | 
| 1774 | 
            -
                 | 
| 1775 | 
            -
                 | 
| 1776 | 
            -
                 | 
| 1777 | 
            -
                 | 
| 1681 | 
            +
                salkar_relation = ::Inkwell::CommunityUser.where(:user_id => @salkar.id, :community_id => @private_community.id).first
         | 
| 1682 | 
            +
                spy_relation = ::Inkwell::CommunityUser.where(:user_id => @spy.id, :community_id => @private_community.id).first
         | 
| 1683 | 
            +
                talisman_relation = ::Inkwell::CommunityUser.where(:user_id => @talisman.id, :community_id => @private_community.id).first
         | 
| 1684 | 
            +
                salkar_relation.user_access.should == "r"
         | 
| 1685 | 
            +
                spy_relation.user_access.should == "w"
         | 
| 1686 | 
            +
                talisman_relation.user_access.should == "r"
         | 
| 1687 | 
            +
             | 
| 1778 1688 | 
             
                @private_community.include_writer?(@salkar).should == false
         | 
| 1779 1689 | 
             
                @private_community.include_writer?(@talisman).should == false
         | 
| 1780 1690 | 
             
                @private_community.include_writer?(@spy).should == true
         | 
| 1781 | 
            -
             | 
| 1782 | 
            -
             | 
| 1783 | 
            -
             | 
| 1784 | 
            -
                communities_info = ActiveSupport::JSON.decode @talisman.communities_info
         | 
| 1785 | 
            -
                communities_info.size.should == 2
         | 
| 1786 | 
            -
                communities_info[1].should == {"c_id" => @private_community.id, "a" => "r"}
         | 
| 1787 | 
            -
                communities_info = ActiveSupport::JSON.decode @spy.communities_info
         | 
| 1788 | 
            -
                communities_info.size.should == 1
         | 
| 1789 | 
            -
                communities_info[0].should == {"c_id" => @private_community.id, "a" => "w"}
         | 
| 1790 | 
            -
              end
         | 
| 1791 | 
            -
             | 
| 1792 | 
            -
              it "error should not raised when R access set to user with R access" do
         | 
| 1691 | 
            +
              end
         | 
| 1692 | 
            +
             | 
| 1693 | 
            +
              it "error shouldraised when R access set to user with R access" do
         | 
| 1793 1694 | 
             
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1794 1695 | 
             
                @public_community.default_user_access = 'r'
         | 
| 1795 1696 | 
             
                @public_community.save
         | 
| @@ -1802,9 +1703,8 @@ describe "Community" do | |
| 1802 1703 | 
             
                @talisman.reload
         | 
| 1803 1704 | 
             
                @spy.reload
         | 
| 1804 1705 |  | 
| 1805 | 
            -
                @public_community.set_read_access (@public_community.users_row - [@morozovm.id])
         | 
| 1806 | 
            -
                 | 
| 1807 | 
            -
                writers_ids.should == [@morozovm.id]
         | 
| 1706 | 
            +
                expect { @public_community.set_read_access (@public_community.users_row - [@morozovm.id]) }.to raise_error
         | 
| 1707 | 
            +
                @public_community.writers_row.should == [@morozovm.id]
         | 
| 1808 1708 | 
             
              end
         | 
| 1809 1709 |  | 
| 1810 1710 | 
             
              it "passed empty array should not lead to error" do
         | 
| @@ -1853,4 +1753,421 @@ describe "Community" do | |
| 1853 1753 | 
             
                @public_community.writers_row.should == [@morozovm.id, @talisman.id, @salkar.id, @spy.id]
         | 
| 1854 1754 | 
             
              end
         | 
| 1855 1755 |  | 
| 1756 | 
            +
              it "counters should be incremented when user enters into the community" do
         | 
| 1757 | 
            +
                @community_1.reload
         | 
| 1758 | 
            +
                @community_1.add_user :admin => @talisman, :user => @salkar
         | 
| 1759 | 
            +
                @community_1.reload
         | 
| 1760 | 
            +
                @community_1.user_count.should == 2
         | 
| 1761 | 
            +
                @salkar.reload
         | 
| 1762 | 
            +
                @salkar.community_count.should == 1
         | 
| 1763 | 
            +
                @talisman.reload
         | 
| 1764 | 
            +
                @talisman.community_count.should == 1
         | 
| 1765 | 
            +
              end
         | 
| 1766 | 
            +
             | 
| 1767 | 
            +
              it "counters should be incremented for community owner when he creates community" do
         | 
| 1768 | 
            +
                @community_1.reload
         | 
| 1769 | 
            +
                @community_1.user_count.should == 1
         | 
| 1770 | 
            +
                @talisman.community_count.should == 1
         | 
| 1771 | 
            +
              end
         | 
| 1772 | 
            +
             | 
| 1773 | 
            +
              it "counters should be decremented when user leaves community" do
         | 
| 1774 | 
            +
                @community_1.reload
         | 
| 1775 | 
            +
                @community_1.add_user :admin => @talisman, :user => @salkar
         | 
| 1776 | 
            +
                @community_1.reload
         | 
| 1777 | 
            +
                @salkar.reload
         | 
| 1778 | 
            +
                @community_1.user_count.should == 2
         | 
| 1779 | 
            +
                @community_1.remove_user :admin => @talisman, :user => @salkar
         | 
| 1780 | 
            +
                @community_1.reload
         | 
| 1781 | 
            +
                @community_1.user_count.should == 1
         | 
| 1782 | 
            +
                @salkar.reload
         | 
| 1783 | 
            +
                @salkar.community_count.should == 0
         | 
| 1784 | 
            +
                @talisman.reload
         | 
| 1785 | 
            +
                @talisman.community_count.should == 1
         | 
| 1786 | 
            +
              end
         | 
| 1787 | 
            +
             | 
| 1788 | 
            +
              it "counters should be decremented when community has been destroyed" do
         | 
| 1789 | 
            +
                @community_1.add_user :admin => @talisman, :user => @salkar
         | 
| 1790 | 
            +
                @community_1.destroy
         | 
| 1791 | 
            +
                @salkar.reload
         | 
| 1792 | 
            +
                @salkar.community_count.should == 0
         | 
| 1793 | 
            +
                @talisman.reload
         | 
| 1794 | 
            +
                @talisman.community_count.should == 0
         | 
| 1795 | 
            +
              end
         | 
| 1796 | 
            +
             | 
| 1797 | 
            +
              it "writer counter should be incremented when user enters to community" do
         | 
| 1798 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1799 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1800 | 
            +
                @public_community.reload
         | 
| 1801 | 
            +
                @public_community.writer_count.should == 2
         | 
| 1802 | 
            +
              end
         | 
| 1803 | 
            +
             | 
| 1804 | 
            +
              it "writer counter should not be incremented when user enters to community" do
         | 
| 1805 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1806 | 
            +
                @public_community.default_user_access = 'r'
         | 
| 1807 | 
            +
                @public_community.save
         | 
| 1808 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1809 | 
            +
                @public_community.reload
         | 
| 1810 | 
            +
                @public_community.writer_count.should == 1
         | 
| 1811 | 
            +
              end
         | 
| 1812 | 
            +
             | 
| 1813 | 
            +
              it "writer counter should be incremented for community owner" do
         | 
| 1814 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1815 | 
            +
                @public_community.reload
         | 
| 1816 | 
            +
                @public_community.writer_count.should == 1
         | 
| 1817 | 
            +
              end
         | 
| 1818 | 
            +
             | 
| 1819 | 
            +
              it "writer counter should be decremented when user is removed" do
         | 
| 1820 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1821 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1822 | 
            +
                @public_community.reload
         | 
| 1823 | 
            +
                @public_community.remove_user :user => @salkar
         | 
| 1824 | 
            +
                @public_community.reload
         | 
| 1825 | 
            +
                @public_community.writer_count.should == 1
         | 
| 1826 | 
            +
              end
         | 
| 1827 | 
            +
             | 
| 1828 | 
            +
              it "writer counter should be decremented when user is removed" do
         | 
| 1829 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1830 | 
            +
                @public_community.default_user_access = 'r'
         | 
| 1831 | 
            +
                @public_community.save
         | 
| 1832 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1833 | 
            +
                @public_community.remove_user :user => @salkar
         | 
| 1834 | 
            +
                @public_community.reload
         | 
| 1835 | 
            +
                @public_community.writer_count.should == 1
         | 
| 1836 | 
            +
              end
         | 
| 1837 | 
            +
             | 
| 1838 | 
            +
              it "writer count should be incremented when admin gives W access to user" do
         | 
| 1839 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1840 | 
            +
                @public_community.default_user_access = 'r'
         | 
| 1841 | 
            +
                @public_community.save
         | 
| 1842 | 
            +
                @public_community.reload
         | 
| 1843 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1844 | 
            +
                @public_community.reload
         | 
| 1845 | 
            +
                @public_community.set_write_access [@salkar.id]
         | 
| 1846 | 
            +
                @public_community.reload
         | 
| 1847 | 
            +
                @public_community.writer_count.should == 2
         | 
| 1848 | 
            +
              end
         | 
| 1849 | 
            +
             | 
| 1850 | 
            +
              it "writer and user counters should be decremeted when user destroy his accaunt" do
         | 
| 1851 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1852 | 
            +
                @public_community.reload
         | 
| 1853 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1854 | 
            +
                @public_community.reload
         | 
| 1855 | 
            +
                @salkar.reload
         | 
| 1856 | 
            +
                @salkar.destroy
         | 
| 1857 | 
            +
                @public_community.reload
         | 
| 1858 | 
            +
                @public_community.user_count.should == 1
         | 
| 1859 | 
            +
                @public_community.writer_count.should == 1
         | 
| 1860 | 
            +
              end
         | 
| 1861 | 
            +
             | 
| 1862 | 
            +
              it "writer count should be decremented when admin set R access for user" do
         | 
| 1863 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1864 | 
            +
                @public_community.reload
         | 
| 1865 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1866 | 
            +
                @public_community.reload
         | 
| 1867 | 
            +
                @public_community.set_read_access [@salkar.id]
         | 
| 1868 | 
            +
                @public_community.reload
         | 
| 1869 | 
            +
                @public_community.writer_count.should == 1
         | 
| 1870 | 
            +
              end
         | 
| 1871 | 
            +
             | 
| 1872 | 
            +
              it "reader count should be returned for community" do
         | 
| 1873 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1874 | 
            +
                @public_community.reload
         | 
| 1875 | 
            +
                @public_community.reader_count.should == 0
         | 
| 1876 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1877 | 
            +
                @public_community.reload
         | 
| 1878 | 
            +
                @public_community.reader_count.should == 0
         | 
| 1879 | 
            +
                @public_community.set_read_access [@salkar.id]
         | 
| 1880 | 
            +
                @public_community.reload
         | 
| 1881 | 
            +
                @public_community.reader_count.should == 1
         | 
| 1882 | 
            +
                @public_community.default_user_access = 'r'
         | 
| 1883 | 
            +
                @public_community.save
         | 
| 1884 | 
            +
                @public_community.add_user :user => @talisman
         | 
| 1885 | 
            +
                @public_community.reload
         | 
| 1886 | 
            +
                @public_community.reader_count.should == 2
         | 
| 1887 | 
            +
              end
         | 
| 1888 | 
            +
             | 
| 1889 | 
            +
              it "community should not be created if owner id is nonexistent" do
         | 
| 1890 | 
            +
                c_size = Community.all.size
         | 
| 1891 | 
            +
                expect {@public_community = Community.create :name => "community", :owner_id => -1}.to raise_error
         | 
| 1892 | 
            +
                Community.all.size.should == c_size
         | 
| 1893 | 
            +
              end
         | 
| 1894 | 
            +
             | 
| 1895 | 
            +
              it "admin counter should be incremented when admin is added" do
         | 
| 1896 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1897 | 
            +
                @public_community.reload
         | 
| 1898 | 
            +
                @public_community.add_user :user => @salkar
         | 
| 1899 | 
            +
                @public_community.reload
         | 
| 1900 | 
            +
                @public_community.admin_count.should == 1
         | 
| 1901 | 
            +
                @public_community.add_admin :user => @salkar, :admin => @morozovm
         | 
| 1902 | 
            +
                @public_community.reload
         | 
| 1903 | 
            +
                @public_community.admin_count.should == 2
         | 
| 1904 | 
            +
              end
         | 
| 1905 | 
            +
             | 
| 1906 | 
            +
              it "admin counter should be 1 after community is created" do
         | 
| 1907 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 1908 | 
            +
                @public_community.reload
         | 
| 1909 | 
            +
                @public_community.admin_count.should == 1
         | 
| 1910 | 
            +
              end
         | 
| 1911 | 
            +
             | 
| 1912 | 
            +
              it "admin counter should be decremented after admin is removed" do
         | 
| 1913 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1914 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 1915 | 
            +
                @community_1.reload
         | 
| 1916 | 
            +
                @community_1.admin_count.should == 2
         | 
| 1917 | 
            +
                @community_1.remove_admin :user => @salkar, :admin => @talisman
         | 
| 1918 | 
            +
                @community_1.reload
         | 
| 1919 | 
            +
                @community_1.admin_count.should == 1
         | 
| 1920 | 
            +
              end
         | 
| 1921 | 
            +
             | 
| 1922 | 
            +
              it "admin counter should be decremeted when admin is removed from community" do
         | 
| 1923 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1924 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 1925 | 
            +
                @community_1.reload
         | 
| 1926 | 
            +
                @community_1.admin_count.should == 2
         | 
| 1927 | 
            +
                @community_1.remove_user :user => @salkar, :admin => @talisman
         | 
| 1928 | 
            +
                @community_1.reload
         | 
| 1929 | 
            +
                @community_1.admin_count.should == 1
         | 
| 1930 | 
            +
              end
         | 
| 1931 | 
            +
             | 
| 1932 | 
            +
              it "admin counter should be decremented when admin destroy his account" do
         | 
| 1933 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1934 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 1935 | 
            +
                @community_1.reload
         | 
| 1936 | 
            +
                @community_1.admin_count.should == 2
         | 
| 1937 | 
            +
                @salkar.destroy
         | 
| 1938 | 
            +
                @community_1.reload
         | 
| 1939 | 
            +
                @community_1.admin_count.should == 1
         | 
| 1940 | 
            +
              end
         | 
| 1941 | 
            +
             | 
| 1942 | 
            +
              it "muted counter should be incremented when admin mutes user" do
         | 
| 1943 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1944 | 
            +
                @community_1.muted_count.should == 0
         | 
| 1945 | 
            +
                @community_1.mute_user :user => @salkar, :admin => @talisman
         | 
| 1946 | 
            +
                @community_1.reload
         | 
| 1947 | 
            +
                @community_1.muted_count.should == 1
         | 
| 1948 | 
            +
              end
         | 
| 1949 | 
            +
             | 
| 1950 | 
            +
              it "muted counter should be decreaded when admin status is getting by muted user" do
         | 
| 1951 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1952 | 
            +
                @community_1.mute_user :user => @salkar, :admin => @talisman
         | 
| 1953 | 
            +
                @community_1.reload
         | 
| 1954 | 
            +
                @community_1.muted_count.should == 1
         | 
| 1955 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 1956 | 
            +
                @community_1.reload
         | 
| 1957 | 
            +
                @community_1.muted_count.should == 0
         | 
| 1958 | 
            +
              end
         | 
| 1959 | 
            +
             | 
| 1960 | 
            +
              it "muted counter should be decreased when admin unmutes user" do
         | 
| 1961 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1962 | 
            +
                @community_1.mute_user :user => @salkar, :admin => @talisman
         | 
| 1963 | 
            +
                @community_1.reload
         | 
| 1964 | 
            +
                @community_1.muted_count.should == 1
         | 
| 1965 | 
            +
                @community_1.unmute_user :user => @salkar, :admin => @talisman
         | 
| 1966 | 
            +
                @community_1.reload
         | 
| 1967 | 
            +
                @community_1.muted_count.should == 0
         | 
| 1968 | 
            +
              end
         | 
| 1969 | 
            +
             | 
| 1970 | 
            +
              it "muted counter should be decreased when muted user is removed from community" do
         | 
| 1971 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1972 | 
            +
                @community_1.mute_user :user => @salkar, :admin => @talisman
         | 
| 1973 | 
            +
                @community_1.reload
         | 
| 1974 | 
            +
                @community_1.muted_count.should == 1
         | 
| 1975 | 
            +
                @community_1.remove_user :user => @salkar, :admin => @talisman
         | 
| 1976 | 
            +
                @community_1.reload
         | 
| 1977 | 
            +
                @community_1.muted_count.should == 0
         | 
| 1978 | 
            +
              end
         | 
| 1979 | 
            +
             | 
| 1980 | 
            +
              it "muted counter should be decreased when muted user destroys his accaunt" do
         | 
| 1981 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1982 | 
            +
                @community_1.mute_user :user => @salkar, :admin => @talisman
         | 
| 1983 | 
            +
                @community_1.reload
         | 
| 1984 | 
            +
                @community_1.muted_count.should == 1
         | 
| 1985 | 
            +
                @salkar.destroy
         | 
| 1986 | 
            +
                @community_1.reload
         | 
| 1987 | 
            +
                @community_1.muted_count.should == 0
         | 
| 1988 | 
            +
              end
         | 
| 1989 | 
            +
             | 
| 1990 | 
            +
              it "banned counter should be increased when admin bans user" do
         | 
| 1991 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 1992 | 
            +
                @community_1.ban_user :user => @salkar, :admin => @talisman
         | 
| 1993 | 
            +
                @community_1.reload
         | 
| 1994 | 
            +
                @community_1.banned_count.should == 1
         | 
| 1995 | 
            +
                @community_1.include_banned_user?(@salkar).should == true
         | 
| 1996 | 
            +
              end
         | 
| 1997 | 
            +
             | 
| 1998 | 
            +
              it "banned counter should be decreased when admin unbans user" do
         | 
| 1999 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 2000 | 
            +
                @community_1.ban_user :user => @salkar, :admin => @talisman
         | 
| 2001 | 
            +
                @community_1.reload
         | 
| 2002 | 
            +
                @community_1.banned_count.should == 1
         | 
| 2003 | 
            +
                @community_1.include_banned_user?(@salkar).should == true
         | 
| 2004 | 
            +
                @community_1.unban_user :user => @salkar, :admin => @talisman
         | 
| 2005 | 
            +
                @community_1.reload
         | 
| 2006 | 
            +
                @community_1.banned_count.should == 0
         | 
| 2007 | 
            +
                @community_1.include_banned_user?(@salkar).should == false
         | 
| 2008 | 
            +
              end
         | 
| 2009 | 
            +
             | 
| 2010 | 
            +
              it "banned counter should be decremeted when user destroys his accaunt" do
         | 
| 2011 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 2012 | 
            +
                @community_1.ban_user :user => @salkar, :admin => @talisman
         | 
| 2013 | 
            +
                @community_1.reload
         | 
| 2014 | 
            +
                @community_1.banned_count.should == 1
         | 
| 2015 | 
            +
                @salkar.destroy
         | 
| 2016 | 
            +
                @community_1.reload
         | 
| 2017 | 
            +
                @community_1.banned_count.should == 0
         | 
| 2018 | 
            +
              end
         | 
| 2019 | 
            +
             | 
| 2020 | 
            +
              it "user counter should be decremented when admin ban user" do
         | 
| 2021 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 2022 | 
            +
                @community_1.reload
         | 
| 2023 | 
            +
                @community_1.user_count.should == 2
         | 
| 2024 | 
            +
                @community_1.ban_user :user => @salkar, :admin => @talisman
         | 
| 2025 | 
            +
                @community_1.reload
         | 
| 2026 | 
            +
                @community_1.user_count.should == 1
         | 
| 2027 | 
            +
              end
         | 
| 2028 | 
            +
             | 
| 2029 | 
            +
              it "invitation counter should be incremented when user asks invitation" do
         | 
| 2030 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2031 | 
            +
                @private_community.reload
         | 
| 2032 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2033 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2034 | 
            +
                @private_community.reload
         | 
| 2035 | 
            +
                @private_community.invitation_count.should == 1
         | 
| 2036 | 
            +
              end
         | 
| 2037 | 
            +
             | 
| 2038 | 
            +
              it "invitation counter should be decremented when admin accept invitation" do
         | 
| 2039 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2040 | 
            +
                @private_community.reload
         | 
| 2041 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2042 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2043 | 
            +
                @private_community.reload
         | 
| 2044 | 
            +
                @private_community.invitation_count.should == 1
         | 
| 2045 | 
            +
                @private_community.accept_invitation_request :user => @salkar, :admin => @morozovm
         | 
| 2046 | 
            +
                @private_community.reload
         | 
| 2047 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2048 | 
            +
              end
         | 
| 2049 | 
            +
             | 
| 2050 | 
            +
              it "invitation counter should be decremented when admin reject invitation" do
         | 
| 2051 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2052 | 
            +
                @private_community.reload
         | 
| 2053 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2054 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2055 | 
            +
                @private_community.reload
         | 
| 2056 | 
            +
                @private_community.invitation_count.should == 1
         | 
| 2057 | 
            +
                @private_community.reject_invitation_request :user => @salkar, :admin => @morozovm
         | 
| 2058 | 
            +
                @private_community.reload
         | 
| 2059 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2060 | 
            +
              end
         | 
| 2061 | 
            +
             | 
| 2062 | 
            +
              it "invitation counter should be decremented when admin ban asked user" do
         | 
| 2063 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2064 | 
            +
                @private_community.reload
         | 
| 2065 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2066 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2067 | 
            +
                @private_community.reload
         | 
| 2068 | 
            +
                @private_community.invitation_count.should == 1
         | 
| 2069 | 
            +
                @private_community.ban_user :user => @salkar, :admin => @morozovm
         | 
| 2070 | 
            +
                @private_community.reload
         | 
| 2071 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2072 | 
            +
              end
         | 
| 2073 | 
            +
             | 
| 2074 | 
            +
              it "invitation counter should be decremented when user destroys his accaunt" do
         | 
| 2075 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2076 | 
            +
                @private_community.reload
         | 
| 2077 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2078 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2079 | 
            +
                @private_community.reload
         | 
| 2080 | 
            +
                @private_community.invitation_count.should == 1
         | 
| 2081 | 
            +
                @salkar.destroy
         | 
| 2082 | 
            +
                @private_community.reload
         | 
| 2083 | 
            +
                @private_community.invitation_count.should == 0
         | 
| 2084 | 
            +
              end
         | 
| 2085 | 
            +
             | 
| 2086 | 
            +
              it "communities should be returned for their member" do
         | 
| 2087 | 
            +
                @public_community = Community.create :name => "Community", :owner_id => @morozovm.id
         | 
| 2088 | 
            +
                @talisman.join @public_community
         | 
| 2089 | 
            +
                communities = @talisman.communities
         | 
| 2090 | 
            +
                communities.include?(@community_1).should == true
         | 
| 2091 | 
            +
                communities.include?(@public_community).should == true
         | 
| 2092 | 
            +
                communities.size.should == 2
         | 
| 2093 | 
            +
              end
         | 
| 2094 | 
            +
             | 
| 2095 | 
            +
              it "communities should be returned for their member" do
         | 
| 2096 | 
            +
                @public_community = Community.create :name => "Community", :owner_id => @morozovm.id
         | 
| 2097 | 
            +
                @talisman.join @public_community
         | 
| 2098 | 
            +
                @salkar.join @public_community
         | 
| 2099 | 
            +
                @spy.join @public_community
         | 
| 2100 | 
            +
                users = @public_community.users
         | 
| 2101 | 
            +
                users.include?(@morozovm).should == true
         | 
| 2102 | 
            +
                users.include?(@talisman).should == true
         | 
| 2103 | 
            +
                users.include?(@salkar).should == true
         | 
| 2104 | 
            +
                users.include?(@spy).should == true
         | 
| 2105 | 
            +
                users.size.should == 4
         | 
| 2106 | 
            +
              end
         | 
| 2107 | 
            +
             | 
| 2108 | 
            +
              it "admins should be returned for community" do
         | 
| 2109 | 
            +
                @community_1.admins.should == [@talisman]
         | 
| 2110 | 
            +
                @community_1.add_user :user => @salkar, :admin => @talisman
         | 
| 2111 | 
            +
                @community_1.admins.should == [@talisman]
         | 
| 2112 | 
            +
                @community_1.add_admin :user => @salkar, :admin => @talisman
         | 
| 2113 | 
            +
                @community_1.reload
         | 
| 2114 | 
            +
                @community_1.admins.should == [@talisman, @salkar]
         | 
| 2115 | 
            +
              end
         | 
| 2116 | 
            +
             | 
| 2117 | 
            +
              it "writers should be returned for community" do
         | 
| 2118 | 
            +
                @public_community = Community.create :name => "community", :owner_id => @morozovm.id
         | 
| 2119 | 
            +
                @public_community.default_user_access = 'r'
         | 
| 2120 | 
            +
                @public_community.save
         | 
| 2121 | 
            +
                @public_community.reload
         | 
| 2122 | 
            +
                @public_community.writers.should == [@morozovm]
         | 
| 2123 | 
            +
                @salkar.join @public_community
         | 
| 2124 | 
            +
                @public_community.reload
         | 
| 2125 | 
            +
                @public_community.writers.should == [@morozovm]
         | 
| 2126 | 
            +
                @public_community.set_write_access [@salkar.id]
         | 
| 2127 | 
            +
                @public_community.reload
         | 
| 2128 | 
            +
                @public_community.writers.should == [@morozovm, @salkar]
         | 
| 2129 | 
            +
              end
         | 
| 2130 | 
            +
             | 
| 2131 | 
            +
              it "muted users should be returned for community" do
         | 
| 2132 | 
            +
                @community_1.muted_users.should == []
         | 
| 2133 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 2134 | 
            +
                @community_1.mute_user :user => @salkar, :admin => @talisman
         | 
| 2135 | 
            +
                @community_1.reload
         | 
| 2136 | 
            +
                @community_1.muted_users.should == [@salkar]
         | 
| 2137 | 
            +
              end
         | 
| 2138 | 
            +
             | 
| 2139 | 
            +
              it "banned users should be returned for community" do
         | 
| 2140 | 
            +
                @community_1.banned_users.should == []
         | 
| 2141 | 
            +
                @community_1.add_user :user => @salkar
         | 
| 2142 | 
            +
                @community_1.ban_user :user => @salkar, :admin => @talisman
         | 
| 2143 | 
            +
                @community_1.reload
         | 
| 2144 | 
            +
                @community_1.banned_users.should == [@salkar]
         | 
| 2145 | 
            +
              end
         | 
| 2146 | 
            +
             | 
| 2147 | 
            +
              it "asked invitation users should be returned for community" do
         | 
| 2148 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2149 | 
            +
                @private_community.asked_invitation_users.should == []
         | 
| 2150 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2151 | 
            +
                @private_community.reload
         | 
| 2152 | 
            +
                @private_community.asked_invitation_users.should == [@salkar]
         | 
| 2153 | 
            +
                @private_community.accept_invitation_request :user => @salkar, :admin => @morozovm
         | 
| 2154 | 
            +
                @private_community.reload
         | 
| 2155 | 
            +
                @private_community.asked_invitation_users.should == []
         | 
| 2156 | 
            +
              end
         | 
| 2157 | 
            +
             | 
| 2158 | 
            +
              it "invitation_uids should be returned for community" do
         | 
| 2159 | 
            +
                @private_community = Community.create :name => "Private Community", :owner_id => @morozovm.id, :public => false
         | 
| 2160 | 
            +
                @private_community.invitations_row.should == []
         | 
| 2161 | 
            +
                @private_community.create_invitation_request @salkar
         | 
| 2162 | 
            +
                @private_community.create_invitation_request @talisman
         | 
| 2163 | 
            +
                @private_community.reload
         | 
| 2164 | 
            +
                @private_community.invitations_row.should == [@salkar.id, @talisman.id]
         | 
| 2165 | 
            +
              end
         | 
| 2166 | 
            +
             | 
| 2167 | 
            +
              it "user should not be destroyed if he is owner of some communities" do
         | 
| 2168 | 
            +
                expect {@talisman.destroy}.to raise_error
         | 
| 2169 | 
            +
                @talisman.reload
         | 
| 2170 | 
            +
                @talisman.should be
         | 
| 2171 | 
            +
              end
         | 
| 2172 | 
            +
             | 
| 1856 2173 | 
             
            end
         |