-
Notifications
You must be signed in to change notification settings - Fork 7
Jb/gamification #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
72bda3b
32e8307
7f5e897
423b140
d79a2cb
ae5af59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| require 'spec_helper' | ||
|
|
||
| feature "Merit Point Rules" do | ||
| include SessionSteps | ||
|
|
||
| background do | ||
| @user = create :user_with_account | ||
| end | ||
|
|
||
| scenario "joining event earns 1 point" do | ||
| # setting up scenario | ||
| @points = @user.points | ||
| @group = create(:group) | ||
| @group.assign_user @user, at: 1.year.ago | ||
| @event1 = @group.child_events.create name: "Gamification Hacking Workshop", start_at: 1.day.from_now | ||
| @event2 = @group.child_events.create name: "Another meeting", start_at: 10.day.from_now | ||
|
|
||
| # Just looking at events#index does nothing. | ||
| login @user | ||
| visit root_path | ||
| @user.reload.points.should == @points | ||
|
|
||
| # Joining an event should add a point. | ||
| visit root_path | ||
| within('.box.upcoming_events') { click_on @event1.name } | ||
| page.should have_selector '#join_event', visible: true | ||
| find('#join_event').click | ||
| @user.reload.points.should == @points+1 | ||
|
|
||
| visit root_path | ||
| within('.box.upcoming_events') { click_on @event2.name } | ||
| page.should have_selector '#join_event', visible: true | ||
| find('#join_event').click | ||
| @user.reload.points.should == @points+2 | ||
| end | ||
|
|
||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # -*- coding: utf-8 -*- | ||
| require 'spec_helper' | ||
|
|
||
| describe User do | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Die Datei Ich würde vorschlagen, dass Du den Test als Feature-Spec konzipierst, ähnlich https://github.com/fiedl/your_platform/blob/master/spec/features/merit_badge_rules_spec.rb. |
||
|
|
||
| before do | ||
| @user = create( :user ) | ||
| @user.save | ||
| @points = @user.points | ||
| end | ||
|
|
||
| subject { @user } | ||
|
|
||
| # Validation | ||
| # ========================================================================================== | ||
|
|
||
| it { should be_valid } | ||
|
|
||
|
|
||
| # Basic Properties | ||
| # ========================================================================================== | ||
|
|
||
| describe "events#join" do | ||
| subject { @user } | ||
| [ :first_name, :last_name, :alias, :email, :create_account, :female, :add_to_group ].each do |attr| | ||
| it { should respond_to( attr ) } | ||
| it { should respond_to( "#{attr}=".to_sym ) } | ||
| end | ||
| end | ||
|
|
||
| describe "events#join" do | ||
| subject { @user.join(@event); time_travel(2.seconds) } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Funktioniert das denn? Ich dachte, merit hängt sich an den Controller. Werden also für Veränderungen auf Model-Ebene ( Ist dieser Test bei Dir grün?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ja, auch auf travis. weil die Point-Rules am Modell vergeben werden. Ich schau ja nur, ob es mehr Punkte geworden sind. |
||
| describe "(joining an event)" do | ||
| before { @event = create(:event); subject } | ||
| specify { @event.attendees.should include @user} | ||
| specify { @event.attendees_group.members.should include @user } | ||
| specify "the user should have earned points" do | ||
| @user.points > @points | ||
| end | ||
| end | ||
|
|
||
| end | ||
|
|
||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mit dieser Beschreibung stimmt auch etwas nicht. Ein Teilnehmer erstellt doch nicht de Veranstaltung.
Sieh den Pull-Request lieber nochmal durch. Hierzu eignet sich diese Übersicht-Seite recht gut: https://github.com/fiedl/your_platform/pull/8/files