|
1 | 1 | require 'spec_helper' |
2 | | -require_dependency 'mothership' |
| 2 | +require_dependency 'discourse_hub' |
3 | 3 |
|
4 | | -describe Mothership do |
| 4 | +describe DiscourseHub do |
5 | 5 | describe '#nickname_available?' do |
6 | 6 | it 'should return true when nickname is available and no suggestion' do |
7 | 7 | RestClient.stubs(:get).returns( {success: 'OK', available: true}.to_json ) |
8 | | - Mothership.nickname_available?('MacGyver').should == [true, nil] |
| 8 | + DiscourseHub.nickname_available?('MacGyver').should == [true, nil] |
9 | 9 | end |
10 | 10 |
|
11 | 11 | it 'should return false and a suggestion when nickname is not available' do |
12 | 12 | RestClient.stubs(:get).returns( {success: 'OK', available: false, suggestion: 'MacGyver1'}.to_json ) |
13 | | - available, suggestion = Mothership.nickname_available?('MacGyver') |
| 13 | + available, suggestion = DiscourseHub.nickname_available?('MacGyver') |
14 | 14 | available.should be_false |
15 | 15 | suggestion.should_not be_nil |
16 | 16 | end |
|
21 | 21 | describe '#nickname_match?' do |
22 | 22 | it 'should return true when it is a match and no suggestion' do |
23 | 23 | RestClient.stubs(:get).returns( {success: 'OK', match: true, available: false}.to_json ) |
24 | | - Mothership.nickname_match?('MacGyver', 'macg@example.com').should == [true, false, nil] |
| 24 | + DiscourseHub.nickname_match?('MacGyver', 'macg@example.com').should == [true, false, nil] |
25 | 25 | end |
26 | 26 |
|
27 | 27 | it 'should return false and a suggestion when it is not a match and the nickname is not available' do |
28 | 28 | RestClient.stubs(:get).returns( {success: 'OK', match: false, available: false, suggestion: 'MacGyver1'}.to_json ) |
29 | | - match, available, suggestion = Mothership.nickname_match?('MacGyver', 'macg@example.com') |
| 29 | + match, available, suggestion = DiscourseHub.nickname_match?('MacGyver', 'macg@example.com') |
30 | 30 | match.should be_false |
31 | 31 | available.should be_false |
32 | 32 | suggestion.should_not be_nil |
33 | 33 | end |
34 | 34 |
|
35 | 35 | it 'should return false and no suggestion when it is not a match and the nickname is available' do |
36 | 36 | RestClient.stubs(:get).returns( {success: 'OK', match: false, available: true}.to_json ) |
37 | | - match, available, suggestion = Mothership.nickname_match?('MacGyver', 'macg@example.com') |
| 37 | + match, available, suggestion = DiscourseHub.nickname_match?('MacGyver', 'macg@example.com') |
38 | 38 | match.should be_false |
39 | 39 | available.should be_true |
40 | 40 | suggestion.should be_nil |
|
44 | 44 | describe '#register_nickname' do |
45 | 45 | it 'should return true when registration succeeds' do |
46 | 46 | RestClient.stubs(:post).returns( {success: 'OK'}.to_json ) |
47 | | - Mothership.register_nickname('MacGyver', 'macg@example.com').should be_true |
| 47 | + DiscourseHub.register_nickname('MacGyver', 'macg@example.com').should be_true |
48 | 48 | end |
49 | 49 |
|
50 | 50 | it 'should return raise an exception when registration fails' do |
51 | 51 | RestClient.stubs(:post).returns( {failed: -200}.to_json ) |
52 | 52 | expect { |
53 | | - Mothership.register_nickname('MacGyver', 'macg@example.com') |
54 | | - }.to raise_error(Mothership::NicknameUnavailable) |
| 53 | + DiscourseHub.register_nickname('MacGyver', 'macg@example.com') |
| 54 | + }.to raise_error(DiscourseHub::NicknameUnavailable) |
55 | 55 | end |
56 | 56 | end |
57 | 57 |
|
58 | 58 | describe '#current_discourse_version' do |
59 | 59 | it 'should return the latest version of discourse' do |
60 | 60 | RestClient.stubs(:get).returns( {success: 'OK', version: 1.0}.to_json ) |
61 | | - Mothership.current_discourse_version().should == 1.0 |
| 61 | + DiscourseHub.current_discourse_version().should == 1.0 |
62 | 62 | end |
63 | 63 | end |
64 | 64 |
|
65 | 65 | describe '#change_nickname' do |
66 | 66 | it 'should return true when nickname is changed successfully' do |
67 | 67 | RestClient.stubs(:put).returns( {success: 'OK'}.to_json ) |
68 | | - Mothership.change_nickname('MacGyver', 'MacG').should be_true |
| 68 | + DiscourseHub.change_nickname('MacGyver', 'MacG').should be_true |
69 | 69 | end |
70 | 70 |
|
71 | 71 | it 'should return raise NicknameUnavailable when nickname is not available' do |
72 | 72 | RestClient.stubs(:put).returns( {failed: -200}.to_json ) |
73 | 73 | expect { |
74 | | - Mothership.change_nickname('MacGyver', 'MacG') |
75 | | - }.to raise_error(Mothership::NicknameUnavailable) |
| 74 | + DiscourseHub.change_nickname('MacGyver', 'MacG') |
| 75 | + }.to raise_error(DiscourseHub::NicknameUnavailable) |
76 | 76 | end |
77 | 77 |
|
78 | | - # TODO: General error handling in mothership.rb |
79 | 78 |
|
80 | 79 | # it 'should return raise NicknameUnavailable when nickname does not belong to this forum' do |
81 | 80 | # RestClient.stubs(:put).returns( {failed: -13}.to_json ) |
82 | 81 | # expect { |
83 | | - # Mothership.change_nickname('MacGyver', 'MacG') |
84 | | - # }.to raise_error(Mothership::ActionForbidden) |
| 82 | + # DiscourseHub.change_nickname('MacGyver', 'MacG') |
| 83 | + # }.to raise_error(DiscourseHub::ActionForbidden) |
85 | 84 | # end |
86 | 85 |
|
87 | 86 | # it 'should return raise NicknameUnavailable when nickname does not belong to this forum' do |
88 | 87 | # RestClient.stubs(:put).returns( {failed: -13}.to_json ) |
89 | 88 | # expect { |
90 | | - # Mothership.change_nickname('MacGyver', 'MacG') |
91 | | - # }.to raise_error(Mothership::ActionForbidden) |
| 89 | + # DiscourseHub.change_nickname('MacGyver', 'MacG') |
| 90 | + # }.to raise_error(DiscourseHub::ActionForbidden) |
92 | 91 | # end |
93 | 92 | end |
94 | 93 | end |
0 commit comments